Skip to content

Instantly share code, notes, and snippets.

@goneri
Last active February 21, 2020 14:56
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 goneri/8ad7ca9f1ccc0bc11260faee572d735d to your computer and use it in GitHub Desktop.
Save goneri/8ad7ca9f1ccc0bc11260faee572d735d to your computer and use it in GitHub Desktop.
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