File tree Expand file tree Collapse file tree 1 file changed +4
-21
lines changed Expand file tree Collapse file tree 1 file changed +4
-21
lines changed Original file line number Diff line number Diff line change 1
- #! /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
1
+ #! /bin/sh
7
2
8
- if ! command -v $CLANG_FORMAT_EXECUTABLE & > /dev/null
9
- then
10
- echo $CLANG_FORMAT_EXECUTABLE does not exist, make sure to install it
11
- exit 1
12
- fi
3
+ git clang-format --extensions cpp,h --style file --staged -- ' :!src/FreeRTOS' ' :!src/libs'
13
4
14
- for FILE in $( git diff --cached --name-only )
5
+ git diff --name-only --diff-filter=ACMR | while read -r file
15
6
do
16
- if [[ " $FILE " =~ src/[A-Za-z0-9\ \- ]+* \. (c| h| cpp| cc)$ ]]; then
17
- echo Autoformatting $FILE with $CLANG_FORMAT_EXECUTABLE
18
- $CLANG_FORMAT_EXECUTABLE -style=file -i -- $FILE
19
- git add -- $FILE
20
- elif [[ " $FILE " =~ src/(components| displayapp| drivers| heartratetask| logging| systemtask)/.* \. (c| h| cpp| cc)$ ]]; then
21
- echo Autoformatting $FILE with $CLANG_FORMAT_EXECUTABLE
22
- $CLANG_FORMAT_EXECUTABLE -style=file -i -- $FILE
23
- git add -- $FILE
24
- fi
7
+ git add -- " $file "
25
8
done
You can’t perform that action at this time.
0 commit comments