File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
+ name=" clang-format"
4
+
5
+ if [ -z " $( command -v " git-$name " ) " ]; then
6
+ name=" $( basename -a $( find $( echo " $PATH " | tr ' :' ' ' ) -maxdepth 1 -type f -executable -name ' git-clang-format*' ) | sort | tail -n 1 | sed ' s/^git-//' ) "
7
+ fi
8
+
3
9
minVersion=" 14.0.0"
4
10
5
- for file in $( find $( echo " $PATH " | tr ' :' ' ' ) -maxdepth 1 -type f -executable -name ' git- clang-format*' ) ; do
6
- curName =" $( basename " $ file" | sed ' s/^git-// ' ) "
7
- curVersion=" $( " $curName " --version | cut -d ' ' -f 3) "
11
+ for file in $( find $( echo " $PATH " | tr ' :' ' ' ) -maxdepth 1 -type f -executable -name ' clang-format*' ) ; do
12
+ curBin =" $file "
13
+ curVersion=" $( " $curBin " --version | cut -d ' ' -f 3) "
8
14
9
15
if [ " $( printf ' %s\n' " $curVersion " " $version " " $minVersion " | sort -V | tail -n 1) " = " $curVersion " ]; then
10
- name =" $curName "
16
+ bin =" $curBin "
11
17
version=" $curVersion "
12
18
fi
13
19
done
14
20
15
- if [ -z " $name " ]; then
21
+ if [ -z " $name " ] || [ -z " $bin " ] ; then
16
22
echo " Could not find a suitable clang-format installation. Install clang-format that includes the git-clang-format script, with at least version $minVersion "
17
23
exit 1
18
24
fi
19
25
20
- args=' - q --extensions cpp,h --style file --staged -- :!src/FreeRTOS :!src/libs'
26
+ args=" --binary $bin - q --extensions cpp,h --style file --staged -- :!src/FreeRTOS :!src/libs"
21
27
22
28
changedFiles=" $( git " $name " --diffstat $args ) "
23
29
git " $name " $args
You can’t perform that action at this time.
0 commit comments