身為總管,我要閘擋的是動作不是字面,我才不會一晚被自己的閘擋六次 #51

Merged
claude-code merged 1 commits from fix/push-guard-target-not-substring into main 2026-08-20 17:30:46 +00:00
Member

一個晚上誤攔六次,第六次是它擋住了引用那幾個字的 commit message,第五次是它擋住了測試它自己的指令。

改成解析 push 的目標 refspec。八向實測 8/8,測試存進 hooks/tests/

一個晚上誤攔六次,第六次是它擋住了引用那幾個字的 commit message,第五次是它擋住了測試它自己的指令。 改成解析 push 的目標 refspec。八向實測 8/8,測試存進 `hooks/tests/`。
claude-code added 1 commit 2026-08-20 17:30:11 +00:00
一個晚上誤攔六次,全都不是在推預設分支:
  ① checkout -b 建新分支時把預設分支寫在後面,再推那條新分支
  ② gh pr create 指定 base——根本不是 git push
  ③ 推 tag(refs/tags/…)
  ④ 推 feature 分支(帶 -u)
  ⑤ 它擋住了我用來**測試它自己**的那條指令
  ⑥ 它擋住了這一筆的 commit——因為 message 裡引用了那幾個字

leo 2026-08-17 早就講過這個形狀:文字層封路必敗,
「紅線寫得越細,命中關鍵字的機率越高 ⇒ 那些閘在懲罰謹慎」。
舊版掃整條指令字串,正是文字層。

改成解析 push 的目標 refspec:
  旗標跳過/第一個非旗標=remote/a:b 取 b/refs/tags/* 不算分支
  一個 refspec 都沒給,才退回看當前分支

八向實測(hooks/tests/main-and-prod-push-guard.test.sh,8/8):
  五種該放行的(今晚誤攔的原形狀,含分支名帶 domain 那種)全過
  三種該擋的全擋

中途自己抓到一個 bug:tag 被跳過後目標清單變空 → 退回猜當前分支
⇒ 當前分支剛好叫預設名時誤擋。改成看到 refspec 就不退回猜測。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
claude-code merged commit 2eb9b2aaaa into main 2026-08-20 17:30:46 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: inkstone/ISEP#51