Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
43 additions
and 40 deletions.
- +1 −1 .gitignore
- +1 −1 format.bat
- BIN hooks/{AStyleWhore.exe → AStyleHelper.exe}
- +6 −3 hooks/{AStyleWhore.exe.config → AStyleHelper.exe.config}
- +2 −2 hooks/README.md
- +33 −33 hooks/pre-commit
@@ -1,2 +1,2 @@ | ||
@echo off | ||
hooks\AStyleWhore.exe Silent | ||
hooks\AStyleHelper.exe Silent |
Binary file not shown.
@@ -1,5 +1,5 @@ | ||
# hooks | ||
|
||
This contains two binaries `AStyleWhore.exe` and `AStyle.dll` to format any code before you commit. | ||
This contains two binaries `AStyleHelper.exe` and `AStyle.dll` to format any code before you commit. | ||
|
||
If you are unsure about the integrity of the files, don't hesitate to contact me (mrexodia). The source code is available at [BitBucket](https://bitbucket.org/mrexodia/astylewhore). The version of `AStyle.dll` is compiled from `AStyle_2.06_windows.zip` which came from [Sourceforge](https://sourceforge.net/projects/astyle/files/astyle/astyle%202.06/AStyle_2.06_windows.zip/download). | ||
If you are unsure about the integrity of the files, don't hesitate to contact me (mrexodia). The source code is available [here](https://github.com/mrexodia/AStyleHelper). The version of `AStyle.dll` is compiled from `AStyle_2.06_windows.zip` which came from [Sourceforge](https://sourceforge.net/projects/astyle/files/astyle/astyle%202.06/AStyle_2.06_windows.zip/download). |
@@ -1,33 +1,33 @@ | ||
#!/bin/sh | ||
# | ||
# Simple script to auto-format every source file before committing. | ||
# | ||
|
||
#check if the formatter is present | ||
if [ ! -f ./hooks/AStyleWhore.exe ]; then | ||
echo "AStyleWhore not found!" | ||
exit 0 | ||
fi | ||
|
||
#format the code | ||
"./hooks/AStyleWhore.exe" Silent | ||
|
||
#exit when nothing needs to be done | ||
if [ $? == 0 ]; then | ||
exit 0 | ||
fi | ||
|
||
#stage the formatted files (when staged in this commit) | ||
gitFiles=$(git diff-index --name-only --cached HEAD) | ||
if [[ -n "${gitFiles}" ]]; then | ||
for fname in $gitFiles; do | ||
git add --all -- "${fname}" | ||
done | ||
fi | ||
|
||
#cancel commit if the changes were undone by the formatting | ||
gitFiles=$(git diff-index --name-only --cached HEAD) | ||
if [ -z "$gitFiles" ]; then | ||
"./hooks/AStyleWhore.exe" "After formatting, no files were staged..." | ||
exit 1 | ||
fi | ||
#!/bin/sh | ||
# | ||
# Simple script to auto-format every source file before committing. | ||
# | ||
|
||
#check if the formatter is present | ||
if [ ! -f ./hooks/AStyleHelper.exe ]; then | ||
echo "AStyleHelper not found!" | ||
exit 0 | ||
fi | ||
|
||
#format the code | ||
"./hooks/AStyleHelper.exe" Silent | ||
|
||
#exit when nothing needs to be done | ||
if [ $? == 0 ]; then | ||
exit 0 | ||
fi | ||
|
||
#stage the formatted files (when staged in this commit) | ||
gitFiles=$(git diff-index --name-only --cached HEAD) | ||
if [[ -n "${gitFiles}" ]]; then | ||
for fname in $gitFiles; do | ||
git add --all -- "${fname}" | ||
done | ||
fi | ||
|
||
#cancel commit if the changes were undone by the formatting | ||
gitFiles=$(git diff-index --name-only --cached HEAD) | ||
if [ -z "$gitFiles" ]; then | ||
"./hooks/AStyleHelper.exe" "After formatting, no files were staged..." | ||
exit 1 | ||
fi |