mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #34972 from jessfraz/add-remote-settings-to-cp-script
Automatic merge from submit-queue hack/: update cherry-pick script to have settings to override remote names **What this PR does / why we need it**: it allows you to override the remote names for the cherry-pick script in case you have it named differently
This commit is contained in:
commit
a47ac1fa30
@ -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=<your-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
|
||||
|
Loading…
Reference in New Issue
Block a user