diff options
author | Tom de Vries <tdevries@suse.de> | 2025-04-25 19:22:36 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2025-04-25 19:22:36 +0200 |
commit | 129228c8b01a8fe0345e33fe07d185047721bd68 (patch) | |
tree | f9911f37dfd77d1f30d28d8611f45adbdd23cfd9 /gdb/testsuite/gdb.ada/atomic_enum/pck.adb | |
parent | a1537331abaf66fddd3553dd827381a01bcda46c (diff) | |
download | gdb-master.zip gdb-master.tar.gz gdb-master.tar.bz2 |
Now that we're using codespell to check spelling in gdb files, can we use
codespell to bring this spelling warning:
...
$ echo usuable | codespell -
1: usuable
usuable ==> usable
...
to:
...
$ git commit -a -m "Usuable stuff"
...
?
First, let's look at a straightforward commit-msg hook implementation:
...
- id: codespell
name: codespell-commit-msg
verbose: true
always_run: true
stages: [commit-msg]
...
installed using:
...
$ pre-commit install -t commit-msg
...
When trying the commit, we get:
...
$ echo "/* bla */" >> gdb/gdb.c
$ git commit -a -m "Usuable stuff"
black................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
isort................................................(no files to check)Skipped
codespell............................................(no files to check)Skipped
check-include-guards.................................(no files to check)Skipped
black................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
codespell............................................(no files to check)Skipped
codespell-commit-msg.....................................................Failed
- hook id: codespell
- duration: 0.06s
- exit code: 65
.git/COMMIT_EDITMSG:1: Usuable ==> Usable
check-include-guards.................................(no files to check)Skipped
$
...
The commit was aborted, but the commit message is still there:
...
$ cat .git/COMMIT_EDITMSG
Usuable stuff
...
We can retry and edit the commit message to clean up the typo:
...
$ git commit -e -F .git/COMMIT_EDITMSG -a
...
but it's a bit cumbersome.
Furthermore, say we fix a typo and want to document this in the commit log, and
do:
...
$ git commit -m "Fixed typo: useable -> usable" -a
...
This commit cannot succeed, unless we add a codespell ignore tag, which feels
like taking it too far.
Both these problems can be addressed by setting things up in such a way that
the commit always succeeds, and codespell output is shown as a hint.
Ideally, we'd tell to pre-commit to implement this using some setting, but
there doesn't seem to be one.
So we use some indirection. Instead of using native codespell, use a local
hook that calls a script gdb/contrib/codespell-log.sh, which calls pre-commit,
which calls codespell.
Using this approach, we get:
...
$ echo "/* bla */" >> gdb/gdb.c
$ git commit -a -m "Usuable stuff"
black................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
isort................................................(no files to check)Skipped
codespell............................................(no files to check)Skipped
check-include-guards.................................(no files to check)Skipped
black................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
codespell............................................(no files to check)Skipped
check-include-guards.................................(no files to check)Skipped
codespell-log............................................................Passed
- hook id: codespell-log
- duration: 0.18s
codespell-log-internal...................................................Failed
- hook id: codespell
- exit code: 65
.git/COMMIT_EDITMSG:1: Usuable ==> Usable
[codespell/codespell-log-2 d081bd25a40] Usuable stuff
1 file changed, 1 insertion(+)
$
...
This is obviously convoluted, but it works. Perhaps we can propose a
pre-commit improvement (always_pass) and simplify this eventually.
Checked new script codespell-log.sh with shell-check.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/testsuite/gdb.ada/atomic_enum/pck.adb')
0 files changed, 0 insertions, 0 deletions