Created
December 6, 2016 21:44
-
-
Save sivel/ce61ff595c0f3bf077b7a42ec3492f22 to your computer and use it in GitHub Desktop.
Migrate mailbox patch for ansible repo merge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
import requests | |
DIFF_GIT_RE = re.compile(r'^(diff --git a/)([^ ]+ b/)([^ ]+)$', re.M) | |
STAT_RE = re.compile(r'^(\s+)([^ ]+\s+\|\s+\d+\s+[+-]+)$', re.M) | |
MINUS_PLUS_RE = re.compile(r'^((?:-|\+){3} [ab]/)(.+)$', re.M) | |
r = requests.get('%s.patch' % sys.argv[1]) | |
r.raise_for_status() | |
patch = r.text | |
patch = DIFF_GIT_RE.sub( | |
r'\1lib/ansible/modules/\2lib/ansible/modules/\3', | |
patch | |
) | |
patch = STAT_RE.sub(r'\1lib/ansible/modules/\2', patch) | |
patch = MINUS_PLUS_RE.sub(r'\1lib/ansible/modules/\2', patch) | |
print patch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment