Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'make push' for non-master branches #75

Merged
merged 1 commit into from
May 18, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions tools/git-scripts/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,38 @@ then
echo -e "\n\n $GIT_STATUS_CONSIDER_CLEAN_MSG.\e[0m\n"
fi

echo "Pulling..."
ok_to_push=1

make pull
status_code=$?
current_branch=`git branch | grep "^* " | cut -d ' ' -f 2`
git branch -r | grep "^ *origin/$current_branch$" 2>&1 > /dev/null
have_remote=$?

if [ $status_code -ne 0 ]
if [ $have_remote -eq 0 ]
then
echo "Pull failed"
exit 1
fi
base_ref="origin/$current_branch"

ok_to_push=1
echo "Pulling..."

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

if [ "$current_branch" != "master" ]
then
echo "Current branch is '$current_branch', not 'master'."
if [ $status_code -ne 0 ]
then
echo "Pull failed"
exit 1
fi
else
base_ref=`git merge-base master $current_branch`
status_code=$?

exit 1
if [ $status_code -ne 0 ]
then
echo "Cannot determine merge-base for '$current_branch' and 'master' branches."
exit 1
fi
fi

commits_to_push=`git log origin/master..master | grep "^commit [0-9a-f]*$" | awk 'BEGIN { s = ""; } { s = $2" "s; } END { print s; }'`
commits_to_push=`git log $base_ref..$current_branch | grep "^commit [0-9a-f]*$" | awk 'BEGIN { s = ""; } { s = $2" "s; } END { print s; }'`

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

function ctrl_c() {
git checkout master >&/dev/null
git checkout $current_branch >&/dev/null

exit 1
}
Expand Down Expand Up @@ -115,7 +124,7 @@ do
echo "Pre-commit quality testing for '$commit_hash' passed successfully"
done

git checkout master >&/dev/null
git checkout $current_branch >&/dev/null

echo
echo "Pre-commit testing passed successfully"
Expand All @@ -128,7 +137,7 @@ then
echo "Pushing..."
echo

git push origin master # refs/notes/*
git push -u origin $current_branch
status_code=$?

if [ $status_code -eq 0 ]
Expand Down