File: check-formatting

package info (click to toggle)
blasr 5.3.3%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,156 kB
  • sloc: cpp: 8,412; ansic: 806; python: 331; java: 158; sh: 152; makefile: 39
file content (34 lines) | stat: -rwxr-xr-x 1,097 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 . ctest iblasr extrautils -name LibBlasrConfig.h -prune -o \( -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 '**third-party/*' \
    | 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