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

Unified Diff: utils/pub/git.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « utils/pub/entrypoint.dart ('k') | utils/pub/git_source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/git.dart
diff --git a/utils/pub/git.dart b/utils/pub/git.dart
index b216735f64c94d1dc78800ff46e253b7e956a14d..df2e8565c3a2fc8ea8d77c20b4c2012498bad3d0 100644
--- a/utils/pub/git.dart
+++ b/utils/pub/git.dart
@@ -5,6 +5,7 @@
/// Helper functionality for invoking Git.
library git;
+import 'dart:async';
import 'io.dart';
import 'log.dart' as log;
import 'utils.dart';
@@ -14,18 +15,18 @@ Future<bool> get isInstalled {
if (_isGitInstalledCache != null) {
// TODO(rnystrom): The sleep is to pump the message queue. Can use
// Future.immediate() when #3356 is fixed.
- return sleep(0).transform((_) => _isGitInstalledCache);
+ return sleep(0).then((_) => _isGitInstalledCache);
}
- return _gitCommand.transform((git) => git != null);
+ return _gitCommand.then((git) => git != null);
}
/// Run a git process with [args] from [workingDir]. Returns the stdout as a
/// list of strings if it succeeded. Completes to an exception if it failed.
Future<List<String>> run(List<String> args, {String workingDir}) {
- return _gitCommand.chain((git) {
+ return _gitCommand.then((git) {
return runProcess(git, args, workingDir: workingDir);
- }).transform((result) {
+ }).then((result) {
if (!result.success) throw new Exception(
'Git error. Command: git ${Strings.join(args, " ")}\n'
'${Strings.join(result.stderr, "\n")}');
@@ -44,18 +45,18 @@ String _gitCommandCache;
Future<String> get _gitCommand {
// TODO(nweiz): Just use Future.immediate once issue 3356 is fixed.
if (_gitCommandCache != null) {
- return sleep(0).transform((_) => _gitCommandCache);
+ return sleep(0).then((_) => _gitCommandCache);
}
- return _tryGitCommand("git").chain((success) {
+ return _tryGitCommand("git").then((success) {
if (success) return new Future.immediate("git");
// Git is sometimes installed on Windows as `git.cmd`
- return _tryGitCommand("git.cmd").transform((success) {
+ return _tryGitCommand("git.cmd").then((success) {
if (success) return "git.cmd";
return null;
});
- }).transform((command) {
+ }).then((command) {
log.fine('Determined git command $command.');
_gitCommandCache = command;
return command;
@@ -69,17 +70,16 @@ Future<bool> _tryGitCommand(String command) {
// If "git --version" prints something familiar, git is working.
var future = runProcess(command, ["--version"]);
- future.then((results) {
- var regex = new RegExp("^git version");
- completer.complete(results.stdout.length == 1 &&
- regex.hasMatch(results.stdout[0]));
- });
-
- future.handleException((err) {
- // If the process failed, they probably don't have it.
- completer.complete(false);
- return true;
- });
+ future
+ .then((results) {
+ var regex = new RegExp("^git version");
+ completer.complete(results.stdout.length == 1 &&
+ regex.hasMatch(results.stdout[0]));
+ })
+ .catchError((err) {
+ // If the process failed, they probably don't have it.
+ completer.complete(false);
+ });
return completer.future;
}
« no previous file with comments | « utils/pub/entrypoint.dart ('k') | utils/pub/git_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698