Skip to content

Commit 0ac0c92

Browse files
authored
Update to latest Flutter candidate version (#9351)
1 parent 941b480 commit 0ac0c92

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

flutter-candidate.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c2ea27002b9c4ab1aff1db6eb1960e4299aca369
1+
a9f310a4c91a523c42495a4e528dad76048c01a5

packages/devtools_shared/lib/src/utils/semantic_version.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ class SemanticVersion with CompareMixin<SemanticVersion> {
3030
// 2.15.0-233.0.dev (dev) (Mon Oct 18 14:06:26 2021 -0700) on "ios_x64"
3131
// 2.15.0-178.1.beta
3232
// 2.6.0-12.0.pre.443
33+
// 2.6.0-12.0.pre-443
3334
//
34-
// So split on the spaces to the version, and then on the dash char to
35+
// First canonicalize the version string to convert any prerelease suffix
36+
// with a "-" to a prerelease suffix with a ".".
37+
final canonicalized = _canonicalizeVersion(versionString);
38+
// Then split on the spaces to the version, and then on the dash char to
3539
// separate the main semantic version from the pre release version.
36-
final splitOnSpaces = versionString.split(' ');
40+
final splitOnSpaces = canonicalized.split(' ');
3741
final version = splitOnSpaces.first;
3842
final splitOnDash = version.split('-');
3943
assert(splitOnDash.length <= 2, 'version: $version');
@@ -115,6 +119,16 @@ class SemanticVersion with CompareMixin<SemanticVersion> {
115119

116120
int? preReleaseMinor;
117121

122+
static final _nonStandardPreReleaseVersionRegex = RegExp(r'(\.pre)-(\d+)$');
123+
124+
/// Canonicalizes a [semanticVersion] with a prerelease version suffix to use
125+
/// a "." instead of a "-".
126+
///
127+
/// e.g. 2.6.0-12.0.pre-443 -> 2.6.0-12.0.pre.443
128+
static String _canonicalizeVersion(String semanticVersion) =>
129+
semanticVersion.replaceFirstMapped(_nonStandardPreReleaseVersionRegex,
130+
(match) => '${match[1]}.${match[2]}');
131+
118132
bool get isPreRelease => preReleaseMajor != null || preReleaseMinor != null;
119133

120134
bool isSupported({required SemanticVersion minSupportedVersion}) =>

packages/devtools_shared/test/semantic_version_test.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ void main() {
2222
SemanticVersion.parse('2.6.0-12.0.pre.443').toString(),
2323
equals('2.6.0-12.0'),
2424
);
25-
2625
expect(
2726
SemanticVersion.parse('2.6.0-1.2.dev+build.metadata').toString(),
2827
equals('2.6.0-1.2'),
2928
);
30-
3129
expect(
3230
SemanticVersion.parse('2.6.0+build.metadata').toString(),
3331
equals('2.6.0'),
3432
);
33+
expect(
34+
SemanticVersion.parse('3.33.0-1.0.pre-1156').toString(),
35+
equals('3.33.0-1.0'),
36+
);
3537
});
3638

3739
test('downgrade', () {

0 commit comments

Comments
 (0)