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:
authorJohn Cai <jcai@gitlab.com>2023-05-10 21:39:22 +0300
committerJohn Cai <jcai@gitlab.com>2023-05-10 21:39:22 +0300
commit094bdffed7afad3b0129d01d77feee6f3cb6cb8a (patch)
treef727fab963db3bfe215d8112a058081b6d9d274f
parente776aab22dec3a58aad5f267558ed2a9eac8432e (diff)
Dangerfile: Automatically add workflow::complete to issues closed by MRjc/add-workflow-label-to-closed-issue
-rw-r--r--danger/rules/labels/Dangerfile27
1 files changed, 18 insertions, 9 deletions
diff --git a/danger/rules/labels/Dangerfile b/danger/rules/labels/Dangerfile
index b52d831fa..22b503fc0 100644
--- a/danger/rules/labels/Dangerfile
+++ b/danger/rules/labels/Dangerfile
@@ -1,3 +1,6 @@
+project_id = gitlab.mr_json['project_id']
+mr_id = gitlab.mr_json['iid']
+
INHERITABLE_LABELS = %w[
type::bug
type::feature
@@ -11,17 +14,23 @@ INHERITABLE_LABELS = %w[
group::gitaly
]
-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
-
GITALY_TEAM = gitlab.api.all_group_members("gl-gitaly").flat_map{ |i| i.username }
+inherited_labels = []
+gitlab.api
+ .merge_request_closes_issues(project_id, mr_id)
+ .select do |issue|
+
+ if gitlab.mr_json['state'] == 'merged'
+ new_labels = issue.labels
+ new_labels << "workflow::complete"
+ gitlab.api.edit_issue(project_id, issue.iid, {labels: labels})
+ end
+
+ inherited_labels += issue.labels.select { |label| INHERITABLE_LABELS.include?(label) }
+ end
+inherited_labels.uniq!
+
required_labels = %w[devops::systems]
required_labels << "group::gitaly" if GITALY_TEAM.include?(gitlab.mr_author)