Created
September 19, 2011 17:07
-
-
Save terrycojones/1226965 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x -e | |
# update master first | |
git checkout master | |
git pull upstream master | |
git push origin master | |
REVIEW_BRANCH_NAME=_reviewbranch | |
PREREQUISITE_BRANCH_NAME=_prerequisite | |
case $# in | |
1) BRANCH="$1";; | |
2) BRANCH="$1"; PREREQUISITE="$2";; | |
*) echo "Usage: `basename $0` branch [prerequisite]" >&2; exit 1;; | |
esac | |
parts=($(echo "$BRANCH"|tr : '\n')) | |
BRANCH_REMOTE=${parts[0]} | |
BRANCH_NAME=${parts[1]} | |
# delete previous review branches | |
git branch -D $REVIEW_BRANCH_NAME | true | |
git branch -D $PREREQUISITE_BRANCH_NAME | true | |
git fetch $BRANCH_REMOTE $BRANCH_NAME:$REVIEW_BRANCH_NAME | |
if [ $PREREQUISITE ] | |
then | |
parts=($(echo "$PREREQUISITE"|tr : '\n')) | |
PREREQUISITE_REMOTE=${parts[0]} | |
PREREQUISITE_NAME=${parts[1]} | |
git fetch $PREREQUISITE_REMOTE $PREREQUISITE_NAME:$PREREQUISITE_BRANCH_NAME | |
REBASE_BRANCH=$PREREQUISITE_BRANCH_NAME | |
else | |
REBASE_BRANCH=master | |
fi | |
# checkout to the new branch and rebase | |
git checkout $REVIEW_BRANCH_NAME | |
git rebase $REBASE_BRANCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment