Last active
October 2, 2015 07:58
-
-
Save vishvananda/2206428 to your computer and use it in GitHub Desktop.
Script for backporting OpenStack branches
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
#!/usr/bin/env bash | |
# This little script is to make backporting patches easier. | |
# Instructions | |
# ------------ | |
# Make sure that <btranch> exists: | |
# git branch -D <branch> | |
# git checkout -b <branch> origin/<branch> | |
# Grab the file and stick it in your <project> directory: | |
# curl -OL https://raw.github.com/gist/2206428/bp.sh | |
# Make sure the script is runnable: | |
# chmod 755 bp.sh | |
# Start backporting reviews: | |
# ./bp.sh <review_number> | |
# Recovering from errors | |
# ---------------------- | |
# If your branch fails to merge cleanly it is usually due to | |
# a dependent branch not being in yet. In that case your best bet | |
# is to wait for the dependent branch to merge and rerun the script. | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <review_number> [branch]" | |
echo " review_number: numeric review number from gerrit" | |
echo " branch: target gerrit branch (defaults to milestone-proposed)" | |
exit 1 | |
fi | |
BRANCH=${2-milestone-proposed} | |
git checkout $BRANCH | |
git pull | |
git branch -D bp-$1 | |
git checkout -b bp-$1 | |
git review -X $1 | |
git review $BRANCH | |
REMOTE=`git remote show gerrit -n | grep Fetch | cut -d'/' -f3` | |
PORT=`echo $REMOTE | cut -d':' -f2` | |
HOST=`echo $REMOTE | cut -d':' -f1` | |
SHA=`git rev-parse HEAD` | |
echo "Use the following line to approve the review" | |
echo "ssh -p $PORT $HOST gerrit review --code-review +2 --approved +1 $SHA" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment