Skip to content

Instantly share code, notes, and snippets.

@freyes
Created September 28, 2023 13:57
Show Gist options
  • Save freyes/c831ad8cf588de6af4736149d3846510 to your computer and use it in GitHub Desktop.
Save freyes/c831ad8cf588de6af4736149d3846510 to your computer and use it in GitHub Desktop.
Helper script to propose backports for OpenStack projects
#!/bin/bash -eux
#
# Usage:
# ./git-cherry-pick-openstack <COMMIT> <TOPIC> <TARGET>
#
# Example:
# ./git-cherry-pick-openstack 83ffa9eb3a2418897bf2707d14efce725d775090 bug/2030094 ussuri
COMMIT_ID=${1}
TOPIC=${2}
TARGET=${3}
CLI_ARGS=( "$@" )
REVIEW="${CLI_ARGS[@]:3}"
git checkout stable/${TARGET} || echo "Already in the desired branch"
git pull
git checkout -b ${TOPIC}-${TARGET}
git cherry-pick -x ${COMMIT_ID}
git review -t ${TOPIC} $REVIEW
git checkout master
git branch -D ${TOPIC}-${TARGET}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment