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 38
38
echo -e " \n\n $GIT_STATUS_CONSIDER_CLEAN_MSG .\e[0m\n"
39
39
fi
40
40
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
-
52
41
ok_to_push=1
53
42
54
43
current_branch=` git branch | grep " ^* " | cut -d ' ' -f 2`
44
+ git branch -r | grep " ^ *origin/$current_branch $" 2>&1 > /dev/null
45
+ have_remote=$?
55
46
56
- if [ " $current_branch " != " master " ]
47
+ if [ $have_remote -eq 0 ]
57
48
then
58
- echo " Current branch is ' $current_branch ', not 'master'. "
49
+ base_ref= " origin/ $current_branch "
59
50
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."
61
64
fi
62
65
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; }' `
64
67
65
68
echo $commits_to_push | grep " [^ ]" >& /dev/null
66
69
status_code=$?
73
76
trap ctrl_c INT
74
77
75
78
function ctrl_c() {
76
- git checkout master >& /dev/null
79
+ git checkout $current_branch >& /dev/null
77
80
78
81
exit 1
79
82
}
115
118
echo " Pre-commit quality testing for '$commit_hash ' passed successfully"
116
119
done
117
120
118
- git checkout master >& /dev/null
121
+ git checkout $current_branch >& /dev/null
119
122
120
123
echo
121
124
echo " Pre-commit testing passed successfully"
128
131
echo " Pushing..."
129
132
echo
130
133
131
- git push origin master # refs/notes/*
134
+ git push -u origin $current_branch
132
135
status_code=$?
133
136
134
137
if [ $status_code -eq 0 ]
You can’t perform that action at this time.
0 commit comments