Track calls to 'pub get' from analysis_server

Fixes https://github.com/dart-lang/sdk/issues/32712

Change-Id: I04825e03e57dd2c45de7a332942c0a8e6415286d
Reviewed-on: https://dart-review.googlesource.com/48800
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Kevin Moore 2018-03-29 22:29:49 +00:00 committed by commit-bot@chromium.org
parent 8d689fcca7
commit af22f6a591

View file

@ -690,7 +690,8 @@ class PluginManager {
ProcessResult result = Process.runSync(pubPath, <String>['get'],
stderrEncoding: utf8,
stdoutEncoding: utf8,
workingDirectory: pluginFolder.path);
workingDirectory: pluginFolder.path,
environment: {_pubEnvironmentKey: _getPubEnvironmentValue()});
if (result.exitCode != 0) {
StringBuffer buffer = new StringBuffer();
buffer.writeln('Failed to run pub get');
@ -829,6 +830,33 @@ class PluginManager {
.putIfAbsent(method, () => <int>[])
.add(time);
}
/**
* The console environment key used by the pub tool.
*/
static const String _pubEnvironmentKey = 'PUB_ENVIRONMENT';
/**
* Returns the environment value that should be used when running pub.
*
* Includes any existing environment value, if one exists.
*/
static String _getPubEnvironmentValue() {
// DO NOT update this function without contacting kevmoo.
// We have server-side tooling that assumes the values are consistent.
var values = <String>[];
var existing = Platform.environment[_pubEnvironmentKey];
// If there is an existing value for this var, make sure to include it.
if ((existing != null) && existing.isNotEmpty) {
values.add(existing);
}
values.add('analysis_server.plugin_manager');
return values.join(':');
}
}
/**