From 3895796c99b7d63a319c953dcb4690432ce26e0d Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Thu, 30 Jan 2025 17:05:40 +0100 Subject: [PATCH 1/3] Use pre-built hooks in pre commit --- .github/scripts/clang-format-hook | 21 --------------------- .pre-commit-config.yaml | 25 ++++++++++--------------- 2 files changed, 10 insertions(+), 36 deletions(-) delete mode 100755 .github/scripts/clang-format-hook diff --git a/.github/scripts/clang-format-hook b/.github/scripts/clang-format-hook deleted file mode 100755 index 731de085c..000000000 --- a/.github/scripts/clang-format-hook +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# Thin wrapper around clang-format for easier to parse output from the -# pre-commit hook. -# -# Needs to work with multiple input files as pre-commit passes multiple files to -# the "executables" - -# Make sure that diff is actually recent enough (diffutils >= 3.4) to support -# colored output -COLOR_OUTPUT=$(diff --color=always <(echo) <(echo) > /dev/null 2>&1 && echo "--color=always") - -success=0 -for file in ${@}; do - if ! $(clang-format --style=file --Werror --dry-run ${file} > /dev/null 2>&1); then - echo "Necessary changes for: '${file}' (run 'clang-format --style=file -i ${file}' to fix it)" - diff ${COLOR_OUTPUT} -u ${file} <(clang-format --style=file ${file}) | tail -n +3 - success=1 - fi -done -exit ${success} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b54a59c8c..6a727d0a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,24 +7,19 @@ repos: exclude: (doc/ReleaseNotes.md) - repo: local hooks: - - id: clang-format - name: clang-format - entry: .github/scripts/clang-format-hook - exclude: (edm4hep/(edm4hep|src)/.*(h|cc)$|EDM4HEPVersion.h) - types: [c++] - language: system - id: readme-links-check name: README links check - entry: python ./scripts/updateReadmeLinks.py --check + entry: python3 ./scripts/updateReadmeLinks.py --check files: (^README.md$) language: system + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.3 + hooks: - id: ruff - name: ruff - entry: ruff check --force-exclude - types: [python] - language: system - id: ruff-format - name: ruff-format - entry: ruff format --force-exclude - types: [python] - language: system + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: 'v16.0.6' + hooks: + - id: clang-format + types: [c++] + exclude: (edm4hep/(edm4hep|src)/.*(h|cc)$|EDM4HEPVersion.h) From 1f9aca070b6581d6f147bb6f60151078b484c913 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Thu, 30 Jan 2025 17:12:03 +0100 Subject: [PATCH 2/3] don't install ruff --- .github/workflows/pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 7a035eb5e..e653c506f 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -32,7 +32,7 @@ jobs: cd $STARTDIR python3 -m venv /root/pre-commit-venv source /root/pre-commit-venv/bin/activate - pip install pre-commit ruff + pip install pre-commit cmake -DENABLE_SIO=ON \ -DCMAKE_CXX_STANDARD=20 \ -DCMAKE_CXX_FLAGS=" -fdiagnostics-color=always -Werror "\ From 4ef96249c279f8dcddb450ad55f742ec4cc6f9fb Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 31 Jan 2025 10:43:33 +0100 Subject: [PATCH 3/3] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a727d0a1..2efe7649e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: ruff - id: ruff-format - repo: https://github.com/pre-commit/mirrors-clang-format - rev: 'v16.0.6' + rev: 'v17.0.6' hooks: - id: clang-format types: [c++]