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',
|
2021-07-27 17:09:42 -04:00
|
|
|
tooling: 'tooling',
|
2021-06-21 08:07:45 -04:00
|
|
|
ci_template: 'ci::templates',
|
|
|
|
feature_flag: 'feature flag'
|
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
|