Skip to content

Commit c12ce89

Browse files
aduh95BethGriggs
authored andcommitted
tools: abort CQ session when landing several commits
Most PRs are meant to be squashed in one commit when landing. If the collaborator hasn't been using `fixup!` commits, the CQ lands the PR as several commits. This change makes the CQ abort by default when attempting to land several commits, unless there's another label added to the PR to force squashing or landing as several commits. Fixes: #40436 Refs: nodejs/node-core-utils#572 PR-URL: #40577 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent dd08e53 commit c12ce89

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

doc/guides/commit-queue.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ From a high-level, the Commit Queue works as follow:
2525
2. Check if the last Jenkins CI is finished running (if it is not, skip this
2626
PR)
2727
3. Remove the `commit-queue` label
28-
4. Run `git node land <pr>`
28+
4. Run `git node land <pr> --oneCommitMax`
2929
5. If it fails:
3030
1. Abort `git node land` session
3131
2. Add `commit-queue-failed` label to the PR
@@ -37,6 +37,12 @@ From a high-level, the Commit Queue works as follow:
3737
3. Close the PR
3838
4. Go to next PR in the queue
3939

40+
To make the Commit Queue squash all the commits of a pull request into the
41+
first one, add the `commit-queue-squash` label.
42+
To make the Commit Queue land a pull request containing several commits, add the
43+
`commit-queue-rebase` label. When using this option, make sure
44+
that all commits are self-contained, meaning every commit should pass all tests.
45+
4046
## Current limitations
4147

4248
The Commit Queue feature is still in early stages, and as such it might not

tools/actions/commit-queue.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ for pr in "$@"; do
7070
# Delete the commit queue label
7171
gitHubCurl "$(labelsUrl "$pr")"/"$COMMIT_QUEUE_LABEL" DELETE
7272

73-
git node land --autorebase --yes "$pr" >output 2>&1 || echo "Failed to land #${pr}"
73+
if gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-squash")'; then
74+
MULTIPLE_COMMIT_POLICY="--fixupAll"
75+
elif gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-rebase")'; then
76+
MULTIPLE_COMMIT_POLICY=""
77+
else
78+
MULTIPLE_COMMIT_POLICY="--oneCommitMax"
79+
fi
80+
81+
git node land --autorebase --yes $MULTIPLE_COMMIT_POLICY "$pr" >output 2>&1 || echo "Failed to land #${pr}"
7482
# cat here otherwise we'll be supressing the output of git node land
7583
cat output
7684

0 commit comments

Comments
 (0)