-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclang-bang
executable file
·31 lines (28 loc) · 995 Bytes
/
clang-bang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
dirty=0
if [[ $(git diff --stat) != '' ]]; then
dirty=1
fi
echo -n "Clang..."
if [[ $# -ne 0 ]] ;
then
clang-format-6.0 -style=file -i "$@"
else
find . \( -iname \*.c -o -iname \*.h -o -iname \*.hpp -o -iname \*.cpp -o -iname \*.cl \) -not -path '*build/*' -not -path '*tools/*' -not -path '*third_party/*' -not -path '*packs/*' -not -path '*config/*' -not -path '*_bsp/*' -print0 | xargs -P $(nproc) -0 -n 4 clang-format-6.0 -style=file -i
fi
echo -n "BANG!"
if [[ $(git diff --stat) == '' ]]; then
echo " made no changes to versioned files."
elif [[ $dirty -eq 0 ]]; then
echo ""
# Clang bang changes can be committed automatically
read -n 1 -r -p "Automatically add and commit clang-bang changes (Y/n)?" choice
if [[ $choice =~ ^(y|Y| ) ]] || [[ -z $choice ]]; then
echo ""
echo "Committing clang-bang changes"
git commit -a -m "Clang-bang commit"
fi
else
echo ""
echo "Git reports that working copy is DIRTY. Commit changes manually."
fi