File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,14 +67,14 @@ wait_for_required_checks() {
6767 while (( elapsed <= REQUIRED_CHECKS_APPEAR_TIMEOUT_SECONDS)) ; do
6868 if is_stale_event; then
6969 echo " PR head moved while waiting for required checks; skipping stale auto-merge attempt."
70- return 0
70+ return 2
7171 fi
7272
7373 required_count=" $( required_checks_count) "
7474 if [[ " $required_count " =~ ^[0-9]+$ ]] && (( required_count > 0 )) ; then
7575 if is_stale_event; then
7676 echo " PR head moved after required checks appeared; skipping stale auto-merge attempt."
77- return 0
77+ return 2
7878 fi
7979 echo " Waiting for $required_count required checks to pass before enabling auto-merge."
8080 if ! gh pr checks " $PR_URL " --required --watch --fail-fast --interval " $REQUIRED_CHECKS_WATCH_INTERVAL_SECONDS " ; then
@@ -136,7 +136,15 @@ if [[ "$allow_rebase_merge" == "true" || "$allow_merge_commit" == "true" ]]; the
136136 exit 1
137137fi
138138
139- if ! wait_for_required_checks; then
139+ if wait_for_required_checks; then
140+ wait_status=0
141+ else
142+ wait_status=$?
143+ fi
144+ if [[ " $wait_status " -eq 2 ]]; then
145+ exit 0
146+ fi
147+ if [[ " $wait_status " -ne 0 ]]; then
140148 exit 1
141149fi
142150
Original file line number Diff line number Diff line change @@ -282,6 +282,7 @@ def test_skips_when_head_becomes_stale_while_waiting(tmp_path: Path) -> None:
282282 )
283283 assert result .returncode == 0
284284 assert "PR head moved while waiting for required checks" in result .stdout
285+ assert "after required checks completed" not in result .stdout
285286
286287 log_lines = (tmp_path / "gh.log" ).read_text (encoding = "utf-8" ).splitlines ()
287288 assert len (log_lines ) == 1
@@ -303,6 +304,7 @@ def test_skips_when_head_becomes_stale_after_checks_appear(tmp_path: Path) -> No
303304 )
304305 assert result .returncode == 0
305306 assert "PR head moved after required checks appeared" in result .stdout
307+ assert "after required checks completed" not in result .stdout
306308
307309 log_lines = (tmp_path / "gh.log" ).read_text (encoding = "utf-8" ).splitlines ()
308310 assert len (log_lines ) == 1
You can’t perform that action at this time.
0 commit comments