version.dart 1.07 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import '../artifacts.dart';
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import '../base/process.dart';

String getVersion(String flutterRoot) {
  String upstream = runSync([
    'git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{u}'
  ], workingDirectory: 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: flutterRoot).trim();
    upstream = upstream.substring(slash + 1);
  }
  String revision = runSync([
    'git', 'log', '-n', '1', '--pretty=format:%H (%ar)'
  ], workingDirectory: flutterRoot).trim();
24 25 26 27 28 29 30 31

  String version = 'Flutter from $repository (on $upstream)\nflutter revision: $revision';

  String engineRevision = ArtifactStore.engineRevision;
  if (engineRevision != null)
    version += '\nengine revision : $engineRevision';

  return version;
32
}