Created
April 11, 2018 11:35
-
-
Save Kidde82/22aeb5e76a9ef96867a0c74b051441eb to your computer and use it in GitHub Desktop.
Pre-Commit Hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| TEMPDIR="tmp" | |
| RED=`tput setaf 1` | |
| GREEN=`tput setaf 2` | |
| RESET=`tput sgr0` | |
| rm -rf $TEMPDIR | |
| mkdir -p $TEMPDIR | |
| git checkout-index --prefix=$TEMPDIR/ -af | |
| INCLUDESTR="$(git diff --cached --name-only --diff-filter=ACM | xargs -n 1 -I file echo $TEMPDIR/file | grep .cs | tr '\n' ';')" | |
| INCLUDESTR=${INCLUDESTR//"tmp/"/"*"} | |
| SOLUTIONFILE="$(find ./$TEMPDIR -name *.sln)" | |
| md5sum $TEMPDIR/**/*.* > checklist.chk | |
| echo "${GREEN}Running CleanUpCode-Check${RESET}" | |
| : $(cleanupcode.exe --include="$INCLUDESTR" $SOLUTIONFILE) | |
| MD5ERROR="$(md5sum -c checklist.chk --quiet)" | |
| rm -rf $TEMPDIR | |
| rm checklist.chk | |
| if [ "${#MD5ERROR}" = "0" ] ; then | |
| echo "${GREEN}CleanUpCode-Check passed, continue commit${RESET}" | |
| exit 0 | |
| else | |
| echo "${RED}CleanUpCode-Check failed, aborting commit${RESET}" | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment