From 7f06aadbbc2dd2f17d9356952ad29df25b13b06b Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 2 Dec 2024 07:52:53 +0800 Subject: [PATCH 1/3] Recognise `Merge:auto-merge` label & friends With the change from Bugzilla to GitHub we will now have a lot more labels, and they are naturally categorised into groups like `OS:Windows`. The ones that the bot deals with need to be handled properly here. Sill to do `Blocked`. --- source/dlangbot/github.d | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/dlangbot/github.d b/source/dlangbot/github.d index c19549c..615cfc9 100644 --- a/source/dlangbot/github.d +++ b/source/dlangbot/github.d @@ -181,11 +181,11 @@ GHMerge.MergeMethod autoMergeMethod(GHLabel[] labels) with (GHMerge.MergeMethod) { auto labelNames = labels.map!(l => l.name); - if (labelNames.canFind!(l => l == "auto-merge")) + if (labelNames.canFind!(l => (l == "auto-merge" || l == "Merge:auto-merge"))) return merge; - else if (labelNames.canFind!(l => l == "auto-merge-squash")) + else if (labelNames.canFind!(l => (l == "auto-merge-squash" || || l == "Merge:auto-merge-squash"))) return squash; - else if (labelNames.canFind!(l => l == "auto-merge-rebase")) + else if (labelNames.canFind!(l => (l == "auto-merge-rebase" || || l == "Merge:auto-merge-rebase"))) return rebase; return none; } @@ -217,13 +217,17 @@ Json[] tryMerge(in ref PullRequest pr, GHMerge.MergeMethod method) return commits; } - auto labelName = method.labelName; + const labelName = method.labelName; + const mergeLabelName = "Merge:" ~ labelName; if (commits.length == 1) method = GHMerge.MergeMethod.rebase; auto events = ghGetRequest(pr.eventsURL).body[] .retro - .filter!(e => e["event"] == "labeled" && e["label"]["name"] == labelName); + .filter!(e => e["event"] == "labeled" && ( + e["label"]["name"] == labelName) + || e["label"]["name"] == mergeLabelName + ); string author = "unknown"; if (!events.empty) From a25b280d0c119bc7b370a781397f874347f13eb5 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 2 Dec 2024 07:59:57 +0800 Subject: [PATCH 2/3] Update github.d --- source/dlangbot/github.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dlangbot/github.d b/source/dlangbot/github.d index 615cfc9..e2cbd57 100644 --- a/source/dlangbot/github.d +++ b/source/dlangbot/github.d @@ -183,9 +183,9 @@ GHMerge.MergeMethod autoMergeMethod(GHLabel[] labels) auto labelNames = labels.map!(l => l.name); if (labelNames.canFind!(l => (l == "auto-merge" || l == "Merge:auto-merge"))) return merge; - else if (labelNames.canFind!(l => (l == "auto-merge-squash" || || l == "Merge:auto-merge-squash"))) + else if (labelNames.canFind!(l => (l == "auto-merge-squash" || l == "Merge:auto-merge-squash"))) return squash; - else if (labelNames.canFind!(l => (l == "auto-merge-rebase" || || l == "Merge:auto-merge-rebase"))) + else if (labelNames.canFind!(l => (l == "auto-merge-rebase" || l == "Merge:auto-merge-rebase"))) return rebase; return none; } From fcfeec1ac2d59db023d008eebfe10807352a0ca4 Mon Sep 17 00:00:00 2001 From: Nicholas Wilson Date: Mon, 2 Dec 2024 11:32:26 +0800 Subject: [PATCH 3/3] Update github.d --- source/dlangbot/github.d | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/dlangbot/github.d b/source/dlangbot/github.d index e2cbd57..c38452c 100644 --- a/source/dlangbot/github.d +++ b/source/dlangbot/github.d @@ -224,10 +224,7 @@ Json[] tryMerge(in ref PullRequest pr, GHMerge.MergeMethod method) auto events = ghGetRequest(pr.eventsURL).body[] .retro - .filter!(e => e["event"] == "labeled" && ( - e["label"]["name"] == labelName) - || e["label"]["name"] == mergeLabelName - ); + .filter!(e => e["event"] == "labeled" && e["label"]["name"].among(labelName, mergeLabelName)); string author = "unknown"; if (!events.empty)