blob: b10259cd05f910af1cecf2cd4cfec8742d4f343a (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
def changelog_entry
@changelog_entry ||=
begin
file = git.added_files.find { |path| path =~ %r{\Achangelogs/unreleased/} }
YAML.safe_load(File.read(file))
rescue
# The change log danger file will handle this
{}
end
end
required_labels = %w[devops::create]
required_labels << "group::gitaly" if GITALY_TEAM.include?(gitlab.mr_author)
TYPE_TO_LABEL = {
'added' => %w[feature feature::addition],
'fixed' => ['bug'],
'changed' => %w[feature feature::maintenance],
'deprecated' => %w[feature feature::maintenance],
'security' => ['security'],
'removed' => %w[feature feature::maintenance],
'performance' => %w[feature feature::maintenance performance],
'other' => ['tooling'],
nil => []
}
INHERITABLE_LABELS = TYPE_TO_LABEL.values.flatten + %w[Deliverable]
def inherited_labels
gitlab.api
.merge_request_closes_issues( gitlab.mr_json['project_id'], gitlab.mr_json['iid'])
.flat_map { |i| i.labels }
.compact
.uniq
.select { |label| INHERITABLE_LABELS.include?(label) }
end
required_labels.concat(TYPE_TO_LABEL[changelog_entry["type"]])
mr_labels = gitlab.mr_labels | required_labels | inherited_labels
gitlab.api.update_merge_request(
gitlab.mr_json['project_id'],
gitlab.mr_json['iid'],
labels: mr_labels.join(",")
)
# vim: ft=ruby
|