forked from krzysztofzablocki/Sourcery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit.sh
More file actions
executable file
·28 lines (23 loc) · 885 Bytes
/
Copy pathpre-commit.sh
File metadata and controls
executable file
·28 lines (23 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -eu
failed=0
test_pattern='\b(fdescribe|fit|fcontext|xdescribe|xit|xcontext)\b'
if git diff-index -p -M --cached HEAD -- '*Tests.swift' '*Specs.swift' | grep '^+' | egrep "$test_pattern" >/dev/null 2>&1
then
echo "COMMIT REJECTED for fdescribe/fit/fcontext/xdescribe/xit/xcontext." >&2
echo "Remove focused and disabled tests before committing." >&2
echo '----' >&2
git grep --cached -E "$test_pattern" '*Tests.swift' '*Specs.swift' >&2
echo '----' >&2
failed=1
fi
misplaced_pattern='misplaced="YES"'
if git diff-index -p -M --cached HEAD -- '*.xib' '*.storyboard' | grep '^+' | egrep "$misplaced_pattern" >/dev/null 2>&1
then
echo "COMMIT REJECTED for misplaced views. Correct them before committing." >&2
echo '----' >&2
git grep --cached -E "$misplaced_pattern" '*.xib' '*.storyboard' >&2
echo '----' >&2
failed=1
fi
exit $failed