Fix frameworkVersionFor for flutter doctor and usage (#54217)

This commit is contained in:
Christopher Fujino
2020-04-08 12:47:05 -07:00
committed by GitHub
parent f8784e72a9
commit 19c8948e61
5 changed files with 86 additions and 51 deletions

View File

@@ -1121,7 +1121,8 @@ String get gitHash {
/// Returns null if the contents are good. Returns a string if they are bad.
/// The string is an error message.
Future<String> verifyVersion(File file) async {
final RegExp pattern = RegExp(r'^\d+\.\d+\.\d+(\+hotfix\.\d+)?(-pre\.\d+)?$');
final RegExp pattern = RegExp(
r'^(\d+)\.(\d+)\.(\d+)((-\d+\.\d+)?\.pre(\.\d+)?)?$');
final String version = await file.readAsString();
if (!file.existsSync())
return 'The version logic failed to create the Flutter version file.';

View File

@@ -23,9 +23,9 @@ void main() {
const List<String> valid_versions = <String>[
'1.2.3',
'12.34.56',
'1.2.3-pre.1',
'1.2.3+hotfix.1',
'1.2.3+hotfix.12-pre.12',
'1.2.3.pre.1',
'1.2.3-4.5.pre',
'1.2.3-5.0.pre.12',
];
for (final String version in valid_versions) {
when(file.readAsString()).thenAnswer((Invocation invocation) => Future<String>.value(version));
@@ -41,8 +41,8 @@ void main() {
const List<String> invalid_versions = <String>[
'1.2.3.4',
'1.2.3.',
'1.2-pre.1',
'1.2.3-pre',
'1.2.pre.1',
'1.2.3-pre.1',
'1.2.3-pre.1+hotfix.1',
' 1.2.3',
'1.2.3-hotfix.1',