|
#!/usr/bin/python3 |
|
import sys |
|
import os |
|
from random import shuffle |
|
from collections import OrderedDict |
|
|
|
if not sys.version_info >= (3, 0): |
|
print("python3 only") |
|
sys.exit() |
|
|
|
tag_from = "" |
|
tag_till = "" |
|
|
|
# full name |
|
ignore_translators = ['luigi1111'] |
|
ignore_contributors = ['luigi1111'] |
|
|
|
exec = lambda cmd: [line.strip() for line in os.popen("""%s""" % cmd).read().split("\n") if line] |
|
|
|
|
|
def git_log(ignores): |
|
if ignores: |
|
ignores = """--author='^(?!{ignores}).*$'""".format(ignores='|'.join(ignores)) |
|
return """ |
|
git log --perl-regexp {ignores} --pretty=format:"%ce %x09%an%x09%s" --date=short {tag_from}..{tag_till} |
|
""".format(tag_from=tag_from, tag_till=tag_till, ignores=ignores).strip() |
|
|
|
|
|
def get_translators(): |
|
# get translation authors |
|
git_cmd = git_log(ignore_translators) + " translations/ " |
|
history = exec(git_cmd) |
|
return parse_history(history) |
|
|
|
|
|
def get_contributors(): |
|
# get commit authors, excluding `translations/` and `lang/` |
|
git_cmd = git_log(ignore_contributors) + " \":(exclude,icase)translations\" \":(exclude,icase)lang\"" |
|
history = exec(git_cmd) |
|
return parse_history(history) |
|
|
|
|
|
def parse_history(history): |
|
shuffle(history) |
|
authors = OrderedDict() |
|
for author in history: |
|
email, name, commit_msg = [_author.strip() for _author in author.split("\t")] |
|
authors.setdefault(name, []) |
|
authors[name].append({'msg': commit_msg, 'name': name, 'email': email}) |
|
return authors |
|
|
|
|
|
def print_authors_detailed(authors, title): |
|
print("============= %s" % title) |
|
for author, commits in authors.items(): |
|
print("%s" % author) |
|
for commit in commits: |
|
print(" - %s" % commit['msg']) |
|
|
|
|
|
def print_authors_markdown(authors, title): |
|
print("============= %s" % title) |
|
for author in authors.keys(): |
|
print('- %s' % author) |
|
|
|
|
|
if __name__ == "__main__": |
|
if len(sys.argv) != 3 or sys.argv[1] not in ['markdown', 'detailed'] or '..' not in sys.argv[2]: |
|
print("usage: ./%s [markdown|detailed] [tag..tag]" % sys.argv[0]) |
|
print("example: ./%s markdown \"v0.12.3.0..v0.13.0.3\"" % sys.argv[0]) |
|
sys.exit() |
|
|
|
tag_from, tag_till = sys.argv[2].split("..") |
|
print("monero-gui %s <> %s - dsc" % (tag_from, tag_till)) |
|
|
|
translators = get_translators() |
|
contributors = get_contributors() |
|
fprint = print_authors_detailed if sys.argv[1] == 'detailed' else print_authors_markdown |
|
|
|
if contributors: |
|
fprint(contributors, title="Contributors") |
|
if translators: |
|
fprint(translators, title="Translations") |