From b2374da2d53e17409ce041b5ba67bd8b0f807c2e Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sun, 6 Sep 2015 16:53:51 +0200 Subject: autogenerate contributors --- AUTHORS.md | 33 +------------------ bin/git/hooks/pre-commit | 3 ++ bin/git/tools/create_contributors.py | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 32 deletions(-) create mode 100644 bin/git/tools/create_contributors.py diff --git a/AUTHORS.md b/AUTHORS.md index 5ebaa1095..77e81149e 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,32 +1 @@ -# Authors -* [Alessandro Cosentino](https://github.com/cosenal): -* [Bernhard Posselt](https://github.com/BernhardPosselt): - -## Designers - -* [Jan-Christoph Borchardt](https://github.com/jancborchardt): -* [Raghu Nayyar](https://github.com/raghunayyar): -* [Bernhard Posselt](https://github.com/BernhardPosselt): - - -## Contributors - -* [Robin Appelman](https://github.com/icewind1991): -* [Morris Jobke](https://github.com/kabum): -* [Lukas Reschke](https://github.com/LukasReschke): -* [bluehaze](https://github.com/bluehaze) -* [Dave Hou Qingping](https://github.com/houqp): -* [David Kleuker](https://github.com/davidak): -* [bastei](https://github.com/bastei) -* [Peter Hedlund](https://github.com/phedlund): -* [benediktb](https://github.com/benediktb) -* [Maik Kulbe](https://github.com/mkzero) -* [s17t.net](https://github.com/s17t): -* [John Kristensen](https://github.com/jerrykan) -* [Lutz Schildt](https://github.com/lsmooth): -* [Christopher](https://github.com/Kondou-ger): -* [Xemle](https://github.com/xemle): -* [Blaimi](https://github.com/Blaimi) -* [Davide Saurino](https://github.com/sub): -* [Repat](http://repat.de/) -* [David Luhmer](https://github.com/David-Development) +# Contributors diff --git a/bin/git/hooks/pre-commit b/bin/git/hooks/pre-commit index 202992f9e..d4edff8cd 100755 --- a/bin/git/hooks/pre-commit +++ b/bin/git/hooks/pre-commit @@ -12,3 +12,6 @@ cd .. phpunit -c phpunit.xml phpunit -c phpunit.integration.xml git add appinfo/checksum.json + +python3 bin/git/tools/create_contributors.py +git add AUTHORS.md diff --git a/bin/git/tools/create_contributors.py b/bin/git/tools/create_contributors.py new file mode 100644 index 000000000..643d22f68 --- /dev/null +++ b/bin/git/tools/create_contributors.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 + +import subprocess +import re +import os.path + +contribs = subprocess.check_output(['git', 'shortlog', '-e', '-s', '-n']) +contrib_lines = contribs.decode('utf-8').split('\n') + +format_regex = r'^\s*(?P\d+)\s*(?P.*\w)\s*<(?P[^\s]+)>$' + +def tuple_to_markdown(tuple): + return ('* [%s](mailto:%s)' % (tuple[0], tuple[1])) + +def line_to_tuple(line): + result = re.search(format_regex, line) + if result: + return ( + result.group('commit_count'), + result.group('name'), + result.group('email') + ) + else: + return () + +def group_by_name(tuples): + authors = {} + for tuple in tuples: + if tuple[1] in authors.keys(): + authors[tuple[1]]['commits'] += int(tuple[0]) + else: + authors[tuple[1]] = { + 'commits': int(tuple[0]), + 'email': tuple[2] + } + result = [] + for author, info in authors.items(): + result.append((info['commits'], author, info['email'])) + return result + +tuples = map(line_to_tuple, contrib_lines) +tuples = filter(lambda x: len(x) > 0, tuples) # filter out empty results +tuples = filter(lambda x: 'Jenkins' not in x[1], tuples) # filter out jenkins +tuples = group_by_name(tuples) +tuples = sorted(tuples, key=lambda x: x[0], reverse=True) +tuples = map(lambda x: (x[1], x[2]), tuples) +authors = map(tuple_to_markdown, tuples) +authors = '\n'.join(authors) + +header = '# Contributors' +contents = '%s\n%s' % (header, authors) + +# write contents into contributors file +base_dir_diff = 3 +current_dir = os.path.dirname(os.path.realpath(__file__)) +base_dir = current_dir + +for x in range(base_dir_diff): + base_dir = os.path.join(base_dir, os.pardir) + +contributors_file = os.path.join(base_dir, 'AUTHORS.md') +with open(contributors_file, 'w') as f: + f.write(contents) -- cgit v1.2.3