diff options
-rw-r--r-- | AUTHORS.md | 33 | ||||
-rwxr-xr-x | bin/git/hooks/pre-commit | 3 | ||||
-rw-r--r-- | bin/git/tools/create_contributors.py | 63 |
3 files changed, 67 insertions, 32 deletions
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): <cosenal@gmail.com> -* [Bernhard Posselt](https://github.com/BernhardPosselt): <dev@bernhard-posselt.com> - -## Designers - -* [Jan-Christoph Borchardt](https://github.com/jancborchardt): <hey@jancborchardt.net> -* [Raghu Nayyar](https://github.com/raghunayyar): <me@iraghu.com> -* [Bernhard Posselt](https://github.com/BernhardPosselt): <dev@bernhard-posselt.com> - - -## Contributors - -* [Robin Appelman](https://github.com/icewind1991): <icewind@owncloud.com> -* [Morris Jobke](https://github.com/kabum): <morris.jobke@gmail.com> -* [Lukas Reschke](https://github.com/LukasReschke): <lukas@statuscode.ch> -* [bluehaze](https://github.com/bluehaze) -* [Dave Hou Qingping](https://github.com/houqp): <dave2008713@gmail.com> -* [David Kleuker](https://github.com/davidak): <info@davidak.de> -* [bastei](https://github.com/bastei) -* [Peter Hedlund](https://github.com/phedlund): <support@peterandlinda.com> -* [benediktb](https://github.com/benediktb) -* [Maik Kulbe](https://github.com/mkzero) -* [s17t.net](https://github.com/s17t): <mail+github@s17t.net> -* [John Kristensen](https://github.com/jerrykan) -* [Lutz Schildt](https://github.com/lsmooth): <ls@lsmooth.de> -* [Christopher](https://github.com/Kondou-ger): <kondou@ts.unde.re> -* [Xemle](https://github.com/xemle): <xemle@phtagr.org> -* [Blaimi](https://github.com/Blaimi) -* [Davide Saurino](https://github.com/sub): <davide.saurino@alcacoop.it> -* [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<commit_count>\d+)\s*(?P<name>.*\w)\s*<(?P<email>[^\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) |