Skip to content
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

Merged
merged 1 commit into from
May 15, 2017

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented May 10, 2017

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.

Copy link
Contributor

@alexwlchan alexwlchan left a 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.

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())))
Copy link
Contributor

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())]

Copy link
Member Author

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.

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!'
Copy link
Contributor

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. 😉

Copy link
Member Author

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!

@Zac-HD Zac-HD force-pushed the precise-changelog-check branch from ea027ea to fd84c2f Compare May 10, 2017 11:59
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/
@Zac-HD Zac-HD force-pushed the precise-changelog-check branch from c27b104 to b4badec Compare May 11, 2017 03:15
@Zac-HD Zac-HD requested a review from alexwlchan May 14, 2017 07:49
@Zac-HD Zac-HD merged commit dcfe61c into HypothesisWorks:master May 15, 2017
@Zac-HD
Copy link
Member Author

Zac-HD commented May 15, 2017

Excellent - having worked out all the ways that merging could break the changelog but not testing for them was going to make me nervous 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants