2020-09-03 14:08:29 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-03-12 07:09:33 -05:00
|
|
|
return unless helper.ci?
|
2020-09-03 14:08:29 -04:00
|
|
|
|
|
|
|
SPECIALIZATIONS = {
|
|
|
|
database: 'database',
|
|
|
|
backend: 'backend',
|
|
|
|
frontend: 'frontend',
|
|
|
|
docs: 'documentation',
|
|
|
|
qa: 'QA',
|
2020-10-13 08:08:41 -04:00
|
|
|
engineering_productivity: 'Engineering Productivity',
|
|
|
|
ci_template: 'ci::templates'
|
2020-09-03 14:08:29 -04:00
|
|
|
}.freeze
|
|
|
|
|
2021-03-12 07:09:33 -05:00
|
|
|
labels_to_add = project_helper.changes_by_category.each_with_object([]) do |(category, _changes), memo|
|
2020-09-08 05:08:31 -04:00
|
|
|
label = SPECIALIZATIONS[category]
|
|
|
|
|
|
|
|
memo << label if label && !gitlab.mr_labels.include?(label)
|
2020-09-03 14:08:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
if labels_to_add.any?
|
|
|
|
gitlab.api.update_merge_request(gitlab.mr_json['project_id'],
|
|
|
|
gitlab.mr_json['iid'],
|
|
|
|
add_labels: labels_to_add.join(','))
|
|
|
|
end
|