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.
This commit is contained in:
parent
142446c405
commit
ac64d82871
1 changed files with 11 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue