File: checkFormat.sh

package info (click to toggle)
zmap 4.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,628 kB
  • sloc: ansic: 15,033; python: 1,085; yacc: 125; sh: 120; lex: 28; makefile: 4
file content (20 lines) | stat: -rwxr-xr-x 433 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

CLANG_FORMAT=clang-format-6.0

files_to_lint=$(find ./src ./lib -type f -name '*.c' -or -name '*.h')

fail=0
for f in ${files_to_lint}; do
  d="$(diff -u "$f" <($CLANG_FORMAT -style=file "$f") || true)"
  if ! [ -z "$d" ]; then
    printf "The file %s is not compliant with the coding style:\n%s\n" "$f" "$d"
    fail=1
  fi
done

if [ "$fail" -eq "1" ]; then
  if [ ! -z $ZMAP_ENFORCE_FORMAT ]; then
    exit 1
  fi
fi