File tree Expand file tree Collapse file tree 1 file changed +21
-18
lines changed
Expand file tree Collapse file tree 1 file changed +21
-18
lines changed Original file line number Diff line number Diff line change 3838 echo -e " \n\n $GIT_STATUS_CONSIDER_CLEAN_MSG .\e[0m\n"
3939fi
4040
41- echo " Pulling..."
42-
43- make pull
44- status_code=$?
45-
46- if [ $status_code -ne 0 ]
47- then
48- echo " Pull failed"
49- exit 1
50- fi
51-
5241ok_to_push=1
5342
5443current_branch=` git branch | grep " ^* " | cut -d ' ' -f 2`
44+ git branch -r | grep " ^ *origin/$current_branch $" 2>&1 > /dev/null
45+ have_remote=$?
5546
56- if [ " $current_branch " != " master " ]
47+ if [ $have_remote -eq 0 ]
5748then
58- echo " Current branch is ' $current_branch ', not 'master'. "
49+ base_ref= " origin/ $current_branch "
5950
60- exit 1
51+ echo " Pulling..."
52+
53+ make pull
54+ status_code=$?
55+
56+ if [ $status_code -ne 0 ]
57+ then
58+ echo " Pull failed"
59+ exit 1
60+ fi
61+ else
62+ base_ref=` git merge-base master $current_branch `
63+ [ $? -eq 0 ] || echo " Cannot determine merge-base for '$current_branch ' and 'master' branches."
6164fi
6265
63- commits_to_push=` git log origin/master..master | grep " ^commit [0-9a-f]*$" | awk ' BEGIN { s = ""; } { s = $2" "s; } END { print s; }' `
66+ commits_to_push=` git log $base_ref .. $current_branch | grep " ^commit [0-9a-f]*$" | awk ' BEGIN { s = ""; } { s = $2" "s; } END { print s; }' `
6467
6568echo $commits_to_push | grep " [^ ]" >& /dev/null
6669status_code=$?
7376trap ctrl_c INT
7477
7578function ctrl_c() {
76- git checkout master >& /dev/null
79+ git checkout $current_branch >& /dev/null
7780
7881 exit 1
7982}
115118 echo " Pre-commit quality testing for '$commit_hash ' passed successfully"
116119done
117120
118- git checkout master >& /dev/null
121+ git checkout $current_branch >& /dev/null
119122
120123echo
121124echo " Pre-commit testing passed successfully"
128131 echo " Pushing..."
129132 echo
130133
131- git push origin master # refs/notes/*
134+ git push -u origin $current_branch
132135 status_code=$?
133136
134137 if [ $status_code -eq 0 ]
You can’t perform that action at this time.
0 commit comments