File: check-format.sh

package info (click to toggle)
pngtools 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 928 kB
  • sloc: ansic: 871; sh: 684; python: 558; makefile: 32
file content (21 lines) | stat: -rwxr-xr-x 568 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
#!/bin/bash
set -e

cd "$(dirname "$0")/.."

# Check or fix C source formatting with clang-format.
# Usage:
#   scripts/check-format.sh        # check only (exits non-zero on diff)
#   scripts/check-format.sh fix    # reformat files in place

mapfile -t FILES < <(find . -maxdepth 1 -name '*.c' -o -name '*.h' | sort)

if [ "$1" = "fix" ]; then
    echo "==> Reformatting C sources..."
    clang-format -i "${FILES[@]}"
    echo "Done."
else
    echo "==> Checking C source formatting..."
    clang-format --dry-run --Werror "${FILES[@]}"
    echo "Formatting OK."
fi