Add a check for missing files befor commit

This commit is contained in:
Jean-Marie Favreau 2025-05-03 11:32:58 +02:00
parent 7dd6412e59
commit 52370e3c09
2 changed files with 18 additions and 2 deletions

View File

@ -14,14 +14,21 @@ repos:
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.9
rev: v0.11.8
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi ]
args: [ --fix ]
- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.32.0
rev: v1.36.4
hooks:
- id: djlint-reformat-django
- id: djlint-django
- repo: local
hooks:
- id: check-untracked
name: "Check untracked and unignored files"
entry: ./scripts/check-untracked.sh
language: script
always_run: true

9
scripts/check-untracked.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
untracked=$(git ls-files --others --exclude-standard)
if [ -n "$untracked" ]; then
echo "Error: The following files are untracked and not ignored:"
echo "$untracked"
echo "Please add them to Git or ignore them in .gitignore before committing."
exit 1
fi