|
38 | 38 | echo -e "\n\n $GIT_STATUS_CONSIDER_CLEAN_MSG.\e[0m\n"
|
39 | 39 | fi
|
40 | 40 |
|
41 |
| -echo "Pulling..." |
| 41 | +ok_to_push=1 |
42 | 42 |
|
43 |
| -make pull |
44 |
| -status_code=$? |
| 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=$? |
45 | 46 |
|
46 |
| -if [ $status_code -ne 0 ] |
| 47 | +if [ $have_remote -eq 0 ] |
47 | 48 | then
|
48 |
| - echo "Pull failed" |
49 |
| - exit 1 |
50 |
| -fi |
| 49 | + base_ref="origin/$current_branch" |
51 | 50 |
|
52 |
| -ok_to_push=1 |
| 51 | + echo "Pulling..." |
53 | 52 |
|
54 |
| -current_branch=`git branch | grep "^* " | cut -d ' ' -f 2` |
| 53 | + make pull |
| 54 | + status_code=$? |
55 | 55 |
|
56 |
| -if [ "$current_branch" != "master" ] |
57 |
| -then |
58 |
| - echo "Current branch is '$current_branch', not 'master'." |
| 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 | + status_code=$? |
59 | 64 |
|
60 |
| - exit 1 |
| 65 | + if [ $status_code -ne 0 ] |
| 66 | + then |
| 67 | + echo "Cannot determine merge-base for '$current_branch' and 'master' branches." |
| 68 | + exit 1 |
| 69 | + fi |
61 | 70 | fi
|
62 | 71 |
|
63 |
| -commits_to_push=`git log origin/master..master | grep "^commit [0-9a-f]*$" | awk 'BEGIN { s = ""; } { s = $2" "s; } END { print s; }'` |
| 72 | +commits_to_push=`git log $base_ref..$current_branch | grep "^commit [0-9a-f]*$" | awk 'BEGIN { s = ""; } { s = $2" "s; } END { print s; }'` |
64 | 73 |
|
65 | 74 | echo $commits_to_push | grep "[^ ]" >&/dev/null
|
66 | 75 | status_code=$?
|
|
73 | 82 | trap ctrl_c INT
|
74 | 83 |
|
75 | 84 | function ctrl_c() {
|
76 |
| - git checkout master >&/dev/null |
| 85 | + git checkout $current_branch >&/dev/null |
77 | 86 |
|
78 | 87 | exit 1
|
79 | 88 | }
|
|
115 | 124 | echo "Pre-commit quality testing for '$commit_hash' passed successfully"
|
116 | 125 | done
|
117 | 126 |
|
118 |
| -git checkout master >&/dev/null |
| 127 | +git checkout $current_branch >&/dev/null |
119 | 128 |
|
120 | 129 | echo
|
121 | 130 | echo "Pre-commit testing passed successfully"
|
|
128 | 137 | echo "Pushing..."
|
129 | 138 | echo
|
130 | 139 |
|
131 |
| - git push origin master # refs/notes/* |
| 140 | + git push -u origin $current_branch |
132 | 141 | status_code=$?
|
133 | 142 |
|
134 | 143 | if [ $status_code -eq 0 ]
|
|
0 commit comments