minimum_pre_commit_version: 4.5.1
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit]
-files: '^(gdb|gdbserver|gdbsupport)/'
+# A default files setting like "files: '^(gdb|gdbserver|gdbsupport)/" would be
+# nice, but that disables commit-msg hooks. See this pre-commit issue (
+# https://github.com/pre-commit/pre-commit/issues/3720 ).
repos:
# Python hooks. Run these for (in glob notation):
hooks:
- id: codespell
args: &codespell_args [--toml, gdb/pyproject.toml]
+ files: &gdb_files '^(gdb|gdbserver|gdbsupport)/'
- id: codespell
name: codespell-log
entry: gdb/contrib/codespell-log.sh
language: unsupported_script
entry: gdb/contrib/check-whitespace-pre-commit.py
types: ['text']
+ files: *gdb_files
- id: &id3 pre-commit-setup
name: *id3
language: python
name: *id4
language: unsupported_script
entry: gdb/contrib/check-file-mode.sh
+ files: *gdb_files
set status [lindex $result 0]
gdb_assert {$status == 0} "pre-commit checks"
+ with_test_prefix commit-msg {
+ set commit_msg [build_standard_output_file "commit-msg.txt"]
+
+ # codespell:ignore-begin.
+ gdb_produce_source $commit_msg {
+ This should aways produce a codespell warning.
+ }
+ # codespell:ignore-end.
+
+ set result \
+ [remote_exec build \
+ "pre-commit run --hook-stage commit-msg --commit-msg-filename $commit_msg -v"]
+ set status [lindex $result 0]
+ set output [lindex $result 1]
+ gdb_assert {$status == 0} "run"
+
+ with_test_prefix codespell-log {
+ # codespell:ignore-begin.
+ set re [string_to_regexp "aways ==> "]
+ # codespell:ignore-end.
+
+ gdb_assert {[regexp $re $output]} "output"
+ }
+ }
}