Commit 18a2525f authored by Adam Barth's avatar Adam Barth

Flutter --version can't handle detached HEAD

Handle this error condition better and tweak some of the formating for the
version string.

Fixes #2162
parent 758de5ed
...@@ -9,7 +9,7 @@ String getVersion(String flutterRoot) { ...@@ -9,7 +9,7 @@ String getVersion(String flutterRoot) {
String upstream = runSync([ String upstream = runSync([
'git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{u}' 'git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{u}'
], workingDirectory: flutterRoot).trim(); ], workingDirectory: flutterRoot).trim();
String repository = '<unknown>'; String repository;
int slash = upstream.indexOf('/'); int slash = upstream.indexOf('/');
if (slash != -1) { if (slash != -1) {
String remote = upstream.substring(0, slash); String remote = upstream.substring(0, slash);
...@@ -22,11 +22,9 @@ String getVersion(String flutterRoot) { ...@@ -22,11 +22,9 @@ String getVersion(String flutterRoot) {
'git', 'log', '-n', '1', '--pretty=format:%H (%ar)' 'git', 'log', '-n', '1', '--pretty=format:%H (%ar)'
], workingDirectory: flutterRoot).trim(); ], workingDirectory: flutterRoot).trim();
String version = 'Flutter from $repository (on $upstream)\nflutter revision: $revision'; String from = repository == null ? 'Flutter from unknown source' : 'Flutter from $repository (on $upstream)';
String flutterVersion = 'Framework: $revision';
String engineRevision = 'Engine: ${ArtifactStore.engineRevision}';
String engineRevision = ArtifactStore.engineRevision; return '$from\n$flutterVersion\n$engineRevision';
if (engineRevision != null)
version += '\nengine revision : $engineRevision';
return version;
} }
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