Skip to content

Instantly share code, notes, and snippets.

@slackorama
Created July 12, 2011 18:33
Show Gist options
  • Save slackorama/1078628 to your computer and use it in GitHub Desktop.
Save slackorama/1078628 to your computer and use it in GitHub Desktop.
#!/bin/bash
# fix the issue by pushing the current branch to the remote named origin
# if the branch isn't named "bugfix/bz[0-9]+ then fail
# inspired by http://reinh.com/blog/2008/08/27/hack-and-and-ship.html
current=`git branch | awk '/\*/{print $2}'`
if ! echo "$current" | egrep -q "^bugfix/bz[0-9]+" ; then
echo "Not in a bugfix branch. Must be named bugfix/bz[0-9]+"
exit 1
fi
# get the remote branch first
remote=`git config --get-regexp branch.${current}.remote | awk '{print $2}'`
if [ -z "${remote}" ]; then
echo "$current is not tracking a branch"
exit 1
else
track=`git config --get-regexp branch.${current}.merge \
| awk '{print $2}' | sed 's/refs\/heads\///'`
if [ -z "${track}" ]; then
echo "No merge point for remote"
exit 1
fi
git fetch -q ${remote} ${track}
# now rebase it
git rebase ${remote}/${track} >/dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "Rebase failed. Check to see what went wrong then manually push:"
echo " git push ${remote} ${current}:${current}"
echo " "
echo "Then run: submit-merge rc"
exit 1
fi
git push -q ${remote} ${current}:${current}
$HOME/cm_fusion/utils/submit-merge "$@" rc
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment