Skip to content

Commit e66a575

Browse files
committed
Don't mix tab and spaces indentation in pre-commit hook (#1)
1 parent 072219e commit e66a575

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

tools/githook/pre-commit

+13-16
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
#!/bin/sh
22

3-
if git rev-parse --verify HEAD >/dev/null 2>&1
4-
then
5-
against=HEAD
3+
if git rev-parse --verify HEAD >/dev/null 2>&1; then
4+
against=HEAD
65
else
7-
# Initial commit: diff against an empty tree object
8-
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
6+
# Initial commit: diff against an empty tree object
7+
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
98
fi
109

11-
FILES=$(git diff-index --name-only --diff-filter=ACMR --cached $against -- |egrep ".py$")
10+
FILES=$(git diff-index --name-only --diff-filter=ACMR --cached $against -- | egrep ".py$")
1211
if [ "$FILES" != "" ]; then
1312
# We want to look at the staged version only, so we have to run it once for
1413
# each file.
1514
E=0
1615
for F in ${FILES}; do
16+
if ! git show ":$F" | ruff check - --quiet --stdin-filename "$F"; then
17+
E=1
18+
fi
1719

18-
if ! git show ":$F" | ruff check - --quiet --stdin-filename "$F"; then
19-
E=1
20-
fi
21-
22-
if ! git show ":$F" | ruff format - --quiet --check; then
23-
E=1
24-
echo "Formatting errors in $F, run 'make format'"
25-
fi
20+
if ! git show ":$F" | ruff format - --quiet --check; then
21+
E=1
22+
echo "Formatting errors in $F, run 'make format'"
23+
fi
2624
done
2725
if [ "$E" != "0" ]; then
28-
exit 1
26+
exit 1
2927
fi
3028

3129
echo Basic python checks passed.
3230
fi
33-

0 commit comments

Comments
 (0)