Skip to content

Commit 1af9d6f

Browse files
Support 'make push' for non-master branches.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
1 parent 5c76b3f commit 1af9d6f

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

tools/git-scripts/push.sh

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,32 @@ then
3838
echo -e "\n\n $GIT_STATUS_CONSIDER_CLEAN_MSG.\e[0m\n"
3939
fi
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-
5241
ok_to_push=1
5342

5443
current_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 ]
5748
then
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."
6164
fi
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

6568
echo $commits_to_push | grep "[^ ]" >&/dev/null
6669
status_code=$?
@@ -73,7 +76,7 @@ fi
7376
trap ctrl_c INT
7477

7578
function ctrl_c() {
76-
git checkout master >&/dev/null
79+
git checkout $current_branch >&/dev/null
7780

7881
exit 1
7982
}
@@ -115,7 +118,7 @@ do
115118
echo "Pre-commit quality testing for '$commit_hash' passed successfully"
116119
done
117120

118-
git checkout master >&/dev/null
121+
git checkout $current_branch >&/dev/null
119122

120123
echo
121124
echo "Pre-commit testing passed successfully"
@@ -128,7 +131,7 @@ then
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 ]

0 commit comments

Comments
 (0)