Skip to content

Instantly share code, notes, and snippets.

Last active Jul 23, 2019
What would you like to do?
import subprocess
import shelve
def _find_author(filename, lineno):
prop = subprocess.check_output(f"git blame -pL {lineno},{lineno} {filename}", shell = True)
lines = prop.decode().split("\n")
commit = lines[0].split()[0]
author = lines[1].split()[1]
return commit, author
def find_author(line):
prop = subprocess.check_output(f"fgrep -rni {line!r}", shell = True)
filename, lineno, line = prop.decode().split("\n")[0].split(":")
return line, _find_author(filename, lineno)
with open("../last.txt") as f:
lines ="\n")
with'result.db') as db,'fails.db') as fdb:
for line in lines:
if line in db:
print("continue", line)
elif line in fdb:
print("failed continue", line)
line, answer = find_author(line)
db[line] = answer
print(f"added {len(db)}/{5000 - len(fdb)}", line, *answer)
except Exception as exc:
fdb[line] = True
print("failed", line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment