| OLD | NEW |
| 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'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 /// Run a git process with [args] from [workingDir]. Returns the stdout as a | 24 /// Run a git process with [args] from [workingDir]. Returns the stdout as a |
| 25 /// list of strings if it succeeded. Completes to an exception if it failed. | 25 /// list of strings if it succeeded. Completes to an exception if it failed. |
| 26 Future<List<String>> run(List<String> args, [String workingDir]) { | 26 Future<List<String>> run(List<String> args, [String workingDir]) { |
| 27 return _gitCommand.chain((git) { | 27 return _gitCommand.chain((git) { |
| 28 return runProcess(git, args, workingDir); | 28 return runProcess(git, args, workingDir); |
| 29 }).transform((result) { | 29 }).transform((result) { |
| 30 if (!result.success) throw new Exception( | 30 if (!result.success) throw new Exception( |
| 31 'Git error. Command: git ${Strings.join(args, " ")}\n' | 31 'Git error. Command: git ${Strings.join(args, " ")}\n' |
| 32 'Working directory: $currentWorkingDir\n' | |
| 33 '${Strings.join(result.stderr, "\n")}'); | 32 '${Strings.join(result.stderr, "\n")}'); |
| 34 | 33 |
| 35 return result.stdout; | 34 return result.stdout; |
| 36 }); | 35 }); |
| 37 } | 36 } |
| 38 | 37 |
| 39 bool _isGitInstalledCache; | 38 bool _isGitInstalledCache; |
| 40 | 39 |
| 41 /// The cached Git command. | 40 /// The cached Git command. |
| 42 String _gitCommandCache; | 41 String _gitCommandCache; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 }); | 76 }); |
| 78 | 77 |
| 79 future.handleException((err) { | 78 future.handleException((err) { |
| 80 // If the process failed, they probably don't have it. | 79 // If the process failed, they probably don't have it. |
| 81 completer.complete(false); | 80 completer.complete(false); |
| 82 return true; | 81 return true; |
| 83 }); | 82 }); |
| 84 | 83 |
| 85 return completer.future; | 84 return completer.future; |
| 86 } | 85 } |
| OLD | NEW |