3 # List the biggest commits from an author over a given rev range
5 # biggest-commits <repo> <author> <range>
7 import subprocess
, sys
, re
, os
10 print('Usage: biggest-commits <repo> <author> <range>')
15 ins
= re
.compile(r
'(\d+) insertion')
16 dele
= re
.compile(r
'(\d+) deletion')
18 cmd
= [ '/usr/bin/git', 'log', '--pretty=oneline', '--shortstat',
19 '-i', '--no-merges', f
'--author={sys.argv[2]}', sys
.argv
[3] ]
23 with subprocess
.Popen(cmd
, stdout
= subprocess
.PIPE
) as log
:
24 line
= log
.stdout
.readline().decode('utf8')
26 commit
, title
= line
.strip().split(' ', 1)
27 line
= log
.stdout
.readline().decode('utf8')
30 lines
= int(m
.group(1))
35 lines
= max(lines
, int(m
.group(1)))
36 commits
[commit
] = (lines
, title
)
38 line
= log
.stdout
.readline().decode('utf8')
40 print(f
'{total} commits.')
41 sc
= sorted(commits
.keys(), key
= lambda e
: -commits
[e
][0])
43 lines
, title
= commits
[c
]
44 print(f
'{lines:6d} {c[:12]} {title}')