From ecca76ea6ea1bff107f4b853bdc8131111c88aa4 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 30 Mar 2015 13:37:55 -0700 Subject: [PATCH] no need for fetch, handle failed backports --- git/githelpers | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/git/githelpers b/git/githelpers index 01d55fb..ca3894d 100644 --- a/git/githelpers +++ b/git/githelpers @@ -111,7 +111,15 @@ backport_pr() { 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 + git checkout ${BRANCH} && git pull ${REMOTE} ${BRANCH} && curl -s "https://github.com/elastic/kibana/pull/${PR}.patch" | git am + + # if the backport couldn't be cleanly applied, tell the user and exit + if [ $? -ne 0 ]; then + echo "FAILED - Backport could not be cleanly applied!" + echo "FAILED - Fix by hand or run 'git am --abort'" + exit 2 + fi + + # switch back if we didn't start in the target branch [ "$THISBRANCH" != "$BRANCH" ] && git checkout - }