Skip to content

Instantly share code, notes, and snippets.

@mbaldessari
Created August 7, 2017 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbaldessari/21251767844aa4f7826756a385753888 to your computer and use it in GitHub Desktop.
Save mbaldessari/21251767844aa4f7826756a385753888 to your computer and use it in GitHub Desktop.
function apply_patch() {
local CHANGE=$1
local REPO=$2
local DIR=$3
# patchset revision is 4th optional argument
if [[ -z ${4-} ]]; then
REF=$(curl -s "https://review.openstack.org/changes/?q=change:$CHANGE&o=CURRENT_REVISION" |tail -n+2|jq -r '.[] | .revisions[.current_revision] | .ref')
else
REF=$(curl -s "https://review.openstack.org/changes/?q=change:$CHANGE&o=ALL_REVISIONS" |tail -n+2| jq -r '.[] | .revisions | to_entries | map(select(.value._number=='$4')) | .[0]|.value.ref')
fi
echo "Revision for $CHANGE/${4-} -> $REF"
pushd $DIR
git config --global user.email "michele@acksyn.org"
git config --global user.name "Michele Baldessari"
git fetch https://git.openstack.org/openstack/$REPO $REF && git cherry-pick FETCH_HEAD
popd
}
# applies review below 4th revision
# apply_patch 474486 tripleo-heat-templates tripleo-heat-templates 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment