2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
return unless helper.ci?
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
SPECIALIZATIONS = {
|
|
|
|
database: 'database',
|
|
|
|
backend: 'backend',
|
|
|
|
frontend: 'frontend',
|
|
|
|
docs: 'documentation',
|
|
|
|
qa: 'QA',
|
2021-01-03 14:25:43 +05:30
|
|
|
engineering_productivity: 'Engineering Productivity',
|
2021-09-30 23:02:18 +05:30
|
|
|
ci_template: 'ci::templates',
|
|
|
|
feature_flag: 'feature flag'
|
2020-11-24 15:15:51 +05:30
|
|
|
}.freeze
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
labels_to_add = project_helper.changes_by_category.each_with_object([]) do |(category, _changes), memo|
|
2020-11-24 15:15:51 +05:30
|
|
|
label = SPECIALIZATIONS[category]
|
|
|
|
|
|
|
|
memo << label if label && !gitlab.mr_labels.include?(label)
|
|
|
|
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
|