Debian Codegraph @

misc/dev/pre-commit-tidy-hook

raw
1 #!/bin/sh
2 FAILED=
3 for f in $(git diff --name-only --staged); do
4 if file $f | grep -q -e "Perl script" -e "Perl5 module"; then
5 echo -n "# Running perltidy on $f (staged changes)... " 1>&2
6 if git show ":$f" | perltidy -opath=/tmp/ -ast -nolq -se -vt=1 -sct -vtc=1 -sct -bar -nsfs -baao -l=100 -pt=2 -ce > /dev/null; then
7 echo "[OK]" 1>&2
8 else
9 FAILED=1
10 echo 1>&2
11 fi
12 fi
13 done
14 if [ -n "$FAILED" ]; then
15 cat <<EOF 1>&2
16 One or more files need to be fixed.
17
18 The following perltidy command may be used to fix a file:
19 $ perltidy -b -bext=/ -nolq -se -vt=1 -sct -vtc=1 -sct -bar -nsfs -baao -l=100 -pt=2 -ce <file>
20
21 Commit aborted.
22 EOF
23 exit 1
24 fi