gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

`but commit` no longer runs pre-commit, commit-msg or post-commit hooks since 0.22.0

Open mattspruiell opened this issue 1 month ago • 2 comments

but commit in 0.22.x creates commits without running any Git commit hooks, and the flag that controlled them is gone. In 0.21.x the same command ran pre-commit, commit-msg and post-commit, and -n/--no-hooks (alias --no-verify) turned them off. The 0.22.0 to 0.22.3 release notes do not mention the change, so a repository that relies on a pre-commit check now commits through but with no check and no warning.

Steps to reproduce (0.22.3, macOS)

  1. In a GitButler-managed repository, add an executable .git/hooks/pre-commit, commit-msg and post-commit, each of which appends a line to a log file and exits 0.
  2. Make a change and run but commit -m "test" <change-id>.
  3. The commit is created and the log stays empty.
  4. Control: git hook run commit-msg -- <msg-file> in the same repository does append to the log, so the hooks themselves are reachable.

Expected: but commit runs the commit hooks, as 0.21.x did and as the desktop app does when "Run Git hooks" is enabled, with a flag to skip them.

Actual: no hook runs, and but commit --help lists no hook option.

Source references

  • crates/but/src/command/legacy/commit.rs at release/0.21.2 calls pre_commit_hook_diffspecs, message_hook and post_commit_hook behind if !no_hooks. At release/0.22.0 and release/0.22.3 the file has no hook references.
  • crates/but/src/args/commit.rs at release/0.21.2 defines #[clap(short = 'n', long = "no-hooks", alias = "no-verify")]. At release/0.22.3 the flag is absent.
  • The change landed with #14970.
  • but push still runs pre-push hooks and still has --no-hooks, so the two commands now behave differently.

If dropping commit hooks from the CLI was intentional, a line in the release notes and in but commit --help would help anyone relying on them.

mattspruiell avatar Oct 16 '26 20:10 mattspruiell

Would love to take on this one @estib-vega

Shiva953 avatar Oct 26 '26 07:10 Shiva953

Still seeing this on 0.23.1 (macOS). A plain git commit runs pre-commit, commit-msg and post-commit, while but commit runs none of them.

What bugs me most is that it isn't mentioned anywhere, not in the release notes and not in but commit --help. My hooks just quietly stopped running and I only found out by accident. That's a risky thing to change silently.

As it stands I can't use but on some of the projects I work on, where the hooks are a hard requirement.

I don't mind which way it goes. Running hooks by default with a flag to skip them, like but push, or making them opt-in are both fine by me, as long as it's documented.

crisptrutski avatar Nov 01 '26 09:11 crisptrutski