worktree 閘:heredoc 的 body 是資料不是指令,並把 inkstone/ISEP#125 的驗收表 A–F 寫成測試

#125 缺陷 D/E(09-02 兩次實地命中):用 heredoc 寫一份內含 `cd <目錄> && git checkout X` 示範的
說明文件,整條指令沒有 git 操作卻被擋。沿用 lib/strip_heredoc.py(D20 閘同一支)先剝 body 再解析。
A–F 六條照票上期望值進 hooks/tests/(A–E 0、F 2)。
(76) 把 tokenize 層「換行被當空白吞掉」寫成已知邊界測試(舊閘同樣 exit=0,漏擋不是誤攔,與 (53) 同層,另報)。
A24:69→77。

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0178ef1fGw3XeZtpN7LaZrm4
This commit is contained in:
isep-hand
2026-09-07 06:35:28 +00:00
parent 49a7145e70
commit 95c6fee199
4 changed files with 59 additions and 4 deletions
+7
View File
@@ -79,6 +79,13 @@ sys.stdout.write((ti.get("command") or "") if isinstance(ti, dict) else "")
' 2>/dev/null) || exit 0
[ -n "${CMD:-}" ] || exit 0
# heredoc 的 body 是資料不是指令(inkstone/ISEP#125 缺陷 DE2026-09-02 兩次實地命中):
# 用 heredoc 寫一份「內含 `cd <目錄> && git checkout X` 示範」的說明文件,整條指令沒有任何
# git 操作,卻被當成在切分支擋下——被擋的是「寫文件」這個動作。跟 github-contact-guard 一樣
# 先把 body 剝掉再解析;剝不動就用原字串(fail-open 的是「這支 helper 有沒有跑」,不是判準)。
CMD=$(printf '%s' "$CMD" | python3 "$(dirname "$0")/lib/strip_heredoc.py" 2>/dev/null || printf '%s' "$CMD")
[ -n "${CMD:-}" ] || exit 0
CWD=$(printf '%s' "$PAYLOAD" | python3 -c '
import json, sys
try: