From 954e67906e3a05970d431f7c2f829aa48aa800b6 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Mon, 17 Oct 2016 12:03:50 -0700 Subject: [PATCH] hack/: update cherry-pick script to have settings to override remote names Signed-off-by: Jess Frazelle --- hack/cherry_pick_pull.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hack/cherry_pick_pull.sh b/hack/cherry_pick_pull.sh index f320185f6be..cd60edba692 100755 --- a/hack/cherry_pick_pull.sh +++ b/hack/cherry_pick_pull.sh @@ -29,6 +29,8 @@ cd "${KUBE_ROOT}" declare -r STARTINGBRANCH=$(git symbolic-ref --short HEAD) declare -r REBASEMAGIC="${KUBE_ROOT}/.git/rebase-apply" DRY_RUN=${DRY_RUN:-""} +UPSTREAM_REMOTE=${UPSTREAM_REMOTE:-upstream} +FORK_REMOTE=${FORK_REMOTE:-origin} if [[ -z ${GITHUB_USER:-} ]]; then echo "Please export GITHUB_USER= (or GH organization, if that's where your fork lives)" @@ -51,6 +53,9 @@ if [[ "$#" -lt 2 ]]; then echo " Set the DRY_RUN environment var to skip git push and creating PR." echo " This is useful for creating patches to a release branch without making a PR." echo " When DRY_RUN is set the script will leave you in a branch containing the commits you cherry-picked." + echo + echo " Set UPSTREAM_REMOTE (default: upstream) and FORK_REMOTE (default: origin)" + echo " To override the default remote names to what you have locally." exit 2 fi @@ -73,10 +78,10 @@ declare -r PULLDASH=$(join - "${PULLS[@]/#/#}") # Generates something like "#123 declare -r PULLSUBJ=$(join " " "${PULLS[@]/#/#}") # Generates something like "#12345 #56789" echo "+++ Updating remotes..." -git remote update upstream origin +git remote update "${UPSTREAM_REMOTE}" "${FORK_REMOTE}" 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 "!!! '${BRANCH}' not found. The second argument should be something like ${UPSTREAM_REMOTE}/release-0.21." echo " (In particular, it needs to be a valid, existing remote branch that I can 'git checkout'.)" exit 1 fi @@ -186,15 +191,16 @@ if [[ -n "${DRY_RUN}" ]]; then exit 0 fi -if git remote -v | grep ^origin | grep kubernetes/kubernetes.git; then - echo "!!! You have 'origin' configured as your kubernetes/kubernetes.git" +if git remote -v | grep ^${FORK_REMOTE} | grep kubernetes/kubernetes.git; then + echo "!!! You have ${FORK_REMOTE} configured as your kubernetes/kubernetes.git" echo "This isn't normal. Leaving you with push instructions:" echo echo "+++ First manually push the branch this script created:" echo echo " git push REMOTE ${NEWBRANCHUNIQ}:${NEWBRANCH}" echo - echo "where REMOTE is your personal fork (maybe 'upstream'? Consider swapping those.)." + echo "where REMOTE is your personal fork (maybe ${UPSTREAM_REMOTE}? Consider swapping those.)." + echo "OR consider setting UPSTREAM_REMOTE and FORK_REMOTE to different values." echo make-a-pr cleanbranch="" @@ -202,9 +208,9 @@ if git remote -v | grep ^origin | grep kubernetes/kubernetes.git; then fi echo -echo "+++ I'm about to do the following to push to GitHub (and I'm assuming origin is your personal fork):" +echo "+++ I'm about to do the following to push to GitHub (and I'm assuming ${FORK_REMOTE} is your personal fork):" echo -echo " git push origin ${NEWBRANCHUNIQ}:${NEWBRANCH}" +echo " git push ${FORK_REMOTE} ${NEWBRANCHUNIQ}:${NEWBRANCH}" echo read -p "+++ Proceed (anything but 'y' aborts the cherry-pick)? [y/n] " -r if ! [[ "${REPLY}" =~ ^[yY]$ ]]; then @@ -212,5 +218,5 @@ if ! [[ "${REPLY}" =~ ^[yY]$ ]]; then exit 1 fi -git push origin -f "${NEWBRANCHUNIQ}:${NEWBRANCH}" +git push "${FORK_REMOTE}" -f "${NEWBRANCHUNIQ}:${NEWBRANCH}" make-a-pr