-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-push.bash
executable file
·38 lines (30 loc) · 996 Bytes
/
pre-push.bash
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
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Copyright 2013 Canonical Ltd.
# Licensed under the AGPLv3, see LICENCE file for details.
set -e
z40=0000000000000000000000000000000000000000
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]; then
# delete remote branch, no check
exit 0
else
git diff --quiet || (echo "unstaged changes"; exit 1)
git diff --cached --quiet || (echo "uncommitted changes"; exit 1)
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits not on master
range="$local_sha...master"
else
# Update to existing branch, examine new commits
range="$remote_sha...$local_sha"
fi
FILECOUNT=`git log --name-only '--pretty=format:' $range | grep '.go$' | wc -l`
if [ $FILECOUNT -eq 0 ]; then
# no go files changed, skip go validation
exit 0
fi
./scripts/verify.bash
fi
done