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

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

Issue 11276042: Explicitly configure git committer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | « no previous file | utils/tests/pub/test_pub.dart » ('j') | utils/tests/pub/test_pub.dart » ('J')
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 to make working with IO easier. 6 * Helper functionality to make working with IO easier.
7 */ 7 */
8 library io; 8 library io;
9 9
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 if ((Platform.operatingSystem == "windows") && 492 if ((Platform.operatingSystem == "windows") &&
493 (executable.indexOf('\\') == -1)) { 493 (executable.indexOf('\\') == -1)) {
494 args = flatten(["/c", executable, args]); 494 args = flatten(["/c", executable, args]);
495 executable = "cmd"; 495 executable = "cmd";
496 } 496 }
497 497
498 final options = new ProcessOptions(); 498 final options = new ProcessOptions();
499 if (workingDir != null) { 499 if (workingDir != null) {
500 options.workingDirectory = _getDirectory(workingDir).path; 500 options.workingDirectory = _getDirectory(workingDir).path;
501 } 501 }
502 options.environment = environment; 502
503 if (environment != null) {
504 options.environment = environment;
505 }
503 506
504 var future = Process.run(executable, args, options); 507 var future = Process.run(executable, args, options);
505 return future.transform((result) { 508 return future.transform((result) {
506 // TODO(rnystrom): Remove this and change to returning one string. 509 // TODO(rnystrom): Remove this and change to returning one string.
507 List<String> toLines(String output) { 510 List<String> toLines(String output) {
508 var lines = output.split(NEWLINE_PATTERN); 511 var lines = output.split(NEWLINE_PATTERN);
509 if (!lines.isEmpty && lines.last == "") lines.removeLast(); 512 if (!lines.isEmpty && lines.last == "") lines.removeLast();
510 return lines; 513 return lines;
511 } 514 }
512 return new PubProcessResult(toLines(result.stdout), 515 return new PubProcessResult(toLines(result.stdout),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (_isGitInstalledCache != null) { 552 if (_isGitInstalledCache != null) {
550 // TODO(rnystrom): The sleep is to pump the message queue. Can use 553 // TODO(rnystrom): The sleep is to pump the message queue. Can use
551 // Future.immediate() when #3356 is fixed. 554 // Future.immediate() when #3356 is fixed.
552 return sleep(0).transform((_) => _isGitInstalledCache); 555 return sleep(0).transform((_) => _isGitInstalledCache);
553 } 556 }
554 557
555 return _gitCommand.transform((git) => git != null); 558 return _gitCommand.transform((git) => git != null);
556 } 559 }
557 560
558 /// Run a git process with [args] from [workingDir]. 561 /// Run a git process with [args] from [workingDir].
559 Future<PubProcessResult> runGit(List<String> args, {String workingDir}) => 562 Future<PubProcessResult> runGit(List<String> args,
560 _gitCommand.chain((git) => runProcess(git, args, workingDir: workingDir)); 563 {String workingDir, Map<String, String> environment}) {
564 return _gitCommand.chain((git) => runProcess(git, args,
565 workingDir: workingDir, environment: environment));
566 }
561 567
562 /// Returns the name of the git command-line app, or null if Git could not be 568 /// Returns the name of the git command-line app, or null if Git could not be
563 /// found on the user's PATH. 569 /// found on the user's PATH.
564 Future<String> get _gitCommand { 570 Future<String> get _gitCommand {
565 // TODO(nweiz): Just use Future.immediate once issue 3356 is fixed. 571 // TODO(nweiz): Just use Future.immediate once issue 3356 is fixed.
566 if (_gitCommandCache != null) { 572 if (_gitCommandCache != null) {
567 return sleep(0).transform((_) => _gitCommandCache); 573 return sleep(0).transform((_) => _gitCommandCache);
568 } 574 }
569 575
570 return _tryGitCommand("git").chain((success) { 576 return _tryGitCommand("git").chain((success) {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 return new Directory(entry); 754 return new Directory(entry);
749 } 755 }
750 756
751 /** 757 /**
752 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 758 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
753 */ 759 */
754 Uri _getUri(uri) { 760 Uri _getUri(uri) {
755 if (uri is Uri) return uri; 761 if (uri is Uri) return uri;
756 return new Uri.fromString(uri); 762 return new Uri.fromString(uri);
757 } 763 }
OLDNEW
« no previous file with comments | « no previous file | utils/tests/pub/test_pub.dart » ('j') | utils/tests/pub/test_pub.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698