@@ -31,6 +31,8 @@ commit_queue_failed() {
3131git config --local user.email " github-bot@iojs.org"
3232git config --local user.name " Node.js GitHub Bot"
3333
34+ SHOULD_ABORT=
35+
3436for 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