Unverified Commit 64e2e00d authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

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.)
parent d6dad958
......@@ -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);
}
}
\ No newline at end of file
......@@ -116,7 +116,7 @@ void main(List<String> args) {
String getFullTag() {
return getGitOutput(
'describe --match v*.*.* --exclude *-* --first-parent --long --tags',
'describe --match v*.*.* --first-parent --long --tags',
'obtain last released version number',
);
}
......
......@@ -492,7 +492,7 @@ class GitTagVersion {
final String hash;
static GitTagVersion determine() {
final String version = _runGit('git describe --match v*.*.* --exclude *-* --first-parent --long --tags');
final String version = _runGit('git describe --match v*.*.* --first-parent --long --tags');
final RegExp versionPattern = new RegExp('^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)\$');
final List<String> parts = versionPattern.matchAsPrefix(version)?.groups(<int>[1, 2, 3, 4, 5]);
if (parts == null) {
......@@ -507,7 +507,7 @@ class GitTagVersion {
String frameworkVersionFor(String revision) {
if (x == null || y == null || z == null || !revision.startsWith(hash))
return 'unknown';
return '0.0.0-unknown';
if (commits == 0)
return '$x.$y.$z';
return '$x.$y.${z + 1}-pre.$commits';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment