From 14b8ca53171435113a0f0f0c4ff1063d12543bc4 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 17 May 2024 14:35:02 +0200 Subject: [PATCH] GH-41688: [Dev] Include all relevant CMakeLists.txt files in cmake-format precommit hook (#41689) ### Rationale for this change Some CMakeLists.txt files are not included in the pre-commit hook (causing failures on CI through archery if you rely on the pre-commit hook locally) ### What changes are included in this PR? Include all CMakeLists.txt files by default anywhere in the repo, and explicitly exclude the ones we don't want (vendored files). In practice, compared to the current set of files covered by the hook, those new files are included in the search: 'cpp/CMakeLists.txt', 'java/CMakeLists.txt', 'matlab/CMakeLists.txt', 'python/CMakeLists.txt' ### Are these changes tested? Yes * GitHub Issue: #41688 Authored-by: Joris Van den Bossche Signed-off-by: Joris Van den Bossche --- .pre-commit-config.yaml | 7 ++----- dev/archery/archery/utils/lint.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7dcc1c9816d12..1e4b91e27ee8a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -116,17 +116,14 @@ repos: name: CMake Format files: >- ( + ?.*CMakeLists\.txt$| ?^ci/.*/.*\.cmake$| ?^cpp/.*/.*\.cmake\.in$| ?^cpp/.*/.*\.cmake$| - ?^cpp/.*/CMakeLists\.txt$| - ?^go/.*/CMakeLists\.txt$| - ?^java/.*/CMakeLists\.txt$| - ?^matlab/.*/CMakeLists\.txt$| - ?^python/.*/CMakeLists\.txt$| ) exclude: >- ( + ?^ci/conan/all/.*CMakeLists\.txt$| ?^cpp/cmake_modules/FindNumPy\.cmake$| ?^cpp/cmake_modules/FindPythonLibsNew\.cmake$| ?^cpp/cmake_modules/UseCython\.cmake$| diff --git a/dev/archery/archery/utils/lint.py b/dev/archery/archery/utils/lint.py index 108c9ded361e7..92b7f79fc1017 100644 --- a/dev/archery/archery/utils/lint.py +++ b/dev/archery/archery/utils/lint.py @@ -157,7 +157,7 @@ def cmake_linter(src, fix=False): 'go/**/CMakeLists.txt', 'java/**/CMakeLists.txt', 'matlab/**/CMakeLists.txt', - 'python/CMakeLists.txt', + 'python/**/CMakeLists.txt', ], exclude_patterns=[ 'cpp/cmake_modules/FindNumPy.cmake',