-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathlist-top-authors
More file actions
executable file
·49 lines (41 loc) · 1.38 KB
/
list-top-authors
File metadata and controls
executable file
·49 lines (41 loc) · 1.38 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
import git
import sys
import time
if len(sys.argv) < 4:
print 'Usage: list-top-authors repo startrev threshold'
print
print 'Lists authors of commits in given repo, starting with startrev'
print 'The threshold defines minimal amount of commits author needs to be listed'
sys.exit()
threshold = int(sys.argv[3])
repo = git.Repo(sys.argv[1])
authors = {}
for commit in repo.iter_commits('%s..master' % sys.argv[2]):
author = commit.author.name
full_author = '%s <%s>' % (commit.author.name, commit.author.email)
date = commit.authored_date
if not author in authors:
authors[author] = {
'first': date,
'last': date,
'count': 1,
'name': full_author,
}
else:
if authors[author]['first'] > date:
authors[author]['first'] = date
if authors[author]['last'] < date:
authors[author]['last'] = date
authors[author]['count'] += 1
authors = authors.values()
authors.sort(lambda a, b: -1 * cmp(a['count'], b['count']))
for a in authors:
if a['count'] < threshold:
break
first = time.strftime("%b %Y", time.gmtime(a['first']))
last = time.strftime("%b %Y", time.gmtime(a['last']))
# Ignore people with short interval
if first == last:
continue
print '%s (%s - %s)' % (a['name'].encode('utf-8'), first, last)