diff --git a/AStyle.dll b/AStyle.dll deleted file mode 100644 index 6ef2091..0000000 Binary files a/AStyle.dll and /dev/null differ diff --git a/AStyleWhore.exe b/AStyleWhore.exe deleted file mode 100644 index 53c3b9e..0000000 Binary files a/AStyleWhore.exe and /dev/null differ diff --git a/format.bat b/format.bat new file mode 100644 index 0000000..00aa3a8 --- /dev/null +++ b/format.bat @@ -0,0 +1,2 @@ +@echo off +hooks\AStyleHelper.exe Silent \ No newline at end of file diff --git a/hooks/AStyle.dll b/hooks/AStyle.dll new file mode 100644 index 0000000..9c2f523 Binary files /dev/null and b/hooks/AStyle.dll differ diff --git a/hooks/AStyleHelper.exe b/hooks/AStyleHelper.exe new file mode 100644 index 0000000..44cfdec Binary files /dev/null and b/hooks/AStyleHelper.exe differ diff --git a/hooks/AStyleHelper.exe.config b/hooks/AStyleHelper.exe.config new file mode 100644 index 0000000..72f3709 --- /dev/null +++ b/hooks/AStyleHelper.exe.config @@ -0,0 +1,25 @@ + + + + +
+ + + + + + + *.c;*.h;*.cpp;*.hpp + + + style=allman, convert-tabs, align-pointer=type, align-reference=middle, indent=spaces, indent-col1-comments, pad-oper, unpad-paren, keep-one-line-blocks, close-templates + + + + + + + + + + diff --git a/hooks/README.md b/hooks/README.md new file mode 100644 index 0000000..10e891b --- /dev/null +++ b/hooks/README.md @@ -0,0 +1,5 @@ +# hooks + +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 [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). \ No newline at end of file diff --git a/hooks/pre-commit b/hooks/pre-commit index 637f3ba..ff4a78f 100644 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,33 +1,33 @@ -#!/bin/sh -# -# Simple script to auto-format every source file before committing. -# - -#check if the formatter is present -if [ ! -f ./AStyleWhore.exe ]; then - echo "AStyleWhore not found!" - exit 0 -fi - -#format the code -"./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 - "./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