-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-push
executable file
·34 lines (31 loc) · 961 Bytes
/
pre-push
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
#!/bin/bash
#
# Place this file named pre-push in .git/hooks
#
# See examples at: http://blog.ittybittyapps.com/blog/2013/09/03/git-pre-push/
#
# git remote add levpoemondo ssh://46.101.221.201/home/ybg/Sites/levpoem/.git
#
# Make sure to perform this config on the remote first:
# git config receive.denyCurrentBranch updateInstead
# See: http://stackoverflow.com/questions/804545/what-is-this-git-warning-message-when-pushing-changes-to-a-remote-repository/28262104#28262104
#
# set -x
CMD="git push --no-verify levpoemondo" # levpoemondo here is the remote branch name
master_branch='master'
# Check if we actually have commits to push
commits=`git log @{u}..`
if [ -z "$commits" ]; then
echo nothing to push
exit 0
fi
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [[ $current_branch = $master_branch ]]; then
$CMD
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "failed $CMD"
exit 1
fi
fi
exit 0