Browse Source

add "issues" field to changelog entry

master
Niklas Rosenstein 6 months ago
parent
commit
08f6a43757
Signed by: NiklasRosenstein <rosensteinniklas@gmail.com> GPG Key ID: 06D269B33D25F6C6
3 changed files with 39 additions and 0 deletions
  1. +21
    -0
      .changelog/_unreleased.yml
  2. +17
    -0
      src/shore/__main__.py
  3. +1
    -0
      src/shore/util/changelog.py

+ 21
- 0
.changelog/_unreleased.yml View File

@@ -6,3 +6,24 @@
for the new version.'
flags: []
type: feature
- component: plugins
description: '`setuptools` plugin now exposes a new `wheel` build target'
issues: [19]
flags: []
type: feature
- component: cli
description: '`shore new` now bootstraps a `test/` directory.'
flags: []
type: feature
- component: cli
description: '`shore new` command now correctly replaces hyphens when bootstrapping
the Python package file layout'
issues: [21]
flags: []
type: fix
- component: plugins
description: Generated setup.py files no longer error when the README file does
not exist.
flags:
- setuptools
type: change

+ 17
- 0
src/shore/__main__.py View File

@@ -835,12 +835,29 @@ def changelog(**args):
if not manager.unreleased.entries:
print('No entries in the unreleased changelog.')
else:
def _fmt_issue(i):
if str(i).isdigit():
return '#' + str(i)
return i
def _fmt_issues(entry):
if not entry.issues:
return None
return '(' + ', '.join(colored(_fmt_issue(i), 'yellow', attrs=['underline']) for i in entry.issues) + ')'
def _fmt_flags(entry):
if not entry.flags:
return None
return '(' + ', '.join(colored(f, 'blue', attrs=['underline']) for f in entry.flags) + ')'
entries = sorted(manager.unreleased.entries, key=lambda x: x.component)
for component, entries in Stream.groupby(entries, lambda x: x.component, collect=list):
maxw = max(len(x.type) for x in entries)
print(colored(component or 'No Component', 'red', attrs=['bold', 'underline']))
for entry in entries:
lines = entry.description.splitlines()
suffix_fmt = ' '.join(filter(bool, (_fmt_issues(entry), _fmt_flags(entry))))
if len(lines) > 1 and suffix_fmt:
lines.append(suffix_fmt)
elif len(lines) == 1 and suffix_fmt:
lines[0] += ' ' + suffix_fmt
print(' {}'.format(colored((entry.type + ':').ljust(maxw+1), attrs=['bold'])), _md_term_stylize(lines[0]))
for line in lines[1:]:
print(' {}{}'.format(' ' * (maxw+2), _md_term_stylize(line)))


+ 1
- 0
src/shore/util/changelog.py View File

@@ -30,6 +30,7 @@ class ChangelogEntry(Struct):
type = Field(str)
component = Field(str)
flags = Field([str], default=list)
issues = Field([(str, int)], default=list)
description = Field(str)




Loading…
Cancel
Save