fix(maintainers): prevent false PR closeout failures (#121101)

This commit is contained in:
Peter Steinberger
2026-08-09 08:58:54 -07:00
committed by GitHub
parent 92bacda206
commit 3b37d15ed4
2 changed files with 14 additions and 23 deletions
+2 -22
View File
@@ -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
+12 -1
View File
@@ -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(