mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
project: Add pre-commit hook for clang-format
Automatically reformats the code before committing any changes using clang-format, to ensure that there are no additional reformatting commits needed in the future. This requires clang-format to be globally available to git, either through path or by directly being in the git bash directory. The hook will only run if a developer actually installs it with install.sh.
This commit is contained in:
parent
be4d42312d
commit
b34c880f88
2 changed files with 15 additions and 0 deletions
7
.hooks/pre-commit/clang-format.sh
Normal file
7
.hooks/pre-commit/clang-format.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
if ! hash clang-format 2>/dev/null; then
|
||||
echo "'clang-format' must be installed in a global environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find ./source -type f -name "*.h" -or -name "*.hpp" -or -name "*.c" -or -name "*.cpp" -exec clang-format -i '{}' \;
|
8
install.sh
Normal file
8
install.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
readarray -t hooks < <(find .hooks/ -maxdepth 1 -type d -not -wholename .hooks/ -print0)
|
||||
for v in "${hooks[@]}"; do
|
||||
hookname=`basename $v`
|
||||
echo "#!/bin/bash" > .git/hooks/${hookname}
|
||||
echo "find .hooks/${hookname}/ -type f -name '*.sh' -exec '{}' \;" >> .git/hooks/${hookname}
|
||||
done
|
Loading…
Reference in a new issue