From 032778fb2e3a0292997c908d7c24a805ce4d6778 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 8 Mar 2026 16:02:24 +0000 Subject: [PATCH] refactor: avoid checkout during prep head verification --- scripts/pr | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/pr b/scripts/pr index 8e20eb72093..4d919ccb241 100755 --- a/scripts/pr +++ b/scripts/pr @@ -220,29 +220,39 @@ checkout_prep_branch() { # shellcheck disable=SC1091 source .local/prep-context.env + local prep_branch + prep_branch=$(resolve_prep_branch_name "$pr") + git checkout "$prep_branch" +} + +resolve_prep_branch_name() { + local pr="$1" + require_artifact .local/prep-context.env + # shellcheck disable=SC1091 + source .local/prep-context.env + local prep_branch="${PREP_BRANCH:-pr-$pr-prep}" if ! git show-ref --verify --quiet "refs/heads/$prep_branch"; then echo "Expected prep branch $prep_branch not found. Run prepare-init first." exit 1 fi - git checkout "$prep_branch" + printf '%s\n' "$prep_branch" } verify_prep_branch_matches_prepared_head() { local pr="$1" local prepared_head_sha="$2" - require_artifact .local/prep-context.env - checkout_prep_branch "$pr" - + local prep_branch + prep_branch=$(resolve_prep_branch_name "$pr") local prep_branch_head_sha - prep_branch_head_sha=$(git rev-parse HEAD) + prep_branch_head_sha=$(git rev-parse "refs/heads/$prep_branch") if [ "$prep_branch_head_sha" = "$prepared_head_sha" ]; then return 0 fi - echo "Local prep branch moved after prepare-push (expected $prepared_head_sha, got $prep_branch_head_sha)." + echo "Local prep branch moved after prepare-push (branch=$prep_branch expected $prepared_head_sha, got $prep_branch_head_sha)." if git merge-base --is-ancestor "$prepared_head_sha" "$prep_branch_head_sha" 2>/dev/null; then echo "Unpushed local commits on prep branch:" git log --oneline "${prepared_head_sha}..${prep_branch_head_sha}" | sed 's/^/ /' || true