Re: [PATCH] [pre-commit] Fix codespell-log hook
Tom de Vries <[email protected]>
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
On 7/16/26 6:54 PM, Tom de Vries wrote: > A recent commit added this top-level setting to .pre-commit-config.yaml: > ... > files: '^(gdb|gdbserver|gdbsupport)/' > ... > > This broke the codespell-log hook, which is a commit-msg hook, which is called > with the commit message as first argument. > > However, the top-level files setting filters out .git/COMMIT_EDITMSG, with the > consequence that the commit-msg hook is no longer called. > > It seems obvious to me that this is a pre-commit bug: the files field is there > to filter files in the repository, which .git/COMMIT_EDITMSG is not one of. > But upstream disagrees [1]. > > Use the workaround suggested as fix upstream: include .git/COMMIT_EDITMSG in > the default files set. > > [ FWIW, that still doesn't fix something like this: > ... > $ tmp=$(mktemp) > $ echo 'msg' > $tmp > $ pre-commit run --hook-stage commit-msg --commit-msg-filename $tmp > ... > > I wanted to mention that upstream, but I couldn't because I was already locked > out of commenting on the issue I filed. ] > > Alternatively, we can drop the top-level files setting, and revert to > per-hook settings. > Writing a regression test for this made me realize that the workaround proposed in this patch is not sufficient, so I've committed a v2 ( https://sourceware.org/pipermail/gdb-patches/2026-July/228714.html ) that reverts to per-hook settings. Thanks, - Tom > [1] https://github.com/pre-commit/pre-commit/issues/3720 > --- > .pre-commit-config.yaml | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml > index 2f86a333ab5..fda10e30b1d 100644 > --- a/.pre-commit-config.yaml > +++ b/.pre-commit-config.yaml > @@ -40,7 +40,9 @@ > minimum_pre_commit_version: 4.5.1 > default_install_hook_types: [pre-commit, commit-msg] > default_stages: [pre-commit] > -files: '^(gdb|gdbserver|gdbsupport)/' > +# The ^\.git/COMMIT_EDITMSG$ is there to make sure commit-msg hooks work. > +# See this issue ( https://github.com/pre-commit/pre-commit/issues/3720 ). > +files: '^(gdb|gdbserver|gdbsupport)/|^\.git/COMMIT_EDITMSG$' > > repos: > # Python hooks. Run these for (in glob notation): > > base-commit: a4481c8ff808e7237b99815d84b0d4c06ded6124