#16364

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

Openmattspruiellopened 14d ago

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.

Activity

1
Shiva9534d ago

Would love to take on this one @estib-vega