Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Automagically pick ansible/ansible PR
import re
import urllib.request
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("pr_id", type=int)
args = parser.parse_args()
url = "{pr_id}.patch".format(
r = urllib.request.urlopen(url)
content = (
.replace("lib/ansible/modules/cloud/vmware/", "plugins/modules/")
.replace("test/integration/targets", "tests/integration/targets")
.replace("lib/ansible/plugins/inventory", "plugins/inventory")
)["git", "am", "--abort"])
for patch in content.split("\nFrom "):
with open("/tmp/my.patch", "w") as fd:
fd.write("From ")
subprocess.check_call(["git", "am", "/tmp/my.patch"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment