From 463a91f6d55647c70a6df2c9020fbe9b16dc2976 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Wed, 24 Apr 2019 12:08:52 +0300 Subject: [PATCH] Add generate_authors.py and AUTHORS --- AUTHORS | 6 +++++ misc/generate_authors.py | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 AUTHORS create mode 100644 misc/generate_authors.py diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..c7a4ede --- /dev/null +++ b/AUTHORS @@ -0,0 +1,6 @@ +Ram Rachum +Oleg Butuzov +Edward Betts +wilfredinni +Peter Bittner +Alireza Ayinmehr diff --git a/misc/generate_authors.py b/misc/generate_authors.py new file mode 100644 index 0000000..173a7ed --- /dev/null +++ b/misc/generate_authors.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# Copyright 2019 Ram Rachum. +# This program is distributed under the MIT license. + + +""" +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 + +""" + + +import time + +import subprocess + + +def drop_recurrences(iterable): + s = set() + for item in iterable: + if item not in s: + s.add(item) + yield item + + +def iterate_authors_by_chronological_order(): + log_call = subprocess.run( + ( + 'git', 'log', 'master', '--encoding=utf-8', '--full-history', + '--reverse', '--format=format:%at;%an;%ae' + ), + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + ) + log_lines = log_call.stdout.decode('utf-8').split('\n') + + return drop_recurrences( + (line.strip().split(";")[1] for line in log_lines) + ) + + +def print_authors(): + for author in iterate_authors_by_chronological_order(): + print(author) + +if __name__ == '__main__': + print_authors() \ No newline at end of file