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
printf '%s\n'"$prep_branch"
}
verify_prep_branch_matches_prepared_head() {
local pr="$1"
local prepared_head_sha="$2"
local prep_branch
prep_branch=$(resolve_prep_branch_name "$pr")
local prep_branch_head_sha
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 (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 echo"Run scripts/pr prepare-sync-head $pr to push them before merge." else echo"Prep branch no longer contains the prepared head. Re-run prepare-init." fi
exit 1
}
prepare_init() {
local pr="$1"
enter_worktree "$pr" true
prepare_validate_commit() {
local pr="$1"
enter_worktree "$pr" false
require_artifact .local/pr-meta.env
checkout_prep_branch "$pr"
# shellcheck disable=SC1091
source .local/pr-meta.env
local pr_number="${PR_NUMBER:-$pr}"
local subject
subject=$(git log -1 --pretty=%s)
ifecho"$subject" | rg -qi "(^|[[:space:]])openclaw#$pr_number([[:space:]]|$)|\\(#$pr_number\\)"; then echo"ERROR: prep commit subject should not include PR number metadata"
exit 1 fi
ifecho"$subject" | rg -qi "thanks @"; then echo"ERROR: prep commit subject should not include contributor thanks"
exit 1 fi
echo"prep commit subject validated: $subject"
}
prepare_push() {
local pr="$1"
enter_worktree "$pr" false
local prep_head_sha
prep_head_sha=$(git rev-parse HEAD)
local lease_sha
lease_sha=$(gh pr view "$pr" --json headRefOid --jq .headRefOid)
local push_result_env=".local/prepare-push-result.env"
verify_pr_head_branch_matches_expected "$pr""$PR_HEAD"
push_prep_head_to_pr_branch "$pr""$PR_HEAD""$prep_head_sha""$lease_sha" true "${DOCS_ONLY:-false}""$push_result_env" # shellcheck disable=SC1090
source "$push_result_env"
prep_head_sha="$PUSH_PREP_HEAD_SHA"
local pushed_from_sha="$PUSHED_FROM_SHA"
local pr_head_sha_after="$PR_HEAD_SHA_AFTER_PUSH"
local contrib="${PR_AUTHOR:-}" if [ -z "$contrib" ]; then
contrib=$(gh pr view "$pr" --json author --jq .author.login) fi
local contrib_id
contrib_id=$(gh api "users/$contrib" --jq .id)
local coauthor_email="${contrib_id}+${contrib}@users.noreply.github.com"
cat >> .local/prep.md <<EOF_PREP
- Gates passed and push succeeded to branch $PR_HEAD.
- Gate mode: ${GATES_MODE:-unknown}.
- Verified PR head SHA matches local prep HEAD.
- Verified PR head contains origin/main.
EOF_PREP
local rebased=false
git fetch origin main if ! git merge-base --is-ancestor origin/main HEAD; then
git rebase origin/main
rebased=true
prepare_gates "$pr"
checkout_prep_branch "$pr" fi
local prep_head_sha
prep_head_sha=$(git rev-parse HEAD)
local lease_sha
lease_sha=$(gh pr view "$pr" --json headRefOid --jq .headRefOid)
local push_result_env=".local/prepare-sync-result.env"
verify_pr_head_branch_matches_expected "$pr""$PR_HEAD"
push_prep_head_to_pr_branch "$pr""$PR_HEAD""$prep_head_sha""$lease_sha" false false "$push_result_env" # shellcheck disable=SC1090
source "$push_result_env"
prep_head_sha="$PUSH_PREP_HEAD_SHA"
local pushed_from_sha="$PUSHED_FROM_SHA"
local pr_head_sha_after="$PR_HEAD_SHA_AFTER_PUSH"
local contrib="${PR_AUTHOR:-}" if [ -z "$contrib" ]; then
contrib=$(gh pr view "$pr" --json author --jq .author.login) fi
local contrib_id
contrib_id=$(gh api "users/$contrib" --jq .id)
local coauthor_email="${contrib_id}+${contrib}@users.noreply.github.com"
cat >> .local/prep.md <<EOF_PREP
- Prep head sync completed to branch $PR_HEAD.
- Rebased onto origin/main: $rebased.
- Verified PR head SHA matches local prep HEAD.
- Verified PR head contains origin/main.
- Prepare gates reran automatically when the sync rebase changed the prep head.
EOF_PREP
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.