feat: add credits
field to release note generator
Now, we can credit folks for their work. The credit generator is very basic, we probably want a database of profiles and link to their preferred page or something. Change-Id: Ida81905750371e5e125d0ce7e554d0526265cf8e Co-Authored-By: Jade Lovelace <lix@jade.fyi> Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
parent
a30c567336
commit
c52eba4424
1 changed files with 12 additions and 2 deletions
|
@ -6,6 +6,7 @@ import textwrap
|
||||||
GH_BASE = "https://github.com/NixOS/nix"
|
GH_BASE = "https://github.com/NixOS/nix"
|
||||||
FORGEJO_BASE = "https://git.lix.systems/lix-project/lix"
|
FORGEJO_BASE = "https://git.lix.systems/lix-project/lix"
|
||||||
GERRIT_BASE = "https://gerrit.lix.systems/c/lix/+"
|
GERRIT_BASE = "https://gerrit.lix.systems/c/lix/+"
|
||||||
|
KNOWN_KEYS = ('synopsis', 'cls', 'issues', 'prs', 'significance', 'credits')
|
||||||
|
|
||||||
SIGNIFICANCECES = {
|
SIGNIFICANCECES = {
|
||||||
None: 0,
|
None: 0,
|
||||||
|
@ -31,6 +32,13 @@ def format_pr(pr: str) -> str:
|
||||||
def format_cl(clid: int) -> str:
|
def format_cl(clid: int) -> str:
|
||||||
return f"[cl/{clid}]({GERRIT_BASE}/{clid})"
|
return f"[cl/{clid}]({GERRIT_BASE}/{clid})"
|
||||||
|
|
||||||
|
def plural_list(strs: list[str]) -> str:
|
||||||
|
if len(strs) <= 1:
|
||||||
|
return ''.join(strs)
|
||||||
|
else:
|
||||||
|
comma = ',' if len(strs) >= 3 else ''
|
||||||
|
return '{}{} and {}'.format(', '.join(strs[:-1]), comma, strs[-1])
|
||||||
|
|
||||||
def run_on_dir(d):
|
def run_on_dir(d):
|
||||||
paths = pathlib.Path(d).glob('*.md')
|
paths = pathlib.Path(d).glob('*.md')
|
||||||
entries = []
|
entries = []
|
||||||
|
@ -39,7 +47,7 @@ def run_on_dir(d):
|
||||||
e = frontmatter.load(p)
|
e = frontmatter.load(p)
|
||||||
if 'synopsis' not in e.metadata:
|
if 'synopsis' not in e.metadata:
|
||||||
raise Exception('missing synopsis')
|
raise Exception('missing synopsis')
|
||||||
unknownKeys = set(e.metadata.keys()) - set(('synopsis', 'cls', 'issues', 'prs', 'significance'))
|
unknownKeys = set(e.metadata.keys()) - set(KNOWN_KEYS)
|
||||||
if unknownKeys:
|
if unknownKeys:
|
||||||
raise Exception('unknown keys', unknownKeys)
|
raise Exception('unknown keys', unknownKeys)
|
||||||
entries.append((p, e))
|
entries.append((p, e))
|
||||||
|
@ -66,7 +74,9 @@ def run_on_dir(d):
|
||||||
print(f"- {header}")
|
print(f"- {header}")
|
||||||
print()
|
print()
|
||||||
print(textwrap.indent(entry.content, ' '))
|
print(textwrap.indent(entry.content, ' '))
|
||||||
|
if credits := listify(entry.metadata.get('credits', [])):
|
||||||
print()
|
print()
|
||||||
|
print(textwrap.indent('Many thanks to {} for this.'.format(plural_list(credits)), ' '))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
e.add_note(f"in {p}")
|
e.add_note(f"in {p}")
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in a new issue