clean up git commits (#3578)
This commit is contained in:
@@ -23,7 +23,7 @@ class ConfigCommand extends FlutterCommand {
|
||||
final String description =
|
||||
'Configure Flutter settings.\n\n'
|
||||
'The Flutter tool anonymously reports feature usage statistics and basic crash reports to help improve\n'
|
||||
'Flutter tools over time. See Google\'s privacy policy: www.google.com/intl/en/policies/privacy';
|
||||
'Flutter tools over time. See Google\'s privacy policy: https://www.google.com/intl/en/policies/privacy/';
|
||||
|
||||
@override
|
||||
final List<String> aliases = <String>['configure'];
|
||||
|
||||
@@ -7,6 +7,13 @@ import 'dart:io';
|
||||
import '../artifacts.dart';
|
||||
import '../base/process.dart';
|
||||
|
||||
final Set<String> kKnownBranchNames = new Set<String>.from(<String>[
|
||||
'master',
|
||||
'alpha',
|
||||
'hackathon',
|
||||
'beta'
|
||||
]);
|
||||
|
||||
class FlutterVersion {
|
||||
FlutterVersion(this.flutterRoot) {
|
||||
_channel = _runGit('git rev-parse --abbrev-ref --symbolic @{u}');
|
||||
@@ -35,13 +42,13 @@ class FlutterVersion {
|
||||
|
||||
String _frameworkRevision;
|
||||
String get frameworkRevision => _frameworkRevision;
|
||||
String get frameworkRevisionShort => _runGit('git rev-parse --short $frameworkRevision');
|
||||
String get frameworkRevisionShort => _shortGitRevision(frameworkRevision);
|
||||
|
||||
String _frameworkAge;
|
||||
String get frameworkAge => _frameworkAge;
|
||||
|
||||
String get engineRevision => ArtifactStore.engineRevision;
|
||||
String get engineRevisionShort => _runGit('git rev-parse --short $engineRevision');
|
||||
String get engineRevisionShort => _shortGitRevision(engineRevision);
|
||||
|
||||
String _runGit(String command) => runSync(command.split(' '), workingDirectory: flutterRoot);
|
||||
|
||||
@@ -57,14 +64,21 @@ class FlutterVersion {
|
||||
return new FlutterVersion(flutterRoot != null ? flutterRoot : ArtifactStore.flutterRoot);
|
||||
}
|
||||
|
||||
static String getVersionString() {
|
||||
/// Return a short string for the version (`a76bc8e22b/alpha`).
|
||||
static String getVersionString({ bool whitelistBranchName: false }) {
|
||||
final String cwd = ArtifactStore.flutterRoot;
|
||||
|
||||
String commit = _runSync('git', <String>['rev-parse', 'HEAD'], cwd);
|
||||
if (commit.length > 8)
|
||||
commit = commit.substring(0, 8);
|
||||
String commit = _shortGitRevision(_runSync('git', <String>['rev-parse', 'HEAD'], cwd));
|
||||
commit = commit.isEmpty ? 'unknown' : commit;
|
||||
|
||||
String branch = _runSync('git', <String>['rev-parse', '--abbrev-ref', 'HEAD'], cwd);
|
||||
branch = branch == 'HEAD' ? 'master' : branch;
|
||||
|
||||
if (whitelistBranchName || branch.isEmpty) {
|
||||
// Only return the branch names we know about; arbitrary branch names might contain PII.
|
||||
if (!kKnownBranchNames.contains(branch))
|
||||
branch = 'dev';
|
||||
}
|
||||
|
||||
return '$commit/$branch';
|
||||
}
|
||||
@@ -74,3 +88,7 @@ String _runSync(String executable, List<String> arguments, String cwd) {
|
||||
ProcessResult results = Process.runSync(executable, arguments, workingDirectory: cwd);
|
||||
return results.exitCode == 0 ? results.stdout.trim() : '';
|
||||
}
|
||||
|
||||
String _shortGitRevision(String revision) {
|
||||
return revision.length > 10 ? revision.substring(0, 10) : revision;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ const String _kFlutterUA = 'UA-67589403-5';
|
||||
|
||||
class Usage {
|
||||
Usage() {
|
||||
_analytics = new AnalyticsIO(_kFlutterUA, 'flutter', FlutterVersion.getVersionString());
|
||||
String version = FlutterVersion.getVersionString(whitelistBranchName: true);
|
||||
_analytics = new AnalyticsIO(_kFlutterUA, 'flutter', version);
|
||||
_analytics.analyticsOpt = AnalyticsOpt.optOut;
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ class Usage {
|
||||
if (isFirstRun)
|
||||
return new _MockUsageTimer();
|
||||
else
|
||||
return new UsageTimer._(event, _analytics.startTimer(event));
|
||||
return new UsageTimer._(event, _analytics.startTimer(event, category: 'flutter'));
|
||||
}
|
||||
|
||||
void sendException(dynamic exception, StackTrace trace) {
|
||||
|
||||
Reference in New Issue
Block a user