Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
autogenerate contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Posselt committed Sep 6, 2015
1 parent 70ff47a commit b2374da
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 32 deletions.
33 changes: 1 addition & 32 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
# Authors
* [Alessandro Cosentino](https://github.com/cosenal): <[email protected]>
* [Bernhard Posselt](https://github.com/BernhardPosselt): <[email protected]>

## Designers

* [Jan-Christoph Borchardt](https://github.com/jancborchardt): <[email protected]>
* [Raghu Nayyar](https://github.com/raghunayyar): <[email protected]>
* [Bernhard Posselt](https://github.com/BernhardPosselt): <[email protected]>


## Contributors

* [Robin Appelman](https://github.com/icewind1991): <[email protected]>
* [Morris Jobke](https://github.com/kabum): <[email protected]>
* [Lukas Reschke](https://github.com/LukasReschke): <[email protected]>
* [bluehaze](https://github.com/bluehaze)
* [Dave Hou Qingping](https://github.com/houqp): <[email protected]>
* [David Kleuker](https://github.com/davidak): <[email protected]>
* [bastei](https://github.com/bastei)
* [Peter Hedlund](https://github.com/phedlund): <[email protected]>
* [benediktb](https://github.com/benediktb)
* [Maik Kulbe](https://github.com/mkzero)
* [s17t.net](https://github.com/s17t): <[email protected]>
* [John Kristensen](https://github.com/jerrykan)
* [Lutz Schildt](https://github.com/lsmooth): <[email protected]>
* [Christopher](https://github.com/Kondou-ger): <[email protected]>
* [Xemle](https://github.com/xemle): <[email protected]>
* [Blaimi](https://github.com/Blaimi)
* [Davide Saurino](https://github.com/sub): <[email protected]>
* [Repat](http://repat.de/)
* [David Luhmer](https://github.com/David-Development)
# Contributors
3 changes: 3 additions & 0 deletions bin/git/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
63 changes: 63 additions & 0 deletions bin/git/tools/create_contributors.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit b2374da

Please sign in to comment.