File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /bin/sh
22
3- git clang-format --extensions cpp,h --style file --staged -- ' :!src/FreeRTOS' ' :!src/libs'
3+ name=" "
4+ version=" 14.0.0"
45
5- git diff --name-only --diff-filter=ACMR | while read -r file
6- do
6+ for file in $( find $( echo " $PATH " | sed ' s/:/\n/g' ) -type f -executable -name ' git-clang-format*' ) ; do
7+ cur_name=" $( basename " $file " | sed ' s/^git-//' ) "
8+ cur_version=" $( " $cur_name " --version | awk ' {print $3}' ) "
9+
10+ if [ " $( printf ' %s\n' " $cur_version " " $version " | sort -V | tail -n 1) " = " $cur_version " ]; then
11+ version=" $cur_version "
12+ name=" $cur_name "
13+ fi
14+ done
15+
16+ if [ -z " $name " ]; then
17+ echo " Could not find a suitable clang-format installation. Install clang-format with at least version $version "
18+ exit 1
19+ fi
20+
21+ changed_files=" $( git " $name " --extensions cpp,h --style file --staged -- ' :!src/FreeRTOS' ' :!src/libs' ) "
22+
23+ echo " $changed_files "
24+
25+ echo " $changed_files " | tail -n +2 | while read -r file; do
726 git add -- " $file "
827done
You can’t perform that action at this time.
0 commit comments