File: format.sh

package info (click to toggle)
libsrtp2 2.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,400 kB
  • sloc: ansic: 18,560; sh: 3,495; makefile: 387; cpp: 17
file content (35 lines) | stat: -rwxr-xr-x 640 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
# format.sh
#
# run clang-format on each .c & .h file
#
# assumes git tree is clean when reporting status

if [ -z "${CLANG_FORMAT}" ]; then
    CLANG_FORMAT=clang-format
fi

a=`git ls-files '*.h' '*.c'`
for x in $a; do
    if [ $x != "config_in.h" ]; then
        $CLANG_FORMAT -i -style=file $x
    fi
done

m=`git ls-files -m`
if [ -n "$m" ]; then
    v=`$CLANG_FORMAT -version`
    echo "Fromatting required when checking with $v"
    echo
    echo "The following files required formatting:"
    for f in $m; do
        echo $f
    done
    if [ "$1" = "-d" ]; then
        echo
        git diff
    fi
    exit 1
fi
exit 0