From 18a2525fc82634395e5e967a142ac6ce2d376891 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 29 Feb 2016 16:25:44 -0800 Subject: [PATCH] Flutter --version can't handle detached HEAD Handle this error condition better and tweak some of the formating for the version string. Fixes #2162 --- packages/flutter_tools/lib/src/runner/version.dart | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/flutter_tools/lib/src/runner/version.dart b/packages/flutter_tools/lib/src/runner/version.dart index 3b53ef8068..f3cc691cb4 100644 --- a/packages/flutter_tools/lib/src/runner/version.dart +++ b/packages/flutter_tools/lib/src/runner/version.dart @@ -9,7 +9,7 @@ String getVersion(String flutterRoot) { String upstream = runSync([ 'git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{u}' ], workingDirectory: flutterRoot).trim(); - String repository = ''; + String repository; int slash = upstream.indexOf('/'); if (slash != -1) { String remote = upstream.substring(0, slash); @@ -22,11 +22,9 @@ String getVersion(String flutterRoot) { 'git', 'log', '-n', '1', '--pretty=format:%H (%ar)' ], 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; - if (engineRevision != null) - version += '\nengine revision : $engineRevision'; - - return version; + return '$from\n$flutterVersion\n$engineRevision'; }