| Index: lib/src/command_runner.dart
|
| diff --git a/lib/src/command_runner.dart b/lib/src/command_runner.dart
|
| index 19d8cf4d18974898c89886ff9f971687d0e44e8f..80815f4fb6c1ab3a3cc78d8ba08c7204464e298b 100644
|
| --- a/lib/src/command_runner.dart
|
| +++ b/lib/src/command_runner.dart
|
| @@ -10,6 +10,7 @@ import 'dart:io';
|
| import 'package:args/args.dart';
|
| import 'package:args/command_runner.dart';
|
| import 'package:http/http.dart' as http;
|
| +import 'package:path/path.dart' as p;
|
|
|
| import 'command/build.dart';
|
| import 'command/cache.dart';
|
| @@ -26,6 +27,7 @@ import 'command/uploader.dart';
|
| import 'command/version.dart';
|
| import 'exceptions.dart';
|
| import 'exit_codes.dart' as exit_codes;
|
| +import 'git.dart' as git;
|
| import 'http.dart';
|
| import 'io.dart';
|
| import 'log.dart' as log;
|
| @@ -89,6 +91,8 @@ class PubCommandRunner extends CommandRunner {
|
| Future runCommand(ArgResults options) async {
|
| log.withPrejudice = options['with-prejudice'];
|
|
|
| + _checkDepsSynced();
|
| +
|
| if (options['version']) {
|
| log.message('Pub ${sdk.version}');
|
| return;
|
| @@ -150,6 +154,31 @@ and include the results in a bug report on http://dartbug.com/new.
|
| log.message(usage);
|
| }
|
|
|
| + /// Print a warning if we're running from the Dart SDK repo and pub isn't
|
| + /// up-to-date.
|
| + ///
|
| + /// This is otherwise hard to tell, and can produce confusing behavior issues.
|
| + void _checkDepsSynced() {
|
| + if (!runningFromDartRepo) return;
|
| +
|
| + var deps = readTextFile(p.join(dartRepoRoot, 'DEPS'));
|
| + var pubRevRegExp = new RegExp(
|
| + r'^ +"pub_rev": +"@([^"]+)"', multiLine: true);
|
| + var match = pubRevRegExp.firstMatch(deps);
|
| + if (match == null) return;
|
| + var depsRev = match[1];
|
| +
|
| + var actualRev = git.runSync(["rev-parse", "HEAD"], workingDir: pubRoot)
|
| + .single;
|
| +
|
| + if (depsRev == actualRev) return;
|
| + log.warning(
|
| + "${log.yellow('Warning:')} the revision of pub in DEPS is "
|
| + "${log.bold(depsRev)},\n"
|
| + "but ${log.bold(actualRev)} is checked out in "
|
| + "${p.relative(pubRoot)}.\n\n");
|
| + }
|
| +
|
| /// Returns the appropriate exit code for [exception], falling back on 1 if no
|
| /// appropriate exit code could be found.
|
| int _chooseExitCode(exception) {
|
|
|