File: check-formatting

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 7,148 kB
  • sloc: cpp: 77,259; python: 331; sh: 103; makefile: 41
file content (34 lines) | stat: -rwxr-xr-x 1,081 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env bash

PLATFORM=$(uname)
TOOLSPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
CLANGFORMAT="${TOOLSPATH}/${PLATFORM}/clang-format -style=file"

if [ "$1" == "--all" ]
then
    find alignment hdf pbdata unittest \( -name '*.cpp' -or -name '*.h' -or -name '*.hpp' \) -print0 \
    | xargs -n1 -0 ${CLANGFORMAT} -output-replacements-xml \
    | grep -c "<replacement " > /dev/null
    grepCode=$?
elif [ "$1" == "--staged" ]
then
    git diff --cached --name-only --diff-filter=ACMRT | grep -e '.*\.h$' -e '.*\.cpp' -v 'pbbam/*' -v 'googletest/*' \
    | xargs -n1 ${CLANGFORMAT} -output-replacements-xml \
    | grep -c "<replacement " >/dev/null
    grepCode=$?
else
    echo "Please specify --all or --staged"
    exit 1
fi

# grep exits 0 => found needed formatting changes
if [ $grepCode -ne 0 ]
then
    echo "Formatting looks good!"
    exit 0
else
    echo "****************************************************"
    echo "Code needs formatting!  Please use 'tools/format-all'"
    echo "****************************************************"
    exit 1
fi