|
| 1 | +# Git has the notion of hooks, which are custom scripts that are run on |
| 2 | +# specific events. One of these hooks is the pre-commit hook (located at |
| 3 | +# .git/hooks/pre-commit), which is run when committing, before specifying a |
| 4 | +# message. |
| 5 | +# |
| 6 | +# To ease management of the pre-commit hook, the pre-commit framework |
| 7 | +# ( https://pre-commit.com ) was developed. This is the configuration file |
| 8 | +# for that framework. It contains a list of hooks, with information on where |
| 9 | +# to find them and on which files to run them. |
| 10 | +# |
| 11 | +# See here ( https://pre-commit.com/#install ) on how to install the |
| 12 | +# pre-commit framework. |
| 13 | +# |
| 14 | +# To run all the hooks specified in this file manually, you can do: |
| 15 | +# $ pre-commit run |
| 16 | +# |
| 17 | +# To run some hooks and skip others, you can use environment variable SKIP: |
| 18 | +# $ SKIP=flake8,isort pre-commit run |
| 19 | +# |
| 20 | +# To install the pre-commit framework in the repository in order to run the |
| 21 | +# hooks on every commit, do: |
| 22 | +# $ pre-commit install |
| 23 | +# |
| 24 | +# After installing the pre-commit framework, you can skip running all |
| 25 | +# pre-commit hooks using --no-verify, or some using SKIP. |
| 26 | +# $ git commit --no-verify ... |
| 27 | +# $ SKIP=flake8,isort git commit ... |
| 28 | +# |
| 29 | +# In case some of these hooks don't work for you, you can make the SKIP |
| 30 | +# setting permanent by: |
| 31 | +# - setting SKIP in your environment |
| 32 | +# (this will affect all repositories where it is set) |
| 33 | +# - setting SKIP in .git/hooks/pre-commit by adding "export SKIP=..." |
| 34 | +# (this will affect only this repository, but it may have to be re-added |
| 35 | +# if .git/hooks/pre-commit is regenerated) |
| 36 | +# |
| 37 | +# See https://pre-commit.com for more information |
| 38 | +# See https://pre-commit.com/hooks.html for more hooks |
| 39 | + |
| 40 | +minimum_pre_commit_version: 3.2.0 |
| 41 | +default_install_hook_types: [pre-commit, commit-msg] |
| 42 | +default_stages: [pre-commit] |
| 43 | +repos: |
| 44 | + - repo: https://github.com/psf/black-pre-commit-mirror |
| 45 | + rev: 25.11.0 |
| 46 | + hooks: |
| 47 | + - id: black |
| 48 | + types_or: [file] |
| 49 | + files: '^gdb/.*\.py(\.in)?$' |
| 50 | + - repo: https://github.com/pycqa/flake8 |
| 51 | + rev: 7.3.0 |
| 52 | + hooks: |
| 53 | + - id: flake8 |
| 54 | + types_or: [file] |
| 55 | + # Run this for (in glob notation): |
| 56 | + # |
| 57 | + # - gdb/gdb-gdb.py.in |
| 58 | + # - gdb/*.py |
| 59 | + # - gdb/python/**/*.py |
| 60 | + # - gdb/testsuite/*.py |
| 61 | + # |
| 62 | + files: '^gdb/.*\.py(\.in)?$' |
| 63 | + args: [--config, gdb/setup.cfg] |
| 64 | + - repo: https://github.com/pycqa/isort |
| 65 | + rev: 7.0.0 |
| 66 | + hooks: |
| 67 | + - id: isort |
| 68 | + types_or: [file] |
| 69 | + files: '^gdb/.*\.py(\.in)?$' |
| 70 | + - repo: https://github.com/codespell-project/codespell |
| 71 | + rev: v2.4.1 |
| 72 | + hooks: |
| 73 | + - id: codespell |
| 74 | + files: '^(gdbsupport|gdbserver|gdb/(dwarf2|tui|target|data-directory|po|system-gdbinit|mi|syscalls|arch|regformats|compile|python|guile|config|unittests|cli|testsuite/gdb.(ctf|dap|debuginfod|gdb|go|guile|mi|modula2|objc|opencl|opt|pascal|perf|replay|reverse|rocm|server|stabs|testsuite|tui|xml)))/' |
| 75 | + args: [--config, gdb/contrib/setup.cfg] |
| 76 | + - id: codespell |
| 77 | + name: codespell-log |
| 78 | + entry: gdb/contrib/codespell-log.sh |
| 79 | + args: [--config, gdb/contrib/setup.cfg] |
| 80 | + always_run: true |
| 81 | + verbose: true |
| 82 | + stages: [commit-msg] |
| 83 | + - repo: local |
| 84 | + hooks: |
| 85 | + - id: check-include-guards |
| 86 | + name: check-include-guards |
| 87 | + language: python |
| 88 | + entry: gdb/check-include-guards.py |
| 89 | + # All gdb header files, but not headers in the test suite. |
| 90 | + files: '^(gdb(support|server)?)/.*\.h$' |
| 91 | + exclude: '.*/testsuite/.*' |
| 92 | + - id: check-gnu-style |
| 93 | + name: check-gnu-style |
| 94 | + language: python |
| 95 | + additional_dependencies: ['termcolor', 'unidiff'] |
| 96 | + entry: gdb/contrib/check-gnu-style-pre-commit.sh |
| 97 | + files: '^(gdb(support|server)?)/.*\.(c|h|cc)$' |
| 98 | + exclude: '.*/testsuite/.*' |
| 99 | + verbose: true |
| 100 | + stages: [pre-commit] |
| 101 | + - id: check-whitespace |
| 102 | + name: check-whitespace |
| 103 | + language: script |
| 104 | + entry: gdb/contrib/check-whitespace-pre-commit.py |
| 105 | + files: '^(gdb(support|server)?)/.*$' |
| 106 | + pass_filenames: true |
| 107 | + stages: [pre-commit] |
| 108 | + - id: pre-commit-setup |
| 109 | + name: pre-commit-setup |
| 110 | + language: python |
| 111 | + entry: gdb/contrib/pre-commit-setup.py |
| 112 | + additional_dependencies: ["pyyaml"] |
| 113 | + always_run: true |
| 114 | + require_serial: true |
| 115 | + - repo: https://github.com/nmoroze/tclint |
| 116 | + rev: v0.7.0 |
| 117 | + hooks: |
| 118 | + - id: tclint |
| 119 | + args: [--commands, gdb/testsuite/tclint-plugin.py] |
| 120 | + types_or: [file] |
| 121 | + files: '^gdb/testsuite/.*\.(exp|tcl)$' |
0 commit comments