From ac64d82871ddf12db072999e4c69e47dc9e9c818 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Tue, 22 Jul 2025 10:46:05 +0200 Subject: [PATCH] fix: prevent duplicate pre-commit hook execution - Add explicit stages: [pre-commit] to all hooks except gitlint - Keep gitlint on stages: [commit-msg] for commit message validation - Prevents hooks from running on both pre-commit and commit-msg stages - Each hook now runs exactly once on the appropriate stage This resolves the issue where some hooks were executing twice during commits, improving performance and reducing redundant output. --- .pre-commit-config.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 71869a1..6acbf88 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,14 +8,22 @@ repos: rev: v4.6.0 hooks: - id: trailing-whitespace + stages: [pre-commit] - id: end-of-file-fixer + stages: [pre-commit] - id: check-yaml + stages: [pre-commit] - id: check-added-large-files + stages: [pre-commit] - id: check-merge-conflict + stages: [pre-commit] - id: check-json + stages: [pre-commit] - id: check-toml + stages: [pre-commit] - id: mixed-line-ending args: ["--fix=lf"] + stages: [pre-commit] # Python code formatting and linting - repo: https://github.com/astral-sh/ruff-pre-commit @@ -23,7 +31,9 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + stages: [pre-commit] - id: ruff-format + stages: [pre-commit] # Git commit message linting with gitlint - repo: https://github.com/jorisroovers/gitlint @@ -39,6 +49,7 @@ repos: - id: bandit args: ["-c", "pyproject.toml"] additional_dependencies: ["bandit[toml]"] + stages: [pre-commit] # Configuration for specific hooks ci: