summaryrefslogtreecommitdiff
path: root/danger/specialization_labels/Dangerfile
blob: e86d66f5fbc9d849ab5fb0633d2c9784ad223ee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

return unless helper.ci?

SPECIALIZATIONS = {
  database: 'database',
  backend: 'backend',
  frontend: 'frontend',
  docs: 'documentation',
  qa: 'QA',
  tooling: 'tooling',
  ci_template: 'ci::templates',
  feature_flag: 'feature flag'
}.freeze

labels_to_add = project_helper.changes_by_category.each_with_object([]) do |(category, _changes), memo|
  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