[3/4] Add check-include-guards.py to pre-commit

Message ID 20240417-header-check-v1-3-a60f610f5bcc@adacore.com
State New
Headers
Series Add include guard checker and reformatter |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey April 17, 2024, 10:05 p.m. UTC
  This changes pre-commit to run check-include-guards.py.
---
 .pre-commit-config.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Simon Marchi April 18, 2024, 3:33 p.m. UTC | #1
On 2024-04-17 18:05, Tom Tromey wrote:
> This changes pre-commit to run check-include-guards.py.
> ---
>  .pre-commit-config.yaml | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
> index 8721dac678b..b3dcf6482cf 100644
> --- a/.pre-commit-config.yaml
> +++ b/.pre-commit-config.yaml
> @@ -22,3 +22,10 @@ repos:
>      - id: isort
>        types_or: [file]
>        files: 'gdb/.*\.py(\.in)?$'
> +  - repo: local
> +    hooks:
> +    - id: check-include-guards
> +      name: check-include-guards
> +      language: python
> +      entry: gdb/check-include-guards.py
> +      files: '^(gdb(support|server)?)/[^/]*(/[^/]*)?\.h$'

The regex is a bit hard to read... can you add a comment to indicate
what this indends to match?  I think this does not match header files
under gdb/testsuite (because they are deeper than what the regex would
match)?

Simon
  
Tom Tromey April 18, 2024, 3:45 p.m. UTC | #2
Simon> The regex is a bit hard to read... can you add a comment to indicate
Simon> what this indends to match?  I think this does not match header files
Simon> under gdb/testsuite (because they are deeper than what the regex would
Simon> match)?

I added this:

      # This matches headers in gdbsupport, gdbserver, gdb, and the
      # immediate subdirectories of gdb (e.g., gdb/nat) -- but,
      # importantly, not gdb/testsuite/*/*.h.

I went a little too fast sending v2, should have waited a bit.
Anyway I don't think this addition warrants a v3.

Tom
  

Patch

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8721dac678b..b3dcf6482cf 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -22,3 +22,10 @@  repos:
     - id: isort
       types_or: [file]
       files: 'gdb/.*\.py(\.in)?$'
+  - repo: local
+    hooks:
+    - id: check-include-guards
+      name: check-include-guards
+      language: python
+      entry: gdb/check-include-guards.py
+      files: '^(gdb(support|server)?)/[^/]*(/[^/]*)?\.h$'