fix(hooks): commit guards match `git commit-tree` as `git commit` (unanchored substring)

Đang mở Phù hợp với người mới
#1,665 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
83/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
git, github, typescript
Lĩnh vực
devtools, tooling

Hướng nghiên cứu

Bắt đầu trong hooks/pre-tool.sh, nơi issue xác định rằng các chỗ gọi seg_match và raw_commit_segment khớp với git commit quá rộng. Đọc các bước kiểm tra đó và những bài kiểm thử hook liên quan, sau đó tái hiện bằng lệnh git commit-tree được cung cấp. Thêm một trường hợp hồi quy cho thấy các lệnh plumbing được đi qua, trong khi các bước bảo vệ cho lệnh porcelain git commit vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Bug Description

The commit guards in hooks/pre-tool.sh match git commit as an unanchored substring, so they also fire on the plumbing command git commit-tree, which doesn't commit staged files at all.

  • The no-changes guard (seg_match 'git commit', about line 1222 in 2.20.0) runs git status --porcelain, sees a clean tree (which is normal for commit-tree, since it builds a commit from an existing tree object), and blocks with HOOK_BLOCKED: No changes to commit. Stage files with 'git add' first.
  • raw_commit_segment selects segments that contain the literal substring "git commit", so a git commit-tree … -m "<msg>" would also have its message checked by the conventional-commit validator.

Seen on 2026-11-08 in a downstream graph repo. Under Claude Code auto mode, force-push is denied. To update a PR branch with a verified rebase, the runner tried to publish the rebased tree as a merge commit: git commit-tree HEAD^{tree} -p <pr-head> -p <main> -m …, then a normal push. The hook blocked it, so the runner fell back to git merge --no-commit plus git checkout <sha> -- ., which took two extra calls.

Steps to Reproduce
  1. In a clean checkout with the hook installed, run: git commit-tree HEAD^{tree} -p HEAD -m "chore: test"
  2. The hook blocks with HOOK_BLOCKED: No changes to commit.
Expected Behavior

The commit guards match git commit only as a whole word, for example git commit([[:space:]]|$), so commit-tree and commit-graph pass through. Other git commit-* plumbing is never a porcelain commit of staged changes.

Related

#1663: the same guard checks the tree before a compound command runs. That issue is about when the guard checks; this one is about what it matches.

Complexity

Small. It's a regex anchor in seg_match callers and raw_commit_segment, plus a test case.

Area

hooks

Environment

sequant 2.20.0, Claude Code VS Code extension, macOS, zsh.

Ngôn ngữ chính
TypeScript
Star
1
Fork
1
Merge trung bình
10 giờ 12 phút
Pull request đã merge (30 ngày)
78

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sequant-io/sequant

Tất cả issue của sequant-io/sequant

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.