Commit 835e7f25 authored by Adam Barth's avatar Adam Barth

Improve flutter --version output

Sample output:

```
Flutter
Repository: git@github.com:flutter/flutter.git
Branch: master
Revision: 7be58b1a (62 minutes ago)
```

Fixes #433
parent 7be58b1a
......@@ -141,15 +141,31 @@ class FlutterCommandRunner extends CommandRunner {
if (globalResults.wasParsed('package-root'))
ArtifactStore.packageRoot = globalResults['package-root'];
if (globalResults['version']) {
String revision = runSync([
'git', 'rev-parse', 'HEAD'
if (globalResults['version'])
return _printVersion();
return super.runCommand(globalResults);
}
Future<int> _printVersion() async {
String upstream = runSync([
'git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{u}'
], workingDirectory: ArtifactStore.flutterRoot).trim();
String repository = '<unknown>';
int slash = upstream.indexOf('/');
if (slash != -1) {
String remote = upstream.substring(0, slash);
repository = runSync([
'git', 'ls-remote', '--get-url', remote
], workingDirectory: ArtifactStore.flutterRoot).trim();
print('flutter version $revision');
return new Future<int>.value(0);
upstream = upstream.substring(slash + 1);
}
String revision = runSync([
'git', 'log', '-n', '1', '--pretty=format:%H (%ar)'
], workingDirectory: ArtifactStore.flutterRoot).trim();
return super.runCommand(globalResults);
print('Flutter\nRepository: $repository\nBranch: $upstream\nRevision: $revision');
return 0;
}
List<BuildConfiguration> _createBuildConfigurations(ArgResults globalResults) {
......
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