handle all types of aliases for the contributor list
If a contributor email is already in the list we won't create a new
entry. However, if the name is different than in the list, we print a
message if an alias is missing in .mailmap
If an email is not in the list, but the name is in the list this could
mean two things:
1. Two different persons have the same name.
This is possible, but less likely than 2.
2. A contributor used another mail.
This is likely the case and we don't make a new entry,
but print a message.
This commit is contained in:
3
.mailmap
3
.mailmap
@@ -1,2 +1,5 @@
|
|||||||
Andrew Brown <brownan@gmail.com> <andrew@fry.(none)>
|
Andrew Brown <brownan@gmail.com> <andrew@fry.(none)>
|
||||||
Alex Headley <aheadley@waysaboutstuff.com> <aheadley@nexcess.net>
|
Alex Headley <aheadley@waysaboutstuff.com> <aheadley@nexcess.net>
|
||||||
|
Alex Headley <aheadley@waysaboutstuff.com> aheadley
|
||||||
|
Michael Fallows <michael@fallo.ws> redorkulated
|
||||||
|
Maciej Malecki <maciej.malecki@hotmail.com> Maciej Małecki
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def format_contributor(contributor):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
# generate list of contributors
|
# generate list of contributors
|
||||||
contributors=[]
|
contributors = []
|
||||||
p_git = Popen(["git", "shortlog", "-se"], stdout=PIPE)
|
p_git = Popen(["git", "shortlog", "-se"], stdout=PIPE)
|
||||||
for line in p_git.stdout:
|
for line in p_git.stdout:
|
||||||
contributors.append({
|
contributors.append({
|
||||||
@@ -27,7 +27,7 @@ def main():
|
|||||||
})
|
})
|
||||||
|
|
||||||
# cache listed contributors
|
# cache listed contributors
|
||||||
old_contributors=[]
|
old_contributors = []
|
||||||
with open("CONTRIBUTORS.rst", "r") as contrib_file:
|
with open("CONTRIBUTORS.rst", "r") as contrib_file:
|
||||||
for line in contrib_file:
|
for line in contrib_file:
|
||||||
if "@" in line:
|
if "@" in line:
|
||||||
@@ -35,24 +35,52 @@ def main():
|
|||||||
'name': line.split()[1:-1],
|
'name': line.split()[1:-1],
|
||||||
'email': line.split()[-1]
|
'email': line.split()[-1]
|
||||||
})
|
})
|
||||||
# We don't access the name of old/listed contributors at all
|
|
||||||
# but that might change.
|
old = map(lambda x: (x['name'], x['email']), old_contributors)
|
||||||
# So we parse it anyways and strip it off again.
|
|
||||||
old_emails = map(lambda x: x['email'], old_contributors)
|
old_emails = map(lambda x: x['email'], old_contributors)
|
||||||
|
old_names = map(lambda x: x['name'], old_contributors)
|
||||||
|
|
||||||
# check which contributors are new
|
# check which contributors are new
|
||||||
new_contributors=[]
|
new_contributors = []
|
||||||
|
update_mailmap = False
|
||||||
for contributor in contributors:
|
for contributor in contributors:
|
||||||
if contributor["email"] not in old_emails:
|
if (contributor['name'], contributor['email']) in old:
|
||||||
|
# this exact combination already in the list
|
||||||
|
pass
|
||||||
|
elif (contributor['email'] not in old_emails
|
||||||
|
and contributor['name'] not in old_names):
|
||||||
|
# name AND email are not in the list
|
||||||
new_contributors.append(contributor)
|
new_contributors.append(contributor)
|
||||||
|
elif contributor['email'] in old_emails:
|
||||||
|
# email is listed, but with another name
|
||||||
|
old_name = filter(lambda x: x['email'] == contributor['email'],
|
||||||
|
old_contributors)[0]['name']
|
||||||
|
print "new alias %s for %s %s ?" % (
|
||||||
|
" ".join(contributor['name']),
|
||||||
|
" ".join(old_name),
|
||||||
|
contributor['email'])
|
||||||
|
update_mailmap = True
|
||||||
|
elif contributor['name'] in old_names:
|
||||||
|
# probably a new email for a previous contributor
|
||||||
|
other_mail = filter(lambda x: x['name'] == contributor['name'],
|
||||||
|
old_contributors)[0]['email']
|
||||||
|
print "new email %s for %s %s ?" % (
|
||||||
|
contributor['email'],
|
||||||
|
" ".join(contributor['name']),
|
||||||
|
other_mail)
|
||||||
|
update_mailmap = True
|
||||||
|
if update_mailmap:
|
||||||
|
print "Please update .mailmap"
|
||||||
|
|
||||||
# sort on the last word of the name
|
# sort on the last word of the name
|
||||||
new_contributors = sorted(new_contributors,
|
new_contributors = sorted(new_contributors,
|
||||||
key=lambda x: x['name'][-1].lower())
|
key=lambda x: x['name'][-1].lower())
|
||||||
|
|
||||||
# show new contributors to be merged to the list
|
# show new contributors to be merged to the list
|
||||||
for contributor in new_contributors:
|
if new_contributors:
|
||||||
print format_contributor(contributor)
|
print "inserting:"
|
||||||
|
for contributor in new_contributors:
|
||||||
|
print format_contributor(contributor)
|
||||||
|
|
||||||
# merge with contributor list
|
# merge with contributor list
|
||||||
i = 0
|
i = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user