Created
October 12, 2017 17:06
-
-
Save hughdbrown/136dafde53a41ce8969a67af78d7925c to your computer and use it in GitHub Desktop.
Which revisions have a particular phrase in their git diff?
This file contains hidden or 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 os | |
import os.path | |
from itertools import tee, izip | |
from subprocess import Popen, PIPE | |
BUFSIZE = 16 * 1024 * 1024 | |
def pairwise(iterable): | |
"s -> (s0,s1), (s1,s2), (s2, s3), ..." | |
a, b = tee(iterable) | |
next(b, None) | |
return izip(a, b) | |
cmd = ["git", "rev-list", "release_prod_20170902_214223..release_prod_20170927_223603"] | |
p = Popen(cmd, stdout=PIPE, stderr=PIPE, bufsize=BUFSIZE) | |
output, errors = p.communicate() | |
if not errors: | |
hashes = output.splitlines() | |
for a, b in pairwise(hashes): | |
cmd = ["git", "diff", a, b] | |
p = Popen(cmd, stdout=PIPE, stderr=PIPE, bufsize=BUFSIZE) | |
output, errors = p.communicate() | |
if errors: | |
print("Error: {0} {1}".format(a, b)) | |
break | |
else: | |
if "MissingColumn" in output: | |
print(a, b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment