Browse Source

changelog script improvements, manual pr, sort order, formatting

pull/1268/head
Ross McFarland 6 months ago
parent
commit
cd4ee5f854
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
3 changed files with 36 additions and 12 deletions
  1. +5
    -0
      .changelog/ff12d7ab1c614a15b3ce8c6bba3407fb.md
  2. +0
    -5
      CHANGELOG.md
  3. +31
    -7
      script/changelog

+ 5
- 0
.changelog/ff12d7ab1c614a15b3ce8c6bba3407fb.md View File

@ -0,0 +1,5 @@
---
type: minor
pr: 1251
---
Correct type-o in name of AcmeManagingProcessor, backwards compatible alias in place

+ 0
- 5
CHANGELOG.md View File

@ -1,8 +1,3 @@
## v1.11.? - 2025-??-?? - ???
* Correct type-o in name of AcmeManagingProcessor, backwards compatible alias
in place
## v1.11.0 - 2025-02-03 - Cleanup & deprecations with meta planning
* Deprecation warning for Source.populate w/o the lenient param, to be removed


+ 31
- 7
script/changelog View File

@ -11,7 +11,7 @@ from subprocess import PIPE, run
from sys import argv, exit, path, stderr
from uuid import uuid4
from yaml import safe_load_all
from yaml import safe_load
def create(argv):
@ -39,6 +39,11 @@ def create(argv):
See https://semver.org/ for more info''',
)
parser.add_argument(
'-p',
'--pr',
help='Manually override the PR number for the change, maintainer use only.',
)
parser.add_argument(
'-a',
'--add',
@ -62,6 +67,9 @@ and links.''',
with open(filepath, 'w') as fh:
fh.write('---\ntype: ')
fh.write(args.type)
if args.pr:
fh.write('\npr: ')
fh.write(args.pr)
fh.write('\n---\n')
fh.write(' '.join(args.md))
@ -106,7 +114,7 @@ class _ChangeMeta:
_pr_cache = None
@classmethod
def get(cls, filepath):
def get(cls, filepath, data):
if cls._pr_cache is None:
result = run(
[
@ -139,7 +147,13 @@ class _ChangeMeta:
try:
return cls._pr_cache[filepath]
except KeyError:
return None, datetime(year=1970, month=1, day=1)
# couldn't find a PR with the changelog file in it
try:
# if a PR number was specified in the changelog entry use it
return data['pr'], datetime(year=1970, month=1, day=1)
except KeyError:
# otherwise just give up
return None, datetime(year=1970, month=1, day=1)
def _get_changelogs():
@ -150,8 +164,12 @@ def _get_changelogs():
continue
filepath = join(dirname, filename)
with open(filepath) as fh:
data, md = safe_load_all(fh)
pr, time = _ChangeMeta.get(filepath)
pieces = fh.read().split('---\n')
data = safe_load(pieces[1])
md = pieces[2]
if md[-1] == '\n':
md = md[:-1]
pr, time = _ChangeMeta.get(filepath, data)
if not pr:
continue
ret.append(
@ -165,7 +183,7 @@ def _get_changelogs():
)
ordering = {'major': 0, 'minor': 1, 'patch': 2, 'none': 3, '': 3}
ret.sort(key=lambda c: (ordering[c['type']], c['time']))
ret.sort(key=lambda c: (ordering[c['type']], c['time']), reverse=True)
return ret
@ -204,6 +222,9 @@ def bump(argv):
action='store_true',
help='Write changelog update and bump version number',
)
parser.add_argument(
'title', nargs='+', help='A short title/quip for the release title'
)
args = parser.parse_args(argv)
@ -224,7 +245,7 @@ def bump(argv):
buf.write(' - ')
buf.write(datetime.now().strftime('%Y-%m-%d'))
buf.write(' - ')
buf.write(' '.join(argv[1:]))
buf.write(' '.join(args.title))
buf.write('\n')
current_type = None
@ -234,6 +255,9 @@ def bump(argv):
continue
_type = changelog['type']
if _type == 'none':
# these aren't included in the listing
continue
if _type != current_type:
buf.write('\n')
buf.write(_type.capitalize())


Loading…
Cancel
Save