refactor(pr): remove unreachable fork push retry (#120565)

* refactor(pr): remove unreachable fork push retry

* refactor(pr): simplify missing fork branch handling
This commit is contained in:
Peter Steinberger
2026-08-08 08:48:44 -07:00
committed by GitHub
parent 7ecdef6e2e
commit 2bce06e1e7
2 changed files with 6 additions and 49 deletions
+2 -31
View File
@@ -175,26 +175,6 @@ GRAPHQL
printf '%s\n' "$new_oid"
}
resolve_head_push_url_https() {
# shellcheck disable=SC1091
source .local/pr-meta.env
if [ -n "${PR_HEAD_OWNER:-}" ] && [ -n "${PR_HEAD_REPO_NAME:-}" ]; then
printf 'https://github.com/%s/%s.git\n' "$PR_HEAD_OWNER" "$PR_HEAD_REPO_NAME"
return 0
fi
if [ -n "${PR_HEAD_REPO_URL:-}" ] && [ "$PR_HEAD_REPO_URL" != "null" ]; then
case "$PR_HEAD_REPO_URL" in
*.git) printf '%s\n' "$PR_HEAD_REPO_URL" ;;
*) printf '%s.git\n' "$PR_HEAD_REPO_URL" ;;
esac
return 0
fi
return 1
}
verify_pr_head_branch_matches_expected() {
local pr="$1"
local expected_head="$2"
@@ -228,17 +208,8 @@ resolve_prhead_remote_sha() {
local remote_sha
remote_sha=$(git ls-remote "$PRHEAD_REMOTE_URL" "refs/heads/$pr_head" 2>/dev/null | awk '{print $1}' || true)
if [ -z "$remote_sha" ]; then
local https_url
https_url=$(resolve_head_push_url_https 2>/dev/null) || true
if [ -n "$https_url" ] && [ "$https_url" != "$PRHEAD_REMOTE_URL" ]; then
echo "SSH remote failed; falling back to HTTPS..." >&2
PRHEAD_REMOTE_URL="$https_url"
remote_sha=$(git ls-remote "$PRHEAD_REMOTE_URL" "refs/heads/$pr_head" 2>/dev/null | awk '{print $1}' || true)
fi
if [ -z "$remote_sha" ]; then
echo "Remote branch refs/heads/$pr_head not found on prhead" >&2
exit 1
fi
echo "Remote branch refs/heads/$pr_head not found on prhead" >&2
exit 1
fi
PRHEAD_REMOTE_SHA="$remote_sha"
+4 -18
View File
@@ -792,7 +792,7 @@ describe("GraphQL fork publication", () => {
});
describe("fork publication transport", () => {
it("keeps the PR push URL process-local", () => {
it("keeps the PR push URL process-local and reports a missing branch", () => {
const { repoDir } = makeRetryRepo();
const result = runGatesBash(
[
@@ -801,23 +801,9 @@ describe("fork publication transport", () => {
"setup_prhead_remote",
'test "$PRHEAD_REMOTE_URL" = https://github.com/contributor/repo.git',
"test ! -e .local/git-called",
].join("\n"),
{ cwd: repoDir, sourcePush: true },
);
expect(result.status, result.stderr).toBe(0);
});
it("preserves an HTTPS fallback for the later push", () => {
const { repoDir } = makeRetryRepo();
const result = runGatesBash(
[
"PRHEAD_REMOTE_URL=ssh://git@example.test/contributor/repo.git",
"resolve_head_push_url_https() { printf '%s\\n' https://github.com/contributor/repo.git; }",
'git() { if [ "$1" = ls-remote ] && [ "$2" = https://github.com/contributor/repo.git ]; then printf \'hosted\\trefs/heads/topic\\n\'; fi; }',
"resolve_prhead_remote_sha topic",
'test "$PRHEAD_REMOTE_URL" = https://github.com/contributor/repo.git',
'test "$PRHEAD_REMOTE_SHA" = hosted',
"if remote_error=$(resolve_prhead_remote_sha topic 2>&1); then exit 97; fi",
'test "$remote_error" = "Remote branch refs/heads/topic not found on prhead"',
"test -e .local/git-called",
].join("\n"),
{ cwd: repoDir, sourcePush: true },
);