3 ms·
It doesn’t seem like this solves the main issues with pre-commit hooks. They are broken by design. Just to name 2, they run during rebase and aren’t compatible
by teaearlgraycold 9mo ago
It doesn’t seem like this solves the main issues with pre-commit hooks. They are broken by design. Just to name 2, they run during rebase and aren’t compatible with commits that leave unstaged files in your tree.
- bradleyy 9mo agoI leave unstaged files all the time, not sure what you mean.
- teaearlgraycold 9mo agoWithout extra shenanigans if you have an unstaged file that fails your test suite then pre-commit will reject your commit even if the staged files are error free.
- bradleyy 9mo agoOur stuff is configured to only run on staged files.
- tomjakubowski 9mo ago> they … aren’t compatible with commits that leave unstaged files in your tree. It's a little surprising that git doesn't pass pre-commit hooks any information, like a list of which files were changed in the soon-to-be-made commit. git does so for pre-push, where it writes to a hook's stdin some information about the refs and remotes involved in the push. I wonder if many pre-commit hooks, like the kind which run formatters, would be better off as `clean` filters, which run on files when they are staged. The filter mechanism makes it easier to apply just to the files which were changed. In the git docs, they even use a formatter (`indent`) as an example. https://git-scm.com/book/ms/v2/Customizing-Git-Git-Attributes#filters_b https://git-scm.com/book/ms/v2/Customizing-Git-Git-Attribute...