File: pre-commit-tidy-hook

package info (click to toggle)
oar 2.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,700 kB
  • sloc: perl: 34,517; sh: 6,041; ruby: 5,840; sql: 3,390; cpp: 2,277; makefile: 402; php: 365; ansic: 335; python: 275; exp: 23
file content (24 lines) | stat: -rwxr-xr-x 676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
FAILED=
for f in $(git diff --name-only --staged); do
  if file $f | grep -q -e "Perl script" -e "Perl5 module"; then
    echo -n "# Running perltidy on $f (staged changes)... " 1>&2
    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
      echo "[OK]" 1>&2
    else
      FAILED=1
      echo 1>&2
    fi
  fi
done
if [ -n "$FAILED" ]; then
  cat <<EOF 1>&2
One or more files need to be fixed.

The following perltidy command may be used to fix a file:
$ perltidy -b -bext=/ -nolq -se -vt=1 -sct -vtc=1 -sct -bar -nsfs -baao -l=100 -pt=2 -ce <file>

Commit aborted.
EOF
  exit 1
fi