add backporting git alias

This commit is contained in:
2015-03-25 16:13:37 -07:00
parent 556aa15bfa
commit 1da19cd5ab
2 changed files with 22 additions and 1 deletions

View File

@@ -87,4 +87,23 @@ clean_branches() {
for i in ${BRANCHES}; do
git branch -d $i
done
}
}
backport_pr() {
PR=$1
BRANCH=$2
[ -z "$BRANCH" ] && BRANCH=`git rev-parse --abbrev-ref HEAD`
REMOTE=$3
: ${REMOTE:=$DEFAULT_REMOTE}
THISBRANCH=`git rev-parse --abbrev-ref HEAD`
if [ -z "$PR" ]; then
echo "Please specify a PR to backport"
exit 1
fi
echo Backporting ${PR} to ${BRANCH} from ${REMOTE}
git fetch ${REMOTE} pull/${1}/head:pr/${1}
git checkout ${BRANCH} && curl -s "https://github.com/elastic/kibana/pull/${PR}.patch" | git am
[ "$THISBRANCH" != "$BRANCH" ] && git checkout -
}