Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognise Merge:auto-merge label & friends #304

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions source/dlangbot/github.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -217,13 +217,14 @@ 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"].among(labelName, mergeLabelName));

string author = "unknown";
if (!events.empty)
Expand Down