Attempt to make flutter compatible with more git versions (#14273)

Fixes https://github.com/flutter/flutter/issues/14232

(I haven't tested this with older versions of git, I'm just going on
what @jason-simmons wrote in the bug.)
This commit is contained in:
Ian Hickson
2018-01-26 16:59:56 -08:00
committed by GitHub
parent d6dad95842
commit 64e2e00d6f
3 changed files with 29 additions and 3 deletions

View File

@@ -164,6 +164,9 @@ Future<Null> _runTests() async {
printOutput: false,
);
// Verify that we correctly generated the version file.
await _verifyVersion(path.join(flutterRoot, 'version'));
// Run tests.
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter'));
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_localizations'));
@@ -579,3 +582,26 @@ bool _isGeneratedPluginRegistrant(File file) {
filename == 'GeneratedPluginRegistrant.h' ||
filename == 'GeneratedPluginRegistrant.m';
}
Future<Null> _verifyVersion(String filename) async {
if (!new File(filename).existsSync()) {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset');
print('The version logic failed to create the Flutter version file.');
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset');
exit(1);
}
final String version = await new File(filename).readAsString();
if (version == '0.0.0-unknown') {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset');
print('The version logic failed to determine the Flutter version.');
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset');
exit(1);
}
final RegExp pattern = new RegExp(r'^[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$');
if (!version.contains(pattern)) {
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset');
print('The version logic generated an invalid version string.');
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset');
exit(1);
}
}