chore(scripts): safe-worktree.sh — 防 stale baseline 白工守門#450
Conversation
- 一律以 origin/<base> 最新 tip 建立 worktree,過期本地分支無法成為起點 - fetch --all --prune + 本地/遠端 SHA 一致性檢查,落後時警告 - 根治多次從過期分支開 worktree 導致 PR 白工的事故(Codex/Cursor review Q2) 測試:bash -n 語法檢查通過;功能測試從 origin/main tip 建立並驗證 SHA 一致
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cec3af0541
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| REMOTE_REF="origin/${BASE}" | ||
|
|
||
| echo "🔄 git fetch --all --prune ..." | ||
| git fetch --all --prune |
There was a problem hiding this comment.
Fetch only the target origin branch
When a developer has any extra remote that is unavailable or requires credentials, git fetch --all --prune fails before the script reaches the origin/<base> validation because set -e is enabled. I checked git fetch -h, which defines --all as “fetch from all remotes”; this script only needs origin/${BASE}, so one bad side remote blocks safe worktree creation even though the intended base is fetchable.
Useful? React with 👍 / 👎.
背景
Codex + Cursor 三方 review(Q2)一致最高信心建議:把「branch 起點機械化驗證」固化成守門,根治多次 stale-baseline 白工(例:被 #445 取代的 cluster PR、被吞併的 #444)。
內容
scripts/safe-worktree.sh <new-branch> <worktree-path> [base-branch]:git fetch --all --prune後,一律以origin/<base>最新 tip 為基準建立 worktree → 過期本地同名分支在物理上無法成為起點。驗證
bash -n語法檢查通過;功能測試從origin/maintip 建立並驗證 HEAD SHA 一致、清理成功。🤖 Generated with Claude Code