Skip to content

Commit

Permalink
Update (and generalize) cherry pick script for client-python
Browse files Browse the repository at this point in the history
  • Loading branch information
mbohlool committed Apr 20, 2017
1 parent 7408d90 commit f567e82
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions scripts/cherry_pick_pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ set -o errexit
set -o nounset
set -o pipefail

declare -r KUBE_ROOT="$(dirname "${BASH_SOURCE}")/.."
cd "${KUBE_ROOT}"
declare -r REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"

declare -r STARTINGBRANCH=$(git symbolic-ref --short HEAD)
declare -r REBASEMAGIC="${KUBE_ROOT}/.git/rebase-apply"
declare -r REBASEMAGIC="${REPO_ROOT}/.git/rebase-apply"
DRY_RUN=${DRY_RUN:-""}
UPSTREAM_REMOTE=${UPSTREAM_REMOTE:-upstream}
FORK_REMOTE=${FORK_REMOTE:-origin}
MAIN_REPO_NAME=${MAIN_REPO_NAME:-"client-python"}
MAIN_REPO_ORG=${MAIN_REPO_ORG:-"kubernetes-incubator"}

if [[ -z ${GITHUB_USER:-} ]]; then
echo "Please export GITHUB_USER=<your-user> (or GH organization, if that's where your fork lives)"
Expand Down Expand Up @@ -135,7 +137,7 @@ Cherry pick of ${PULLSUBJ} on ${rel}.
$(printf '%s\n' "${SUBJECTS[@]}")
EOF

hub pull-request -F "${prtext}" -h "${GITHUB_USER}:${NEWBRANCH}" -b "kubernetes:${rel}"
hub pull-request -F "${prtext}" -h "${GITHUB_USER}:${NEWBRANCH}" -b "${MAIN_REPO_ORG}:${rel}"
}

git checkout -b "${NEWBRANCHUNIQ}" "${BRANCH}"
Expand All @@ -144,7 +146,8 @@ cleanbranch="${NEWBRANCHUNIQ}"
gitamcleanup=true
for pull in "${PULLS[@]}"; do
echo "+++ Downloading patch to /tmp/${pull}.patch (in case you need to do this again)"
curl -o "/tmp/${pull}.patch" -sSL "http://pr.k8s.io/${pull}.patch"

curl -o "/tmp/${pull}.patch" -sSL "https://github.com/${MAIN_REPO_ORG}/${MAIN_REPO_NAME}/pull/${pull}.patch"
echo
echo "+++ About to attempt cherry pick of PR. To reattempt:"
echo " $ git am -3 /tmp/${pull}.patch"
Expand Down Expand Up @@ -195,8 +198,8 @@ if [[ -n "${DRY_RUN}" ]]; then
exit 0
fi

if git remote -v | grep ^${FORK_REMOTE} | grep kubernetes/kubernetes.git; then
echo "!!! You have ${FORK_REMOTE} configured as your kubernetes/kubernetes.git"
if git remote -v | grep ^${FORK_REMOTE} | grep {$MAIN_REPO_ORG}/{$MAIN_REPO_NAME}.git; then
echo "!!! You have ${FORK_REMOTE} configured as your {$MAIN_REPO_ORG}/{$MAIN_REPO_NAME}.git"
echo "This isn't normal. Leaving you with push instructions:"
echo
echo "+++ First manually push the branch this script created:"
Expand Down

0 comments on commit f567e82

Please sign in to comment.