Skip to content

Commit a819be4

Browse files
xlzfloe
authored andcommitted
tools: Add mkcontrib.py
1 parent 95301a5 commit a819be4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tools/mkcontrib.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 1. Visual inspection: python mkcontrib.py
2+
# 2. If OK, python mkcontrib.py | grep -v ^# > CONTRIB
3+
4+
from subprocess import Popen, PIPE
5+
from collections import defaultdict, Counter
6+
7+
p = Popen(["git","log","--no-merges","--format=%aN <%aE>"], stdout=PIPE).stdout
8+
common_email = defaultdict(Counter)
9+
common_name = defaultdict(Counter)
10+
for line in p:
11+
author, email = line.rstrip().split('<')
12+
common_email[author].update([email])
13+
common_name[email].update([author])
14+
15+
for email in common_name:
16+
names = common_name[email]
17+
names = sorted(names, key=lambda x: (names[x], len(x)), reverse=True)
18+
for name in names[1:]:
19+
common_email[names[0]] += common_email[name]
20+
del common_email[name]
21+
print '# Less common or shorter name', name, 'is replaced by', names[0]
22+
23+
for name in sorted(common_email):
24+
for k in common_email[name].most_common()[1:]:
25+
print '# Less common email <' + k[0] + ' is removed.'
26+
print name + '<' + common_email[name].most_common(1)[0][0]

0 commit comments

Comments
 (0)