diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-03-19 16:57:38 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-03-20 17:32:28 +0300 |
commit | 4dedfa1bc5375a9c5d8f49581c61b0b0e467804b (patch) | |
tree | fd63584553adb7be79a936b6a1b1bbb012d6bcaf /danger | |
parent | abccf3c2de9c66edefcf4e32757702142c0b2bc5 (diff) |
Have GitalyBot apply the milestone if it can
GitalyBot gets the issues the merge request closes and will detect the
first upcoming milestone and apply it.
This can be overridden by the user, and GitalyBot will not try again.
Another issue might be that if a MR slips, the milestone isn't updated.
Diffstat (limited to 'danger')
-rw-r--r-- | danger/milestones/Dangerfile | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/danger/milestones/Dangerfile b/danger/milestones/Dangerfile new file mode 100644 index 000000000..e967b27cf --- /dev/null +++ b/danger/milestones/Dangerfile @@ -0,0 +1,23 @@ +unless gitlab.mr_json["milestone"] + issues = gitlab.api.merge_request_closes_issues(gitlab.mr_json['project_id'], gitlab.mr_json['iid']) + + milestone_id = issues + .map { |i| i.milestone } + .compact + .reject { |m| m.state == "closed" } + .sort_by { |m| m.due_date } + .first + &.id + + if milestone_id + gitlab.api.update_merge_request( + gitlab.mr_json['project_id'], + gitlab.mr_json['iid'], + milestone_id: milestone_id + ) + else + warn "No milestone was set, nor could it be detected from the issues this merge request closes." + end +end + +# vim: ft=ruby |