mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
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, typically .git/COMMIT_EDITMSG. 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]. The fix suggested upstream is to include .git/COMMIT_EDITMSG in the default files setting. That indeed works for a regular commit, but not for something like this: ... $ tmp=$(mktemp) $ echo 'msg' > $tmp $ pre-commit run --hook-stage commit-msg --commit-msg-filename $tmp ... which is roughly what we're using in the regression test. We can't use .git/COMMIT_EDITMSG in the regression test, because the user may be editing it, or using it in some other way. We also cannot use say gdb/testsuite/gdb.src/commit-msg.txt, because using that filename doesn't detect the regression. [1] https://github.com/pre-commit/pre-commit/issues/3720
135 lines
4.4 KiB
YAML
135 lines
4.4 KiB
YAML
# Git has the notion of hooks, which are custom scripts that are run on
|
|
# specific events. One of these hooks is the pre-commit hook (located at
|
|
# .git/hooks/pre-commit), which is run when committing, before specifying a
|
|
# message.
|
|
#
|
|
# To ease management of the pre-commit hook, the pre-commit framework
|
|
# ( https://pre-commit.com ) was developed. This is the configuration file
|
|
# for that framework. It contains a list of hooks, with information on where
|
|
# to find them and on which files to run them.
|
|
#
|
|
# See here ( https://pre-commit.com/#install ) on how to install the
|
|
# pre-commit framework.
|
|
#
|
|
# To run all the hooks specified in this file manually, you can do:
|
|
# $ pre-commit run
|
|
#
|
|
# To run some hooks and skip others, you can use environment variable SKIP:
|
|
# $ SKIP=flake8,isort pre-commit run
|
|
#
|
|
# To install the pre-commit framework in the repository in order to run the
|
|
# hooks on every commit, do:
|
|
# $ pre-commit install
|
|
#
|
|
# After installing the pre-commit framework, you can skip running all
|
|
# pre-commit hooks using --no-verify, or some using SKIP.
|
|
# $ git commit --no-verify ...
|
|
# $ SKIP=flake8,isort git commit ...
|
|
#
|
|
# In case some of these hooks don't work for you, you can make the SKIP
|
|
# setting permanent by:
|
|
# - setting SKIP in your environment
|
|
# (this will affect all repositories where it is set)
|
|
# - setting SKIP in .git/hooks/pre-commit by adding "export SKIP=..."
|
|
# (this will affect only this repository, but it may have to be re-added
|
|
# if .git/hooks/pre-commit is regenerated)
|
|
#
|
|
# See https://pre-commit.com for more information
|
|
# See https://pre-commit.com/hooks.html for more hooks
|
|
|
|
minimum_pre_commit_version: 4.5.1
|
|
default_install_hook_types: [pre-commit, commit-msg]
|
|
default_stages: [pre-commit]
|
|
# 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):
|
|
#
|
|
# - gdb/gdb-gdb.py.in
|
|
# - gdb/*.py
|
|
# - gdb/python/**/*.py
|
|
# - gdb/testsuite/*.py
|
|
#
|
|
# Because gdb/gdb-gdb.py.in is not classified as python, we use
|
|
# 'types_or: [file]' to override the default type for these hooks.
|
|
#
|
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
|
rev: 26.5.1
|
|
hooks:
|
|
- id: black
|
|
types_or: &gdb_python_types [file]
|
|
files: &gdb_python_files '^gdb/.*\.py(\.in)?$'
|
|
- repo: https://github.com/pycqa/flake8
|
|
rev: 7.3.0
|
|
hooks:
|
|
- id: flake8
|
|
types_or: *gdb_python_types
|
|
files: *gdb_python_files
|
|
args: [--config, gdb/setup.cfg]
|
|
- repo: https://github.com/pycqa/isort
|
|
rev: 9.0.0b1
|
|
hooks:
|
|
- id: isort
|
|
types_or: *gdb_python_types
|
|
files: *gdb_python_files
|
|
|
|
# Codespell hooks.
|
|
- repo: https://github.com/codespell-project/codespell
|
|
rev: v2.4.3
|
|
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
|
|
args: *codespell_args
|
|
verbose: true
|
|
stages: [commit-msg]
|
|
|
|
# Tclint hooks.
|
|
- repo: https://github.com/nmoroze/tclint
|
|
rev: v0.8.0
|
|
hooks:
|
|
- id: tclint
|
|
args: [--trust-plugins]
|
|
files: '^gdb/testsuite/.*\.(exp|tcl)$'
|
|
|
|
# Local hooks.
|
|
- repo: local
|
|
hooks:
|
|
- id: &id0 check-include-guards
|
|
name: *id0
|
|
language: unsupported_script
|
|
entry: gdb/check-include-guards.py
|
|
# All gdb header files, but not headers in the test suite.
|
|
files: '^(gdb(support|server)?)/.*\.h$'
|
|
exclude: '.*/testsuite/.*'
|
|
- id: &id1 check-gnu-style
|
|
name: *id1
|
|
language: python
|
|
additional_dependencies: ['termcolor', 'unidiff']
|
|
entry: gdb/contrib/check-gnu-style-pre-commit.sh
|
|
files: '^(gdb(support|server)?)/.*\.(c|h|cc)$'
|
|
exclude: '.*/testsuite/.*'
|
|
verbose: true
|
|
- id: &id2 check-whitespace
|
|
name: *id2
|
|
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
|
|
entry: gdb/contrib/pre-commit-setup.py
|
|
additional_dependencies: ["pyyaml"]
|
|
always_run: true
|
|
pass_filenames: false
|
|
- id: &id4 check-file-mode
|
|
name: *id4
|
|
language: unsupported_script
|
|
entry: gdb/contrib/check-file-mode.sh
|
|
files: *gdb_files
|