-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[flutter_plugin_tool] Don't allow NEXT on version bumps #4246
[flutter_plugin_tool] Don't allow NEXT on version bumps #4246
Conversation
The special "NEXT" entry in a CHANGELOG should never be present in a commit that bumped the version. This validates that this is true even if the CHANGELOG would be correct for a non-version-change state, to catch someone incorrectly resolving a merge conflict by leaving both parts of the conflict, rather than folding the 'NEXT' entry's list into the new version's notes. Fixes flutter/flutter#85584
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.
Looks good other than some niggles about _hasConsistentVersion
. It's not a huge deal, let me know what you think.
await _getVersionState(package, pubspec: pubspec); | ||
switch (versionState) { | ||
case _CurrentVersionState.unchanged: | ||
break; |
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.
nit: I'd put versionChanged = false here since setting it above isn't clearly associated with the unchanged branch.
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.
Changed to no initialization of the variable so that the compiler forces setting it in each branch, for better clarity/future-proofing.
} | ||
|
||
/// Returns whether or not the pubspec version and CHANGELOG version for | ||
/// [plugin] match. | ||
Future<bool> _hasConsistentVersion( | ||
Directory package, { | ||
required Pubspec pubspec, | ||
required bool versionChanged, |
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.
Can versionChanged
be calculated inside of this function? The first 2 arguments make sense to me, this one isn't clear. It seems like you wouldn't ask "has consistent version?" if you already know the "version hasn't changed".
We should at least update the docstring. Also, based on the name it seems like a pure function but it is printing out stuff.
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 changed the name and docstring, so hopefully it's clearer what this is doing now (it's unfortunately hard to do pure functions in these checks a lot of the time, because verbose logging of everything that's happening is a feature in CI checks; failures where you don't get easily and clearly enough detail about why are a pain). I also changed the parameter name to be more specific about what version changed (the pubspec version) since that was, as evidenced by your question, ambiguous.
For an example of why we'd call this even when that hasn't changed: if a PR author forgets to actually update the version in pubspec.yaml
but remembers to update CHANGELOG.md
as if they had, we want that to fail CI. In that case the parameter here will be false, but the version consistency check will fail.
} | ||
|
||
if (!(await _hasConsistentVersion(package, pubspec: pubspec))) { | ||
if (!(await _hasConsistentVersion(package, |
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.
Should we be calling hasConsistentVersion when _CurrentVersionState.unknown?
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.
In general, my experience has been that unless it's expensive (which isn't the case here) it's much better to have CI checks fail but continue, so that we find more errors per run. It's really frustrating to fix a CI failure, push a PR, and wait for checks to run again, only to discover that there's another error now that could have been surfaced before but wasn't. That's a pattern I've been following in most of the tool overhaul work, and it's already made things better.
In this case, errors in the CHANGELOG are almost entirely unrelated to whether the version actually changed (only the one edge case this test now covers); almost all of the time a failure here will just be due to a mismatch between what's in pubspec.yaml and what's in CHANGELOG.md, so surfacing that (so the PR author can fix it in parallel) even if something weird happens with the version check is useful.
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.
LGTM!
The special "NEXT" entry in a CHANGELOG should never be present in a commit that bumped the version. This validates that this is true even if the CHANGELOG would be correct for a non-version-change state, to catch someone incorrectly resolving a merge conflict by leaving both parts of the conflict, rather than folding the 'NEXT' entry's list into the new version's notes. Fixes flutter/flutter#85584
The special "NEXT" entry in a CHANGELOG should never be present in a commit that bumped the version. This validates that this is true even if the CHANGELOG would be correct for a non-version-change state, to catch someone incorrectly resolving a merge conflict by leaving both parts of the conflict, rather than folding the 'NEXT' entry's list into the new version's notes. Fixes flutter/flutter#85584
The special "NEXT" entry in a CHANGELOG should never be present in a
commit that bumped the version. This validates that this is true even if
the CHANGELOG would be correct for a non-version-change state, to catch
someone incorrectly resolving a merge conflict by leaving both parts of
the conflict, rather than folding the 'NEXT' entry's list into the new
version's notes.
Fixes flutter/flutter#85584
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).