-
-
Save slackorama/1078627 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# hack -- create a branch for a bz ticket off of whatever branch you are | |
# currently in or the branch you pass in as an argument | |
bug=$1 | |
base=$2 | |
if [ -z "${bug}" ] || [ "${bug}" == "-?" ] ; then | |
echo "Usage: hack [BZTICKET]" | |
exit 1 | |
fi | |
if ! echo $bug | egrep -q "^bugfix/bz" ; then | |
bug=bugfix/bz${bug} | |
fi | |
if [ -z "$base" ]; then | |
current=`git branch | awk '/\*/{print $2}'` | |
remote=`git config --get branch.$current.remote` | |
git fetch -q $remote | |
git checkout -b ${bug} $remote/$current | |
else | |
remote=`git config --get branch.$base.remote` | |
if [ -z "$remote" ]; then | |
echo "No remote found for $base" >&2; | |
exit 1; | |
fi | |
git remote update $remote | |
git checkout -b ${bug} $remote/$base | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment