Last active
January 16, 2017 11:30
-
-
Save ricardopereira/56cbad03abe8c46c740a9a747b1f6b11 to your computer and use it in GitHub Desktop.
iOS pre-commit sample
This file contains 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
#!/usr/bin/env bash | |
set -eu | |
if git diff-index -p -M --cached HEAD -- '*.xib' '*.storyboard' | grep '^+' | egrep 'misplaced="YES"' >/dev/null 2>&1 | |
then | |
echo "COMMIT REJECTED because it contains misplaced views; please correct them before committing." | |
exit 1 | |
fi | |
if git diff-index -p -M --cached HEAD -- '*.swift' | grep '^+' | egrep 'TEST' >/dev/null 2>&1 | |
then | |
echo "COMMIT REJECTED because it contains code marked as TEST; please correct them before committing." | |
exit 1 | |
fi | |
if git diff-index -p -M --cached HEAD -- '*Specs.swift' | grep '^+' | egrep '(fdescribe|fit|fcontext|xdescribe|xit|xcontext)' >/dev/null 2>&1 | |
then | |
echo "COMMIT REJECTED because it contains fdescribe/fit/fcontext/xdescribe/xit/xcontext; please remove focused and disabled tests before committing." | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment