2019-04-24 09:08:52 +00:00
|
|
|
#!/usr/bin/env python
|
2019-04-24 09:10:46 +00:00
|
|
|
# Copyright 2019 Ram Rachum and collaborators.
|
2019-04-24 09:08:52 +00:00
|
|
|
# This program is distributed under the MIT license.
|
|
|
|
|
|
|
|
|
2019-04-25 11:25:42 +00:00
|
|
|
'''
|
2019-04-24 09:08:52 +00:00
|
|
|
Generate an AUTHORS file for your Git repo.
|
|
|
|
|
|
|
|
This will list the authors by chronological order, from their first
|
|
|
|
contribution.
|
|
|
|
|
|
|
|
You probably want to run it this way:
|
|
|
|
|
|
|
|
./generate_authors > AUTHORS
|
|
|
|
|
2019-04-25 11:25:42 +00:00
|
|
|
'''
|
2019-04-24 09:08:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
import subprocess
|
2019-05-09 05:09:11 +00:00
|
|
|
import sys
|
2019-04-24 09:08:52 +00:00
|
|
|
|
2022-04-02 15:07:32 +00:00
|
|
|
# This is used for people who show up more than once:
|
|
|
|
deny_list = frozenset((
|
|
|
|
'Lumir Balhar',
|
|
|
|
))
|
|
|
|
|
2019-04-24 09:08:52 +00:00
|
|
|
|
|
|
|
def drop_recurrences(iterable):
|
|
|
|
s = set()
|
|
|
|
for item in iterable:
|
|
|
|
if item not in s:
|
|
|
|
s.add(item)
|
|
|
|
yield item
|
|
|
|
|
|
|
|
|
2019-09-08 18:53:41 +00:00
|
|
|
def iterate_authors_by_chronological_order(branch):
|
2019-04-24 09:08:52 +00:00
|
|
|
log_call = subprocess.run(
|
|
|
|
(
|
2019-09-08 18:53:41 +00:00
|
|
|
'git', 'log', branch, '--encoding=utf-8', '--full-history',
|
2019-04-24 09:08:52 +00:00
|
|
|
'--reverse', '--format=format:%at;%an;%ae'
|
|
|
|
),
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
|
|
)
|
|
|
|
log_lines = log_call.stdout.decode('utf-8').split('\n')
|
2022-04-02 15:07:32 +00:00
|
|
|
|
|
|
|
authors = tuple(line.strip().split(";")[1] for line in log_lines)
|
|
|
|
authors = (author for author in authors if author not in deny_list)
|
|
|
|
return drop_recurrences(authors)
|
2019-04-24 09:08:52 +00:00
|
|
|
|
|
|
|
|
2019-09-08 18:53:41 +00:00
|
|
|
def print_authors(branch):
|
|
|
|
for author in iterate_authors_by_chronological_order(branch):
|
2019-05-09 05:09:11 +00:00
|
|
|
sys.stdout.buffer.write(author.encode())
|
|
|
|
sys.stdout.buffer.write(b'\n')
|
2019-04-24 09:08:52 +00:00
|
|
|
|
2019-04-25 14:59:36 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-09-08 18:53:41 +00:00
|
|
|
try:
|
|
|
|
branch = sys.argv[1]
|
|
|
|
except IndexError:
|
|
|
|
branch = 'master'
|
|
|
|
print_authors(branch)
|