Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [pre-commit] Fix codespell-log hook
@ 2026-07-16 16:54 Tom de Vries
  2026-07-17 11:21 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-07-16 16:54 UTC (permalink / raw)
  To: gdb-patches

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.

[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
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [pre-commit] Fix codespell-log hook
  2026-07-16 16:54 [PATCH] [pre-commit] Fix codespell-log hook Tom de Vries
@ 2026-07-17 11:21 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2026-07-17 11:21 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-17 11:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-16 16:54 [PATCH] [pre-commit] Fix codespell-log hook Tom de Vries
2026-07-17 11:21 ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox