Merge pull request #10965 from zmerlynn/trappy

Fix two issues in cherry_pick_pull.sh
pull/6/head
Zach Loafman 2015-07-08 18:17:16 -07:00
commit fb52d1e93e
1 changed files with 14 additions and 4 deletions

View File

@ -29,7 +29,11 @@ declare -r STARTINGBRANCH=$(git symbolic-ref --short HEAD)
declare -r REBASEMAGIC="${KUBE_ROOT}/.git/rebase-apply" declare -r REBASEMAGIC="${KUBE_ROOT}/.git/rebase-apply"
if [[ "$#" -ne 2 ]]; then if [[ "$#" -ne 2 ]]; then
echo "${0} <pr-number> <branch>: cherry pick <pr> onto <branch> and leave instructions for proposing pull request" echo "${0} <pr-number> <remote branch>: cherry pick <pr> onto <remote branch> and leave instructions for proposing pull request"
echo ""
echo " Checks out <remote branch> and handles the cherry-pick of <pr> for you."
echo " Example:"
echo " $0 12345 upstream/release-3.14"
exit 2 exit 2
fi fi
@ -48,6 +52,12 @@ declare -r BRANCH="${2}"
echo "+++ Updating remotes..." echo "+++ Updating remotes..."
git remote update git remote update
if ! git log -n1 --format=%H "${BRANCH}" >/dev/null 2>&1; then
echo "!!! '${BRANCH}' not found. The second argument should be something like upstream/release-0.21."
echo " (In particular, it needs to be a valid, existing remote branch that I can 'git checkout'.)"
exit 1
fi
echo "+++ Downloading patch to /tmp/${PULL}.patch (in case you need to do this again)" echo "+++ Downloading patch to /tmp/${PULL}.patch (in case you need to do this again)"
curl -o "/tmp/${PULL}.patch" -sSL "https://github.com/GoogleCloudPlatform/kubernetes/pull/${PULL}.patch" curl -o "/tmp/${PULL}.patch" -sSL "https://github.com/GoogleCloudPlatform/kubernetes/pull/${PULL}.patch"
@ -62,11 +72,11 @@ function return_to_kansas {
echo "" echo ""
echo "+++ Returning you to the ${STARTINGBRANCH} branch and cleaning up." echo "+++ Returning you to the ${STARTINGBRANCH} branch and cleaning up."
if [[ "${gitamcleanup}" == "true" ]]; then if [[ "${gitamcleanup}" == "true" ]]; then
git am --abort >/dev/null git am --abort >/dev/null 2>&1 || true
fi fi
git checkout -f "${STARTINGBRANCH}" >/dev/null git checkout -f "${STARTINGBRANCH}" >/dev/null 2>&1 || true
if [[ -n "${cleanbranch}" ]]; then if [[ -n "${cleanbranch}" ]]; then
git branch -D "${cleanbranch}" >/dev/null git branch -D "${cleanbranch}" >/dev/null 2>&1 || true
fi fi
} }
trap return_to_kansas EXIT trap return_to_kansas EXIT