Skip to content

Commit d7ed670

Browse files
authored
tools: lazy-abort failed PR merges in CQ
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #65004 Refs: #64972 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 985aa07 commit d7ed670

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

tools/actions/commit-queue.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ commit_queue_failed() {
3131
git config --local user.email "github-bot@iojs.org"
3232
git config --local user.name "Node.js GitHub Bot"
3333

34+
SHOULD_ABORT=
35+
3436
for pr in "$@"; do
3537
gh pr view "$pr" --json labels --jq ".labels" > labels.json
3638
# Skip PR if CI was requested
@@ -56,6 +58,14 @@ for pr in "$@"; do
5658
MULTIPLE_COMMIT_POLICY="--oneCommitMax"
5759
fi
5860

61+
if [ -n "$SHOULD_ABORT" ]; then
62+
# If `git node land --abort` fails, we're in unknown state. Better to stop
63+
# the script here, current PR was removed from the queue so it shouldn't
64+
# interfere again in the future.
65+
git node land --abort --yes
66+
SHOULD_ABORT=
67+
fi
68+
5969
git node land --autorebase --yes $MULTIPLE_COMMIT_POLICY "$pr" >output 2>&1 || echo "Failed to land #${pr}"
6070
# cat here otherwise we'll be suppressing the output of git node land
6171
cat output
@@ -64,10 +74,8 @@ for pr in "$@"; do
6474
# if the "Landed in..." message was not on the output we assume land failed
6575
if ! grep -q '. Post "Landed in .*/pull/'"${pr}" output; then
6676
commit_queue_failed "$pr"
67-
# If `git node land --abort` fails, we're in unknown state. Better to stop
68-
# the script here, current PR was removed from the queue so it shouldn't
69-
# interfere again in the future.
70-
git node land --abort --yes
77+
# Using a variable as there's no point in aborting if there are no PRs left in the queue.
78+
SHOULD_ABORT=1
7179
continue
7280
fi
7381

0 commit comments

Comments
 (0)