-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
44 lines (40 loc) · 1.48 KB
/
.pre-commit-config.yaml
File metadata and controls
44 lines (40 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
name: ruff-check
args: [--fix]
types_or: [python, pyi, jupyter]
- id: ruff-format
name: ruff-format
types_or: [python, pyi, jupyter]
- repo: local
hooks:
- id: prevent-mixed-internal-external
name: Prevent internal/external files mixed commit
entry: bash -c
args:
- |
INTERNAL_PATTERN="^(xrl|intetest|docs/xrl)/"
staged_files=$(git -c core.quotePath=false diff --cached --name-only)
internal_files=$(echo "$staged_files" | grep -E "$INTERNAL_PATTERN" || true)
external_files=$(echo "$staged_files" | grep -vE "$INTERNAL_PATTERN" || true)
if [ -n "$internal_files" ] && [ -n "$external_files" ]; then
echo ""
echo "❌ ERROR: Cannot commit internal and external files simultaneously!"
echo ""
echo "Internal files (xrl/, intetest/):"
echo "$internal_files" | sed "s/^/ - /"
echo ""
echo "External files (other folders):"
echo "$external_files" | sed "s/^/ - /"
echo ""
echo "💡 Please commit them separately"
echo ""
exit 1
fi
language: system
pass_filenames: false
always_run: true
stages: [pre-commit]