From 3b37d15ed4cf1522d262c2c855d14efe281b187f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 9 Aug 2026 08:58:54 -0700 Subject: [PATCH] fix(maintainers): prevent false PR closeout failures (#121101) --- scripts/pr-lib/merge.sh | 24 ++---------------------- test/scripts/pr-merge.test.ts | 13 ++++++++++++- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/scripts/pr-lib/merge.sh b/scripts/pr-lib/merge.sh index bb2cca308dd3..4f33c4852bc9 100644 --- a/scripts/pr-lib/merge.sh +++ b/scripts/pr-lib/merge.sh @@ -454,28 +454,8 @@ merge_run() { local repo_nwo repo_nwo=$(gh repo view --json nameWithOwner --jq .nameWithOwner) - local landed_sha_url="" - if gh api repos/:owner/:repo/commits/"$landed_sha" >/dev/null 2>&1; then - landed_sha_url="https://github.com/$repo_nwo/commit/$landed_sha" - else - echo "Landed commit is not resolvable via repository commit endpoint: $landed_sha" - exit 1 - fi - - local prep_sha_url="" - if gh api repos/:owner/:repo/commits/"$PREP_HEAD_SHA" >/dev/null 2>&1; then - prep_sha_url="https://github.com/$repo_nwo/commit/$PREP_HEAD_SHA" - else - local pr_commit_count - pr_commit_count=$(gh pr view "$pr" --json commits --jq "[.commits[].oid | select(. == \"$PREP_HEAD_SHA\")] | length") - if [ "${pr_commit_count:-0}" -gt 0 ]; then - prep_sha_url="https://github.com/$repo_nwo/pull/$pr/commits/$PREP_HEAD_SHA" - fi - fi - if [ -z "$prep_sha_url" ]; then - echo "Prepared head SHA is not resolvable in repo commits or PR commit list: $PREP_HEAD_SHA" - exit 1 - fi + local landed_sha_url="https://github.com/$repo_nwo/commit/$landed_sha" + local prep_sha_url="https://github.com/$repo_nwo/pull/$pr/commits/$PREP_HEAD_SHA" local ok=0 local comment_body diff --git a/test/scripts/pr-merge.test.ts b/test/scripts/pr-merge.test.ts index 1a5426473245..d94831e8897e 100644 --- a/test/scripts/pr-merge.test.ts +++ b/test/scripts/pr-merge.test.ts @@ -197,6 +197,15 @@ gh_route() { ;; "repo view") printf 'openclaw/openclaw\\n' ;; "api "*) + local api_arg + for api_arg in "$@"; do + case "$api_arg" in + repos/*/*/commits/*) + echo 'unexpected repository commit-resolution API probe' >&2 + return 1 + ;; + esac + done case "$*" in *"issues/123/comments"*) local arg @@ -334,12 +343,14 @@ describePosix("scripts/pr merge-run", () => { expect(result.calls).toContain("path pr view 123 --json state,isDraft"); expect(result.calls).not.toContain("--required --watch"); expect(result.calls).not.toContain("--auto"); + expect(result.calls).not.toMatch(/^(?:path|plain) api .*\/commits\//mu); + expect(result.calls).not.toContain("--json commits"); expect(result.stdout).toContain("merge-run complete for PR #123"); expect(result.stdout).toContain( "completion comment: https://github.com/openclaw/openclaw/pull/123#issuecomment-1", ); expect(result.commentBody).toBe( - `Merged via squash.\n\n- Prepared head SHA: [${headSha}](https://github.com/openclaw/openclaw/commit/${headSha})\n- Landed commit: [${landedSha}](https://github.com/openclaw/openclaw/commit/${landedSha})`, + `Merged via squash.\n\n- Prepared head SHA: [${headSha}](https://github.com/openclaw/openclaw/pull/123/commits/${headSha})\n- Landed commit: [${landedSha}](https://github.com/openclaw/openclaw/commit/${landedSha})`, ); expect(result.rgCalls).toBe(""); expect(result.lifecycle).toBe(