-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathprocess.py
More file actions
executable file
·35 lines (24 loc) · 825 Bytes
/
process.py
File metadata and controls
executable file
·35 lines (24 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
import sys
import git
import whatthepatch
# git hash-object -t tree /dev/null
EMPTY_TREE_SHA = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
repo = git.Repo(".")
file_name = sys.argv[1:]
commits = list(repo.iter_commits(paths=file_name))
commits.reverse()
# first commit hack
patch = commits[0].diff(EMPTY_TREE_SHA, file_name, True)[0].diff.decode("utf-8")
for diff in whatthepatch.parse_patch(patch):
for (i, d, t, _) in diff.changes:
print((d, i, t))
print((commits[0].author.name, commits[0].message))
for i, c in enumerate(commits):
if i==0: continue
patch = commits[i-1].diff(c, file_name, True)[0].diff.decode("utf-8")
for diff in whatthepatch.parse_patch(patch):
for (d, i, t, _) in diff.changes:
if d==None or i==None:
print((d, i, t))
print((c.author.name, c.message))