Skip to content

Instantly share code, notes, and snippets.

@ricardopereira
Last active January 16, 2017 11:30
Show Gist options
  • Save ricardopereira/56cbad03abe8c46c740a9a747b1f6b11 to your computer and use it in GitHub Desktop.
Save ricardopereira/56cbad03abe8c46c740a9a747b1f6b11 to your computer and use it in GitHub Desktop.
iOS pre-commit sample
#!/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