Skip to content

Conversation

@christopherfujino
Copy link
Contributor

@christopherfujino christopherfujino commented Apr 1, 2020

Description

Update the flutter version determination logic to support both old and new tag formats. NOTE: #53775 was landed before this as part of the fix.

Old Tags

  1. v1.2.3
  2. v1.2.3+hotfix.1

New Tags

  1. 1.2.3
  2. 1.2.3-dev.4.5

Related Issues

Fixes #53688

Tests

Updated existing unit test to verify both old and new style tag format.

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.

@fluttergithubbot fluttergithubbot added tool Affects the "flutter" command-line tool. See also t: labels. work in progress; do not review labels Apr 1, 2020
@tvolkert
Copy link
Contributor

tvolkert commented Apr 1, 2020

It might be simpler to try to parse it twice - once using the old regexp and one using the new. And then to add new fields to the GitTagVersion class for the dev.([0-9]+).([0-9]+) values (e.g. devRevision, patchNumber?)

}
}

/// Attempts to reset to the last non-hotfix tag.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing this as from this point forward, upgrades will be possible with mere fast forward.

Copy link
Contributor

Choose a reason for hiding this comment

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

Woot!

static GitTagVersion parse(String version) {
final RegExp versionPattern = RegExp(r'^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:\+hotfix\.([0-9]+))?-([0-9]+)-g([a-f0-9]+)$');
/// Check for the release tag format pre-v1.17.0
static GitTagVersion parseFirstVersion(String version) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a point in time where it would be safe to remove the old tag parsing logic? If so, lets file an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, filed #53850 to track.

}
final List<int> parsedParts = parts.take(5).map<int>((String source) => source == null ? null : int.tryParse(source)).toList();
return GitTagVersion(parsedParts[0], parsedParts[1], parsedParts[2], parsedParts[3], parsedParts[4], parts[5]);
final List<int> parsedParts = parts.take(6).map<int>((String source) => source == null ? null : int.tryParse(source)).toList();
Copy link
Contributor

Choose a reason for hiding this comment

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

why did this change to 6?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, bad copy and paste, fixed.

@christopherfujino christopherfujino marked this pull request as ready for review April 2, 2020 19:40
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

<String>['git', 'tag', '-l', '*.*.*', '--sort=-creatordate'],
throwOnError: true,
workingDirectory: Cache.flutterRoot,
);
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the toolExit below. If git is not installed, I think the exception would be an ArgumentError and not a ProcessException.

Copy link
Contributor Author

@christopherfujino christopherfujino Apr 2, 2020

Choose a reason for hiding this comment

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

should the action point be to remove the reference to git not being installed? I was gonna check if git canRun, but then i realize if they don't have git installed they'll never get to this point, as it would fail earlier.

in terms of how to handle the case of the user not having git installed, I'm planning to address this for #52262

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, removing the reference to git not being installed sgtm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

/// Check for the release tag format from v1.17.0 on
static GitTagVersion parseSecondVersion(String version) {
final RegExp versionPattern = RegExp(
r'^([0-9]+)\.([0-9]+)\.([0-9]+)(?:\+hotfix\.([0-9]+))?(-dev\.[0-9]+\.[0-9]+)?-([0-9]+)-g([a-f0-9]+)$');
Copy link
Member

Choose a reason for hiding this comment

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

Is it supposed to be possible to have both a +hotfix and a -dev?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right, i took out the hotfix from this regex pattern

});

tearDown(() {
//print('Investigate ${parentDirectory.path}');
Copy link
Member

Choose a reason for hiding this comment

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

leftover debug print?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, removed.

}

/// Check for the release tag format from v1.17.0 on
static GitTagVersion parseSecondVersion(String version) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming bikeshed: maybe call this parseVersion() and the other one parseLegacyVersion()? Or feel free to ignore so you don't have to start tests over again just for a naming commit.

Copy link
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 kick the tests off again anyway, so I applied this change.

@christopherfujino
Copy link
Contributor Author

Firebase test lab failure looks to be infra related, following up in infra chat.

@christopherfujino christopherfujino merged commit 2396616 into flutter:master Apr 3, 2020
@christopherfujino christopherfujino deleted the fix-new-version-tag branch April 3, 2020 16:39
pcsosinski pushed a commit to pcsosinski/flutter that referenced this pull request Apr 6, 2020
pcsosinski pushed a commit that referenced this pull request Apr 6, 2020
* Support old and new git release tag formats (#53715)

* Improve downgrade-upgrade integration test (#53775)

* Fix diagnostics crash in profile mode (#53878)

* Prevent diagnostics crash in profile mode

* Prevent diagnostics crash in profile mode

Co-authored-by: Christopher Fujino <[email protected]>
Co-authored-by: Ferhat <[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.

New release tag format (e.g. "1.17.0-dev.0.0") not detected by flutter tool

7 participants