File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 11#! /bin/sh
22
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+
39minVersion=" 14.0.0"
410
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) "
814
915 if [ " $( printf ' %s\n' " $curVersion " " $version " " $minVersion " | sort -V | tail -n 1) " = " $curVersion " ]; then
10- name =" $curName "
16+ bin =" $curBin "
1117 version=" $curVersion "
1218 fi
1319done
1420
15- if [ -z " $name " ]; then
21+ if [ -z " $name " ] || [ -z " $bin " ] ; then
1622 echo " Could not find a suitable clang-format installation. Install clang-format that includes the git-clang-format script, with at least version $minVersion "
1723 exit 1
1824fi
1925
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"
2127
2228changedFiles=" $( git " $name " --diffstat $args ) "
2329git " $name " $args
You can’t perform that action at this time.
0 commit comments