Skip to content

Fix frameworkVersionFor for flutter doctor and usage - #54217

Merged
fluttergithubbot merged 11 commits into
flutter:masterfrom
chris-forks:fix-flutter-version-take-two
Apr 8, 2020
Merged

fluttergithubbot merged 11 commits into
flutter:masterfrom
chris-forks:fix-flutter-version-take-two

Conversation

@christopherfujino

@christopherfujino christopherfujino commented Apr 7, 2020 •

Copy link
Copy Markdown
Contributor

Description

With the new release tag format, the Flutter tool failed to detect the new tags #53688. Tag parsing was fixed in #53715, however, version reporting was not updated, so flutter doctor and usage reporting would only include x.y.z, and not the additional m.n in pre-stable releases.

This PR fixes frameworkVersionFor() AND accounts for another modification to the release tag format (1.2.3-dev.4.5 -> 1.2.3-4.5.pre). Parsing of the x.y.z-dev.m.n format is being moved to the parseLegacyVersion() method, and we are dropping support for vx.y.z+hotfix.m. This parsing logic is only for the nearest tagged parent, thus we can drop parsing support for old formats once the new format has been published on that channel.

Related Issues

fixes #54160, #53688

Tests

I extended the existing test to verify more permutations are correctly being parsed.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read [Handling breaking changes].

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@fluttergithubbot fluttergithubbot added tool Affects the "flutter" command-line tool. See also t: labels. work in progress; do not review labels Apr 7, 2020
@christopherfujino
christopherfujino force-pushed the fix-flutter-version-take-two branch 2 times, most recently from 2d03c9f to f23114d Compare April 7, 2020 20:35
@christopherfujino
christopherfujino force-pushed the fix-flutter-version-take-two branch from f23114d to ee33ead Compare April 7, 2020 20:46
@christopherfujino
christopherfujino marked this pull request as ready for review April 7, 2020 21:06
Comment thread dev/bots/test.dart Outdated
final RegExp pattern = RegExp(r'^\d+\.\d+\.\d+(\+hotfix\.\d+)?(-pre\.\d+)?$');
// 1.18.0-5.0-pre.8
final RegExp pattern = RegExp(
r'^(\d+)\.(\d+)\.(\d+)(-\d+\.\d+)?(-pre\.\d+)?$');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.pre (dot, not hyphen).

And elsewhere.

@christopherfujino christopherfujino Apr 7, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make that change, but to clarify, this is just for reporting commits past last tagged version in the tool, and not the git tag format itself, and is a break from how we used to do it.

// old way, 4 commits past 1.2.3
1.2.4-pre.4

// this PR, 4 commits past 1.2.3-0.0.pre
1.2.3-1.0-pre.4

// proposed change, 4 commits past 1.2.3-0.0.pre
1.2.3-1.0.pre.4

@christopherfujino christopherfujino Apr 7, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also, if you are 4 commits past version 1.2.3? Should that be 1.2.3-pre.4 or 1.2.3.pre.4? (though I suppose this would be an edge case, where the user is adding their own commits on the stable branch).


// TODO(fujino): Deprecate this https://github.com/flutter/flutter/issues/53850
/// Check for the release tag format pre-v1.17.0
/// Check for the release tag format of the form x.y.z-dev.m.n

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer -dev

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to support the -dev tag or else when I land this (before there are the new tags) the tool will be in a bad state (and pre-submit was failing because it couldn't parse the current version)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was either support the -dev tag, or change the git describe --match glob, and I figured if I support the -dev tag here, I can safely remove it after the next dev release with the new tag format.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, can you split out the -dev parsing code to more clearly delineate what logic can be removed after the next dev?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire method can be removed in the next dev.

(String source) => source == null ? null : int.tryParse(source)).toList();
List<int> devParts = <int>[null, null];
if (parts[3] != null) {
devParts = RegExp(r'^-dev\.(\d+)\.(\d+)')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer -dev

return '$x.$y.$z+hotfix.${hotfix + 1}-pre.$commits';
}
if (devPatch != null && devVersion != null) {
return '$x.$y.$z-${devVersion + 1}.0-pre.$commits';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.pre

}
if (hotfix != null) {
// This is an unexpected state where untagged commits exist past a hotfix
return '$x.$y.$z+hotfix.${hotfix + 1}-pre.$commits';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.pre

@christopherfujino

Copy link
Copy Markdown
Contributor Author

I'm looking at the failure to test/commands.shard/hermetic/version_test.dart


// TODO(fujino): Deprecate this https://github.com/flutter/flutter/issues/53850
/// Check for the release tag format pre-v1.17.0
/// Check for the release tag format of the form x.y.z-dev.m.n

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, can you split out the -dev parsing code to more clearly delineate what logic can be removed after the next dev?

// legacy tag release format
gitTagVersion = GitTagVersion.parse('v1.2.3-4-g$hash');
expect(gitTagVersion.frameworkVersionFor(hash), '1.2.4-pre.4');
// legacy tag format (x.y.z-dev.m.n), master channel

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a regression test of the doctor also be useful?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff in this PR for dev/bots/test.dart was because changing the output of frameworkVersionFor caused the verifyVersion integration test to fail. I think between that integration test and this unit test, we're covering any territory a doctor test would assert. What do you think?

pcsosinski pushed a commit to pcsosinski/flutter that referenced this pull request Apr 21, 2020
pcsosinski pushed a commit that referenced this pull request Apr 22, 2020
* Update engine, includes Dart 2.8.0-20.11.beta

* git pull --ff-only (#54987)

* [flutter_tools] Reland: fix multiple dart defines (#54973)

* Fix `frameworkVersionFor` for flutter doctor and usage (#54217)

* update engine hash, use dart 2.8.0-20.10-beta (with old naming schema)

Co-authored-by: Jenn Magder <[email protected]>
Co-authored-by: Jonah Williams <[email protected]>
Co-authored-by: Christopher Fujino <[email protected]>
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Beta channel should report version including dev version and dev patch

5 participants