Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Unified Diff: lib/src/command_runner.dart

Issue 1227913009: Warn if pub isn't up-to-date in the SDK repo. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/command_runner.dart
diff --git a/lib/src/command_runner.dart b/lib/src/command_runner.dart
index 19d8cf4d18974898c89886ff9f971687d0e44e8f..3a16621776b56d0141b222b66a79595801f4a86a 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,30 @@ 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);
Bob Nystrom 2015/07/13 17:15:35 Long line.
nweiz 2015/07/13 20:13:34 Done.
+ var match = pubRevRegExp.firstMatch(deps);
+ if (match == null) return;
Bob Nystrom 2015/07/13 17:15:35 Do we want to silently fail?
nweiz 2015/07/13 20:13:33 I don't really want to make this a place where we
+ var depsRev = match[1];
+
+ var actualRev = git.runSync(["rev-parse", "HEAD"], workingDir: pubRoot)
Bob Nystrom 2015/07/13 17:15:35 What does this do to the test cycle time?
nweiz 2015/07/13 20:13:34 I'll run a test. I suspect it won't be that bad; g
+ .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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698