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

Side by Side Diff: lib/src/git.dart

Issue 1148443005: Use an auto-generated pub snapshot for tests. (Closed) Base URL: git@github.com:dart-lang/pub_test@master
Patch Set: Code review changes Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/io.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 /// Helper functionality for invoking Git. 5 /// Helper functionality for invoking Git.
6 library pub.git; 6 library pub.git;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 "Please ensure Git is correctly installed."); 69 "Please ensure Git is correctly installed.");
70 } 70 }
71 71
72 var result = runProcessSync(_gitCommand, args, 72 var result = runProcessSync(_gitCommand, args,
73 workingDir: workingDir, 73 workingDir: workingDir,
74 environment: environment); 74 environment: environment);
75 if (!result.success) throw new GitException(args, result.stderr.join("\n")); 75 if (!result.success) throw new GitException(args, result.stderr.join("\n"));
76 return result.stdout; 76 return result.stdout;
77 } 77 }
78 78
79 /// Starts a git process and returns it.
80 Future<PubProcess> start(List<String> args,
81 {String workingDir, Map<String, String> environment}) {
82 if (!isInstalled) {
83 fail("Cannot find a Git executable.\n"
84 "Please ensure Git is correctly installed.");
85 }
86
87 return startProcess(_gitCommand, args, workingDir: workingDir,
88 environment: environment);
89 }
90
79 /// Returns the name of the git command-line app, or null if Git could not be 91 /// Returns the name of the git command-line app, or null if Git could not be
80 /// found on the user's PATH. 92 /// found on the user's PATH.
81 String get _gitCommand { 93 String get _gitCommand {
82 if (_commandCache != null) return _commandCache; 94 if (_commandCache != null) return _commandCache;
83 95
84 var command; 96 var command;
85 if (_tryGitCommand("git")) { 97 if (_tryGitCommand("git")) {
86 _commandCache = "git"; 98 _commandCache = "git";
87 } else if (_tryGitCommand("git.cmd")){ 99 } else if (_tryGitCommand("git.cmd")){
88 _commandCache = "git.cmd"; 100 _commandCache = "git.cmd";
(...skipping 13 matching lines...) Expand all
102 var result = runProcessSync(command, ["--version"]); 114 var result = runProcessSync(command, ["--version"]);
103 var regexp = new RegExp("^git version"); 115 var regexp = new RegExp("^git version");
104 return result.stdout.length == 1 && regexp.hasMatch(result.stdout.single); 116 return result.stdout.length == 1 && regexp.hasMatch(result.stdout.single);
105 } on ProcessException catch (error, stackTrace) { 117 } on ProcessException catch (error, stackTrace) {
106 var chain = new Chain.forTrace(stackTrace); 118 var chain = new Chain.forTrace(stackTrace);
107 // If the process failed, they probably don't have it. 119 // If the process failed, they probably don't have it.
108 log.message('Git command is not "$command": $error\n$chain'); 120 log.message('Git command is not "$command": $error\n$chain');
109 return false; 121 return false;
110 } 122 }
111 } 123 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698