



















@@ -202,6 +202,27 @@ resolve_prhead_remote_sha() {
202202printf '%s\n' "$remote_sha"
203203}
204204205+push_prep_head_once() {
206+local pr_head="$1"
207+local lease_sha="$2"
208+local prep_head_sha="$3"
209+210+if [ -n "${PR_HEAD_OWNER:-}" ] && [ -n "${PR_HEAD_REPO_NAME:-}" ] && [ "${OPENCLAW_PR_PUSH_MODE:-graphql}" != "git" ]; then
211+echo "Pushing PR branch through GitHub createCommitOnBranch so the prepared commit is verified." >&2
212+ graphql_push_to_fork "${PR_HEAD_OWNER}/${PR_HEAD_REPO_NAME}" "$pr_head" "$lease_sha"
213+return $?
214+fi
215+216+if [ "${OPENCLAW_ALLOW_UNSIGNED_GIT_PUSH:-}" != "1" ]; then
217+echo "Refusing git-protocol PR branch push because it can publish unsigned commits." >&2
218+echo "Use the default GitHub createCommitOnBranch path, or set OPENCLAW_ALLOW_UNSIGNED_GIT_PUSH=1 for an explicit manual override." >&2
219+return 2
220+fi
221+222+ git push --force-with-lease=refs/heads/$pr_head:$lease_sha prhead HEAD:$pr_head >&2
223+printf '%s\n' "$prep_head_sha"
224+}
225+205226push_prep_head_to_pr_branch() {
206227local pr="$1"
207228local pr_head="$2"
@@ -226,9 +247,7 @@ push_prep_head_to_pr_branch() {
226247fi
227248 pushed_from_sha="$lease_sha"
228249local push_output
229-if ! push_output=$(
230- git push --force-with-lease=refs/heads/$pr_head:$lease_sha prhead HEAD:$pr_head 2>&1
231- ); then
250+if ! push_output=$(push_prep_head_once "$pr_head" "$lease_sha" "$prep_head_sha" 2>&1); then
232251echo "Push failed: $push_output"
233252234253if printf '%s' "$push_output" | grep -qiE '(permission|denied|403|forbidden)'; then
@@ -253,9 +272,7 @@ push_prep_head_to_pr_branch() {
253272 run_prepare_push_retry_gates "$docs_only"
254273fi
255274256-if ! push_output=$(
257- git push --force-with-lease=refs/heads/$pr_head:$lease_sha prhead HEAD:$pr_head 2>&1
258- ); then
275+if ! push_output=$(push_prep_head_once "$pr_head" "$lease_sha" "$prep_head_sha" 2>&1); then
259276echo "Retry push failed: $push_output"
260277if [ -n "${PR_HEAD_OWNER:-}" ] && [ -n "${PR_HEAD_REPO_NAME:-}" ]; then
261278echo "Retry failed; trying GraphQL createCommitOnBranch fallback..."
@@ -266,8 +283,12 @@ push_prep_head_to_pr_branch() {
266283echo "Git push failed and no fork owner/repo info for GraphQL fallback."
267284exit 1
268285fi
286+else
287+ prep_head_sha=$(printf '%s\n' "$push_output" | tail -n 1)
269288fi
270289fi
290+else
291+ prep_head_sha=$(printf '%s\n' "$push_output" | tail -n 1)
271292fi
272293fi
273294此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。