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

Side by Side Diff: utils/pub/git.dart

Issue 11437019: Add logging system to pub and sprinkle some logging in. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak output. Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/entrypoint.dart ('k') | utils/pub/hosted_source.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Helper functionality for invoking Git. 6 * Helper functionality for invoking Git.
7 */ 7 */
8 library git; 8 library git;
9 9
10 import 'io.dart'; 10 import 'io.dart';
11 import 'log.dart' as log;
11 import 'utils.dart'; 12 import 'utils.dart';
12 13
13 /// Tests whether or not the git command-line app is available for use. 14 /// Tests whether or not the git command-line app is available for use.
14 Future<bool> get isInstalled { 15 Future<bool> get isInstalled {
15 if (_isGitInstalledCache != null) { 16 if (_isGitInstalledCache != null) {
16 // TODO(rnystrom): The sleep is to pump the message queue. Can use 17 // TODO(rnystrom): The sleep is to pump the message queue. Can use
17 // Future.immediate() when #3356 is fixed. 18 // Future.immediate() when #3356 is fixed.
18 return sleep(0).transform((_) => _isGitInstalledCache); 19 return sleep(0).transform((_) => _isGitInstalledCache);
19 } 20 }
20 21
(...skipping 29 matching lines...) Expand all
50 51
51 return _tryGitCommand("git").chain((success) { 52 return _tryGitCommand("git").chain((success) {
52 if (success) return new Future.immediate("git"); 53 if (success) return new Future.immediate("git");
53 54
54 // Git is sometimes installed on Windows as `git.cmd` 55 // Git is sometimes installed on Windows as `git.cmd`
55 return _tryGitCommand("git.cmd").transform((success) { 56 return _tryGitCommand("git.cmd").transform((success) {
56 if (success) return "git.cmd"; 57 if (success) return "git.cmd";
57 return null; 58 return null;
58 }); 59 });
59 }).transform((command) { 60 }).transform((command) {
61 log.fine('Determined git command $command.');
60 _gitCommandCache = command; 62 _gitCommandCache = command;
61 return command; 63 return command;
62 }); 64 });
63 } 65 }
64 66
65 /// Checks whether [command] is the Git command for this computer. 67 /// Checks whether [command] is the Git command for this computer.
66 Future<bool> _tryGitCommand(String command) { 68 Future<bool> _tryGitCommand(String command) {
67 var completer = new Completer<bool>(); 69 var completer = new Completer<bool>();
68 70
69 // If "git --version" prints something familiar, git is working. 71 // If "git --version" prints something familiar, git is working.
70 var future = runProcess(command, ["--version"]); 72 var future = runProcess(command, ["--version"]);
71 73
72 future.then((results) { 74 future.then((results) {
73 var regex = new RegExp("^git version"); 75 var regex = new RegExp("^git version");
74 completer.complete(results.stdout.length == 1 && 76 completer.complete(results.stdout.length == 1 &&
75 regex.hasMatch(results.stdout[0])); 77 regex.hasMatch(results.stdout[0]));
76 }); 78 });
77 79
78 future.handleException((err) { 80 future.handleException((err) {
79 // If the process failed, they probably don't have it. 81 // If the process failed, they probably don't have it.
80 completer.complete(false); 82 completer.complete(false);
81 return true; 83 return true;
82 }); 84 });
83 85
84 return completer.future; 86 return completer.future;
85 } 87 }
OLDNEW
« no previous file with comments | « utils/pub/entrypoint.dart ('k') | utils/pub/hosted_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698