Debian Codegraph @

scripts/clang-format-pre-commit

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # To use:
4 # ln -s scripts/clang-format.hook .git/hooks/pre-commit
5
6 # Based loosely on https://github.com/andrewseidl/githook-clang-format
7
8 format_filescip-shell shell cli11 2.6.1+ds-1 format_file().() {
9 file="${1}"
10 case "$file" in
11 *.hpp | *.cpp | .c | *.cc | *.cu | *.h )
12 if [scip-shell system . . `[`. -f "${1}" ] ; then
13 clang-format -i -style=file -sort-includes "${1}"
14 if gitscip-shell system . . git. diff-files --quiet -- "${1}" ; then
15 echoscip-shell system . . echo. "Already nicely formatted: ${1}"
16 else
17 gitscip-shell system . . git. add "${1}"
18 echoscip-shell system . . echo. "Reformatting file: ${1}"
19 fi
20 fi
21 ;;
22 *)
23 ;;
24 esac
25 }
26
27 case "${1}" in
28 --about )
29 echoscip-shell system . . echo. "Runs clang-format on source files"
30 ;;
31 * )
32 for file in `gitscip-shell system . . git. diff-index --cached --name-only HEAD` ; do
33 format_filescip-shell shell cli11 2.6.1+ds-1 format_file(). "${file}"
34 done
35 ;;
36 esac