debian-mirror-gitlab/danger/specialization_labels/Dangerfile

30 lines
791 B
Ruby
Raw Normal View History

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',
2021-12-11 22:18:48 +05:30
ux: 'UX',
2020-11-24 15:15:51 +05:30
docs: 'documentation',
qa: 'QA',
2021-12-11 22:18:48 +05:30
tooling: 'type::tooling',
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
2022-01-26 12:08:38 +05:30
labels_to_add = helper.changes_by_category.each_with_object([]) do |(category, _changes), memo|
2020-11-24 15:15:51 +05:30
label = SPECIALIZATIONS[category]
2021-12-11 22:18:48 +05:30
next unless label
next if gitlab.mr_labels.include?(label)
2020-11-24 15:15:51 +05:30
2021-12-11 22:18:48 +05:30
# Don't override already-set scoped labels.
label_scope = label.split('::')[0...-1].join('::')
next if !label_scope.empty? && gitlab.mr_labels.any? { |mr_label| mr_label.start_with?(label_scope) }
2020-11-24 15:15:51 +05:30
2021-12-11 22:18:48 +05:30
memo << label
2020-11-24 15:15:51 +05:30
end
2021-12-11 22:18:48 +05:30
project_helper.labels_to_add.concat(labels_to_add) if labels_to_add.any?