Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-06-18 13:53:23 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-06-18 13:53:23 +0300
commit5f824afe6c6005a82365f18cb745fb5985f42fa2 (patch)
treeeb73350b3fbaf1deabc308d07f06677d1a852245
parent333775253533ae4e9e9e66dc12b636821646551f (diff)
MR labels to be inherited from issues it closes
If the issue this MR will close through either the commit messages or the description have relevant labels, apply them on the MR too. Closes https://gitlab.com/gitlab-org/gitaly/issues/1555
-rw-r--r--danger/labels/Dangerfile16
1 files changed, 14 insertions, 2 deletions
diff --git a/danger/labels/Dangerfile b/danger/labels/Dangerfile
index cd27a323b..6770b718c 100644
--- a/danger/labels/Dangerfile
+++ b/danger/labels/Dangerfile
@@ -5,7 +5,7 @@ def changelog_entry
YAML.safe_load(File.read(file))
rescue
- # The changelog danger file will handle this
+ # The change log danger file will handle this
{}
end
end
@@ -30,12 +30,24 @@ TYPE_TO_LABEL = {
nil => []
}
+INHERIRABLE_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| INHERIRABLE_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: (gitlab.mr_labels | required_labels).join(",")
+ labels: mr_labels.join(",")
)
# vim: ft=ruby