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/bash
2+ if clang-format --version | grep -q ' version 11\.' ; then
3+ CLANG_FORMAT_EXECUTABLE=" clang-format"
4+ else
5+ CLANG_FORMAT_EXECUTABLE=" clang-format-11"
6+ fi
7+
28for FILE in $( git diff --cached --name-only)
39do
410 if [[ " $FILE " =~ src/[A-Za-z0-9\ \- ]+* \. (c| h| cpp| cc)$ ]]; then
5- echo Autoformatting $FILE with clang-format
6- clang-format-11 -style=file -i -- $FILE
11+ echo Autoformatting $FILE with $CLANG_FORMAT_EXECUTABLE
12+ $CLANG_FORMAT_EXECUTABLE -style=file -i -- $FILE
713 git add -- $FILE
814 elif [[ " $FILE " =~ src/(components| displayapp| drivers| heartratetask| logging| systemtask)/.* \. (c| h| cpp| cc)$ ]]; then
9- echo Autoformatting $FILE with clang-format
10- clang-format-11 -style=file -i -- $FILE
15+ echo Autoformatting $FILE with $CLANG_FORMAT_EXECUTABLE
16+ $CLANG_FORMAT_EXECUTABLE -style=file -i -- $FILE
1117 git add -- $FILE
1218 fi
1319done
You can’t perform that action at this time.
0 commit comments