blob: c1b36a0ed311002d33aa196bc91cc56d95ab43f2 (
plain)
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
|
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
FILES=$(git diff-index --name-only --diff-filter=ACMR --cached $against -- |egrep ".py$")
if [ "$FILES" != "" ]; then
# We want to look at the staged version only, so we have to run it once for
# each file.
E=0
for F in ${FILES}; do
P=$(git show ":$F" | python3 -c "import sys; compile(sys.stdin.read(), '/dev/null', 'exec')")
if [ "$?" != "0" ]; then
echo "Errors in $F"
echo $P
E=1
continue
fi
R=$(git show ":$F" | pycodestyle -)
if [ "$?" != "0" ]; then
echo "Errors in $F"
echo "$R"
E=1
fi
done
if [ "$E" != "0" ]; then
exit 1
fi
echo Basic python checks passed.
fi
|