diff options
author | David Kalnischkies <david@kalnischkies.de> | 2017-12-13 15:21:40 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2017-12-13 23:52:28 +0100 |
commit | fd9f75b3164cd4eb52783eed3be9898dd7fba800 (patch) | |
tree | f1cc90bf8206e8214300df5f1d1f47065f137e03 /git-clang-format.sh | |
parent | b857d586edeb3639d996a75fccd55ebea370b491 (diff) | |
download | apt-fd9f75b3164cd4eb52783eed3be9898dd7fba800.tar.gz |
use the newest available git-clang-format in PATH
Hardcoding a specific version is sad as default versions change over
time, so instead of tying us to a specific clang version we let the
script figure out a good version by looking at what is available in
PATH.
Gbp-Dch: Ignore
Diffstat (limited to 'git-clang-format.sh')
-rwxr-xr-x | git-clang-format.sh | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/git-clang-format.sh b/git-clang-format.sh index d374b66bd..6348652c1 100755 --- a/git-clang-format.sh +++ b/git-clang-format.sh @@ -1,3 +1,10 @@ #!/bin/sh cd "$(dirname "$0")" -git clang-format-3.8 --diff "$@" | sed "s#+/\*\}\}\}\*/#+ /*}}}*/#" | patch -p1 +CLANG_FORMAT="$(find $(echo "$PATH" | tr ':' ' ') -name 'git-clang-format-*' | sort | tail -n1 )" +if [ -z "$CLANG_FORMAT" ]; then + echo >&2 'Could not find a clang-format to use. Is the package clang-format installed?' + exit 1 +fi +git "$(basename "$CLANG_FORMAT" | cut -d'-' -f 2-)" --diff "$@" | \ + sed "s#+/\*\}\}\}\*/#+ /*}}}*/#" | \ + patch -p1 |