Skip to content

Commit

Permalink
tools: Add mkcontrib.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xlz authored and floe committed Jan 25, 2016
1 parent 95301a5 commit a819be4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tools/mkcontrib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 1. Visual inspection: python mkcontrib.py
# 2. If OK, python mkcontrib.py | grep -v ^# > CONTRIB

from subprocess import Popen, PIPE
from collections import defaultdict, Counter

p = Popen(["git","log","--no-merges","--format=%aN <%aE>"], stdout=PIPE).stdout
common_email = defaultdict(Counter)
common_name = defaultdict(Counter)
for line in p:
author, email = line.rstrip().split('<')
common_email[author].update([email])
common_name[email].update([author])

for email in common_name:
names = common_name[email]
names = sorted(names, key=lambda x: (names[x], len(x)), reverse=True)
for name in names[1:]:
common_email[names[0]] += common_email[name]
del common_email[name]
print '# Less common or shorter name', name, 'is replaced by', names[0]

for name in sorted(common_email):
for k in common_email[name].most_common()[1:]:
print '# Less common email <' + k[0] + ' is removed.'
print name + '<' + common_email[name].most_common(1)[0][0]

0 comments on commit a819be4

Please sign in to comment.