Skip to content

Instantly share code, notes, and snippets.

@thewtex
Last active April 26, 2018 21:45
Show Gist options
  • Save thewtex/5045b8e13b5d12b8fdcf to your computer and use it in GitHub Desktop.
Save thewtex/5045b8e13b5d12b8fdcf to your computer and use it in GitHub Desktop.
List all new authors since the given revision.
#!/usr/bin/env python3
"""List all new authors since the given revision"""
import sys
import subprocess
if len(sys.argv) < 2 or sys.argv[1] == '-h' or sys.argv[1] == '--help':
usage = "Usage: authors-since.py revision"
print(usage)
sys.exit(1)
revision = sys.argv[1]
def remove_maintainers(authors):
individual_authors = []
for author in authors:
if author.lower().find('maintainer') == -1 and \
author.lower().find('robot') == -1 and \
author.lower().find('group') == -1 and \
author.lower().find('upstream') == -1 and \
len(author) > 3:
individual_authors.append(author)
return set(individual_authors)
previous_authors = subprocess.check_output('git log --pretty=format:"%aN" ' + revision + ' | sort -u',
shell=True)
previous_authors = set(str(previous_authors).strip().split('\\n'))
previous_authors = remove_maintainers(previous_authors)
print('Previous authors: ' + str(len(previous_authors)))
recent_authors = subprocess.check_output('git log --pretty=format:"%aN" ' + revision + '.. | sort -u',
shell=True)
recent_authors = set(str(recent_authors).strip().split('\\n'))
recent_authors = remove_maintainers(recent_authors)
print('Recent authors: ' + str(len(recent_authors)))
new_authors = recent_authors.difference(previous_authors)
print('\nNew authors: ' + str(len(new_authors)))
for author in new_authors:
sys.stdout.write(author + ', ')
authors_with_email = subprocess.check_output('git log --pretty=format:"%aN <%aE>" ' + revision + '.. | sort -u',
shell=True)
authors_with_email = set(str(authors_with_email).strip().split('\\n'))
authors_with_email = remove_maintainers(authors_with_email)
recent_authors_with_email = []
for author in authors_with_email:
for an in recent_authors:
if author.find(an) != -1:
recent_authors_with_email.append(author)
print('\n\nRecent with emails:')
for author in recent_authors_with_email:
sys.stdout.write(author + ', ')
print('\n\nWith emails oneline:')
for author in authors_with_email:
sys.stdout.write(author + '\n')
print('\n\nNames:')
for author in authors_with_email:
sys.stdout.write(author.split('<')[0] + '\n')
print('\n\nEmails:')
for author in authors_with_email:
sys.stdout.write(author.split('<')[1][:-1] + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment