Browse Source

Tweaks to changelog script to suppoort edge cases and dry-run by default

pull/1252/head
Ross McFarland 7 months ago
parent
commit
d65c176ace
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 30 additions and 1 deletions
  1. +1
    -0
      .git_hooks_pre-commit
  2. +29
    -1
      script/changelog

+ 1
- 0
.git_hooks_pre-commit View File

@ -10,3 +10,4 @@ ROOT=$(dirname "$GIT")
"$ROOT/script/lint"
"$ROOT/script/format" --check --quiet || (echo "Formatting check failed, run ./script/format" && exit 1)
"$ROOT/script/coverage"
"$ROOT/script/changelog" check

+ 29
- 1
script/changelog View File

@ -71,7 +71,12 @@ def check(argv):
check=False,
stdout=PIPE,
)
if not result.returncode and result.stdout != b'':
entries = {
l
for l in result.stdout.decode('utf-8').split()
if l.endswith('.md')
}
if not result.returncode and entries:
exit(0)
print(
@ -178,6 +183,21 @@ def _format_version(version):
def bump(argv):
prog = basename(argv.pop(0))
parser = ArgumentParser(
prog=f'{prog} bump',
description='Builds a changelog update and calculates a new version number.',
add_help=True,
)
parser.add_argument(
'--make-changes',
action='store_true',
help='Write changelog update and bump version number',
)
args = parser.parse_args(argv)
buf = StringIO()
cwd = getcwd()
@ -187,6 +207,9 @@ def bump(argv):
current_version = _get_current_version(module_name)
changelogs = _get_changelogs()
new_version = _get_new_version(current_version, changelogs)
if not new_version:
print('No changelog entries found that would bump, nothing to do')
exit(1)
new_version = _format_version(new_version)
buf.write(new_version)
buf.write(' - ')
@ -225,6 +248,11 @@ def bump(argv):
buf.write('\n')
if not args.make_changes:
print(f'New version number {new_version}\n')
print(buf.getvalue())
exit(0)
with open('CHANGELOG.md') as fh:
existing = fh.read()


Loading…
Cancel
Save