From 9a36ae245be8f1781bf5e12c3cb5d7acae9ac3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kova=C4=BE?= Date: Thu, 30 Jul 2026 12:05:29 +0200 Subject: [PATCH] Nudge pending finish agents to use --watch --- clerk/legacy/clerk.bash | 2 +- tests/clerk/finish-sync.bats | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/clerk/legacy/clerk.bash b/clerk/legacy/clerk.bash index 42d7302..fea9380 100755 --- a/clerk/legacy/clerk.bash +++ b/clerk/legacy/clerk.bash @@ -3102,7 +3102,7 @@ finish_reconcile_unit() { # $1=backend $2=root $3=id-or-empty $4=watch(0|1) $5=s fi pending=$(finish_check_pending "$pr_json") if [ -n "$pending" ]; then - printf "clerk: PR #%s for %s has pending checks — rerun 'clerk backlog finish' when green (or use --watch)\n" "$pr_number" "$full" + printf "clerk: PR #%s for %s has pending checks — run 'clerk backlog finish %s --watch' to wait\n" "$pr_number" "$full" "$full" while IFS= read -r line || [ -n "$line" ]; do [ -n "$line" ] || continue printf ' %s\n' "$line" diff --git a/tests/clerk/finish-sync.bats b/tests/clerk/finish-sync.bats index 6a0eb7b..6e139af 100644 --- a/tests/clerk/finish-sync.bats +++ b/tests/clerk/finish-sync.bats @@ -71,6 +71,7 @@ if [ "$1 $2" = "pr list" ]; then case "$mode" in none) json='[]' ;; review) json='[{"number":7,"url":"https://example/pr/7","state":"OPEN","mergedAt":"","reviewDecision":"REVIEW_REQUIRED","statusCheckRollup":[{"name":"delivery-gate","status":"COMPLETED","conclusion":"SUCCESS"}],"headRefName":"delivery/x","isDraft":false,"updatedAt":"2026-07-10T00:00:00Z"}]' ;; + pending) json='[{"number":6,"url":"https://example/pr/6","state":"OPEN","mergedAt":"","reviewDecision":"APPROVED","statusCheckRollup":[{"name":"delivery-gate","status":"IN_PROGRESS","conclusion":""}],"headRefName":"delivery/x","isDraft":false,"updatedAt":"2026-07-10T00:00:00Z"}]' ;; fail) json='[{"number":8,"url":"https://example/pr/8","state":"OPEN","mergedAt":"","reviewDecision":"APPROVED","statusCheckRollup":[{"name":"delivery-gate","status":"COMPLETED","conclusion":"FAILURE"},{"name":"unit-tests","status":"COMPLETED","conclusion":"SUCCESS"}],"headRefName":"delivery/x","isDraft":false,"updatedAt":"2026-07-10T00:00:00Z"}]' ;; merged) json='[{"number":9,"url":"https://example/pr/9","state":"MERGED","mergedAt":"2026-07-10T00:00:00Z","reviewDecision":"APPROVED","statusCheckRollup":[{"name":"delivery-gate","status":"COMPLETED","conclusion":"SUCCESS"}],"headRefName":"delivery/x","isDraft":false,"updatedAt":"2026-07-10T00:00:00Z"}]' ;; multi) json='[{"number":5,"url":"https://example/pr/5","state":"CLOSED","mergedAt":"","reviewDecision":"","statusCheckRollup":[],"headRefName":"delivery/x","isDraft":false,"updatedAt":"2026-07-09T00:00:00Z"},{"number":12,"url":"https://example/pr/12","state":"OPEN","mergedAt":"","reviewDecision":"REVIEW_REQUIRED","statusCheckRollup":[{"name":"delivery-gate","status":"COMPLETED","conclusion":"SUCCESS"}],"headRefName":"delivery/x","isDraft":false,"updatedAt":"2026-07-10T00:00:00Z"}]' ;; @@ -125,6 +126,19 @@ SH ! grep -q 'pr merge' "$BATS_TEST_TMPDIR/gh.calls" } +@test "finish: pending checks prescribe --watch and exit successfully" { + repo=$(make_finish_repo finish_pending) + cd "$repo" + id=$(mk_claimed_unit) + short="${id#*-}" + git checkout -q "delivery/$short" + install_gh_pr_stub pending + run "$CLERK" backlog finish + [ "$status" -eq 0 ] + [ "${lines[0]}" = "clerk: PR #6 for $id has pending checks — run 'clerk backlog finish $id --watch' to wait" ] + [ "${lines[1]}" = " delivery-gate" ] +} + @test "finish: failing checks output each named failure" { repo=$(make_finish_repo finish_fail) cd "$repo"