Skip to content

Commit ecbc285

Browse files
Support 'make push' for non-master branches.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
1 parent 5c76b3f commit ecbc285

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

tools/git-scripts/push.sh

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,38 @@ then
3838
echo -e "\n\n $GIT_STATUS_CONSIDER_CLEAN_MSG.\e[0m\n"
3939
fi
4040

41-
echo "Pulling..."
41+
ok_to_push=1
4242

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=$?
4546

46-
if [ $status_code -ne 0 ]
47+
if [ $have_remote -eq 0 ]
4748
then
48-
echo "Pull failed"
49-
exit 1
50-
fi
49+
base_ref="origin/$current_branch"
5150

52-
ok_to_push=1
51+
echo "Pulling..."
5352

54-
current_branch=`git branch | grep "^* " | cut -d ' ' -f 2`
53+
make pull
54+
status_code=$?
5555

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=$?
5964

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
6170
fi
6271

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; }'`
6473

6574
echo $commits_to_push | grep "[^ ]" >&/dev/null
6675
status_code=$?
@@ -73,7 +82,7 @@ fi
7382
trap ctrl_c INT
7483

7584
function ctrl_c() {
76-
git checkout master >&/dev/null
85+
git checkout $current_branch >&/dev/null
7786

7887
exit 1
7988
}
@@ -115,7 +124,7 @@ do
115124
echo "Pre-commit quality testing for '$commit_hash' passed successfully"
116125
done
117126

118-
git checkout master >&/dev/null
127+
git checkout $current_branch >&/dev/null
119128

120129
echo
121130
echo "Pre-commit testing passed successfully"
@@ -128,7 +137,7 @@ then
128137
echo "Pushing..."
129138
echo
130139

131-
git push origin master # refs/notes/*
140+
git push -u origin $current_branch
132141
status_code=$?
133142

134143
if [ $status_code -eq 0 ]

0 commit comments

Comments
 (0)