Skip to content
Snippets Groups Projects

Add information and helper scripts for creating releases

Open Oliver Sander requested to merge add-release-instructions into master
6 unresolved threads
Files
2
+ 93
0
#!/usr/bin/python3
#import locale
import subprocess
import sys
from collections import defaultdict
#locale.setlocale(locale.LC_ALL, '')
format = '--format=%ad %aN'
git = subprocess.Popen(['git', 'log', '--date=format:%Y', format] + sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = git.communicate()
if git.returncode > 0:
print(stderr.decode('utf-8'))
sys.exit(1)
def uncommented(author):
return author[0:author.find('(')].strip()
def authorKey(item):
author = uncommented(item[0])
#return (locale.strxfrm(author.split()[-1]), locale.strxfrm(author.split()[0]))
return (author.split()[-1], author.split()[0])
# TODO: Check whether there is a git mechanism for this
# TODO: Move the following lists into the module source trees
aliases = {
'git-bot': None,
'unkown': None,
'Jö Fahlke': 'Jorrit Fahlke',
'Christoph Grüninge': 'Christoph Grüninger',
'Bernhard Haasdonk': 'Bernard Haasdonk',
'dedner': 'Andreas Dedner',
'Robert K': 'Robert Klöfkorn',
'Robert Kloefkorn': 'Robert Klöfkorn',
'Arne Morten Kvarving (SINTEF)': 'Arne Morten Kvarving',
'Rene Milk': 'René Milk',
'Steffe Müthing': 'Steffen Müthing',
'Steffen Muething': 'Steffen Müthing'
}
# TODO: This seems to fail if the .authorsalias file does not exist.
with open(".authorsalias") as f:
for line in f:
(key, val) = line.split(',')
if val.strip() == 'None':
aliases[key.strip()] = None
else:
aliases[key.strip()] = val.strip()
authors = defaultdict(set)
for line in stdout.decode('utf-8').splitlines():
year, author = line.split(maxsplit=1)
author = aliases.get(author, author)
authors[author].add(int(year))
if None in authors:
del(authors[None])
with open('LICENSE.md', 'r', encoding='utf-8') as fh:
copying = list(fh)
empty = [i for i, l in enumerate(copying) if l == '\n']
if len(empty) < 2:
print('Error: "LICENSE.md" should contain more than 2 empty lines.')
sys.exit(1)
for line in copying[empty[0]+1:empty[1]]:
years, author = line.split(maxsplit=1)
author = author.strip()
author = aliases.get(author, author)
if uncommented(author) != author and uncommented(author) in authors:
authors[author] = authors[uncommented(author)]
del(authors[uncommented(author)])
authors[author].add(int(years[:4]))
authors[author].add(int(years[-4:]))
if None in authors:
print("Error: Invalid authors added by COPYING")
with open('LICENSE.md', 'w', encoding='utf-8') as fh:
for line in copying[:empty[0]+1]:
fh.write(line)
for author, years in sorted(authors.items(), key=authorKey):
year_min, year_max = min(years), max(years)
if year_min == year_max:
fh.write('{} {}\n'.format(year_min, author))
else:
fh.write('{}--{} {}\n'.format(year_min, year_max, author))
for line in copying[empty[1]:]:
fh.write(line)
Loading