-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that changelog entries are ordered #613
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems sensible, two suggestions.
scripts/check-changelog.py
Outdated
for line in tools.changelog().split('\n'): | ||
if line.strip() in acceptable_lines: | ||
pattern = r'\n\d+\.\d+\.\d+ - \d\d\d\d-\d\d-\d\d\n' | ||
all_versions = list(map(str.strip, re.findall(pattern, tools.changelog()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly cleaner?
pattern = re.compile(r'\n(?<line>\d+\.\d+\.\d+ - \d{4}-\d{2}-\d{2})\n')
all_versions = [m.group('line') for m in pattern.finditer(tools.changelog())]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the date pattern better, but otherwise I find it easier to think about re.findall
returning a list of strings.
scripts/check-changelog.py
Outdated
else: | ||
print('No line with version and current date (%s) in the changelog. ' | ||
'Remember this will be released as soon as you merge to master!' | ||
% ' or '.join(repr(line) for line in acceptable_lines)) | ||
sys.exit(1) | ||
|
||
assert all_versions == sorted(all_versions), \ | ||
'You edited old release notes and changed the ordering!' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I’d make this an if
statement instead:
if all_versions != sorted(all_versions):
I reserve assert
for "the program has got into an unexpected/should-be-impossible state, abort!" – whereas it's totally possible that one of us screws up the changelog. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - I should have done that when I thought a message might be useful!
ea027ea
to
fd84c2f
Compare
I've had some trouble with the changelog when rebasing or merging, so I thought I'd write some more checks. Now the expected entry must appear first, all version numbers must be unique and in order, and no version numbers may be skipped. See https://xkcd.com/208/
c27b104
to
b4badec
Compare
Excellent - having worked out all the ways that merging could break the changelog but not testing for them was going to make me nervous 😄 |
I just had the changelog for #508 (proposed version 3.9.0) merged to below the changelog for new release 3.8.3, so I thought our check should look at order as well as existence. And uniqueness. And that we didn't skip a valid version number.