Fix pre-commit hook for commit messages
Corrects the pre-commit hook configuration to ensure the codespell-log hook correctly processes commit messages.
This commit addresses an issue where the codespell-log pre-commit hook was not being triggered for commit messages. A recent change to the files filter in .pre-commit-config.yaml inadvertently excluded the .git/COMMIT_EDITMSG file, which is used by commit-msg hooks. The fix updates the configuration to include .git/COMMIT_EDITMSG in the filter, ensuring the hook properly analyzes commit messages, and also adjusts the associated regression test to accurately detect the issue.
In Details
The pre-commit hook configuration in .pre-commit-config.yaml was updated to resolve a regression where the codespell-log commit-msg hook was bypassed. The previous files directive, intended for repository files, incorrectly filtered out .git/COMMIT_EDITMSG. This change modifies the files pattern to include .git/COMMIT_EDITMSG, ensuring commit-msg hooks are invoked correctly. The test case in gdb/testsuite/gdb.src/pre-commit.exp was also adjusted to properly trigger and detect this behavior during regression testing.
- pre-commit hook
- A script that runs automatically before a commit is created (or during other Git operations), used for tasks like linting, formatting, and spell-checking code and commit messages.
- commit-msg hook
- A specific type of Git hook that runs after a commit message has been written but before the commit is finalized, allowing for validation or modification of the message.
- codespell-log
- A pre-commit hook that checks for common spelling errors in code and commit messages.
- .git/COMMIT_EDITMSG
- A temporary file in the
.gitdirectory that stores the commit message during the commit process. - regression test
- A test designed to ensure that a previously fixed bug does not reappear or that a new change does not break existing functionality.