mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
refactor: avoid checkout during prep head verification
This commit is contained in:
22
scripts/pr
22
scripts/pr
@@ -220,29 +220,39 @@ checkout_prep_branch() {
|
|||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
source .local/prep-context.env
|
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}"
|
local prep_branch="${PREP_BRANCH:-pr-$pr-prep}"
|
||||||
if ! git show-ref --verify --quiet "refs/heads/$prep_branch"; then
|
if ! git show-ref --verify --quiet "refs/heads/$prep_branch"; then
|
||||||
echo "Expected prep branch $prep_branch not found. Run prepare-init first."
|
echo "Expected prep branch $prep_branch not found. Run prepare-init first."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout "$prep_branch"
|
printf '%s\n' "$prep_branch"
|
||||||
}
|
}
|
||||||
|
|
||||||
verify_prep_branch_matches_prepared_head() {
|
verify_prep_branch_matches_prepared_head() {
|
||||||
local pr="$1"
|
local pr="$1"
|
||||||
local prepared_head_sha="$2"
|
local prepared_head_sha="$2"
|
||||||
|
|
||||||
require_artifact .local/prep-context.env
|
local prep_branch
|
||||||
checkout_prep_branch "$pr"
|
prep_branch=$(resolve_prep_branch_name "$pr")
|
||||||
|
|
||||||
local prep_branch_head_sha
|
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
|
if [ "$prep_branch_head_sha" = "$prepared_head_sha" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
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
|
if git merge-base --is-ancestor "$prepared_head_sha" "$prep_branch_head_sha" 2>/dev/null; then
|
||||||
echo "Unpushed local commits on prep branch:"
|
echo "Unpushed local commits on prep branch:"
|
||||||
git log --oneline "${prepared_head_sha}..${prep_branch_head_sha}" | sed 's/^/ /' || true
|
git log --oneline "${prepared_head_sha}..${prep_branch_head_sha}" | sed 's/^/ /' || true
|
||||||
|
|||||||
Reference in New Issue
Block a user