Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cherry pick a patch, even if the file has been renamed.
#!/bin/bash
set -eux
git clone https://github.com/goneri/ansible_vmware_collection /tmp/cherry_pick_demo
cd /tmp/cherry_pick_demo
# starts a dev branch
git checkout -B dev origin/master
git mv community/vmware/plugins/modules/vmware_dvswitch.py ansible/vmware/plugins/modules/
# mock some extra changes to fix the module
sed -i 's,destroy_dvswitch,remove_dvswitch,g' ansible/vmware/plugins/modules/vmware_dvswitch.py
git commit -a -m "promotion of vmware_dvswitch.py"
sed -i 's,update_dvswitch,update_dvswitch_status,g' ansible/vmware/plugins/modules/vmware_dvswitch.py
git commit -a -m "Apply a fix that will need to be cherry-picked"
# Open up a stable branch
git checkout -B stable origin/master
# Cherry-pick the fix
git cherry-pick $(git log -1 --pretty=tformat:%H dev)
git log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment