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

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

Issue 10873053: Don't print Git output when running Pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 #library('git_source'); 5 #library('git_source');
6 6
7 #import('io.dart'); 7 #import('io.dart');
8 #import('package.dart'); 8 #import('package.dart');
9 #import('source.dart'); 9 #import('source.dart');
10 #import('source_registry.dart'); 10 #import('source_registry.dart');
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 * Ensure that the canonical clone of the repository referred to by [id] (the 115 * Ensure that the canonical clone of the repository referred to by [id] (the
116 * one in `<system cache>/git/cache`) exists and is up-to-date. Returns a 116 * one in `<system cache>/git/cache`) exists and is up-to-date. Returns a
117 * future that completes once this is finished and throws an exception if it 117 * future that completes once this is finished and throws an exception if it
118 * fails. 118 * fails.
119 */ 119 */
120 Future _ensureRepoCache(PackageId id) { 120 Future _ensureRepoCache(PackageId id) {
121 var path = _repoCachePath(id); 121 var path = _repoCachePath(id);
122 return exists(path).chain((exists) { 122 return exists(path).chain((exists) {
123 if (!exists) return _clone(_getUrl(id), path); 123 if (!exists) return _clone(_getUrl(id), path);
124 124
125 return runProcess("git", ["pull", "--force"], workingDir: path, 125 return runProcess("git", ["pull", "--force"], workingDir: path)
126 pipeStdout: true, pipeStderr: true).transform((result) { 126 .transform((result) {
127 if (!result.success) throw 'Git failed.'; 127 if (!result.success) throw 'Git failed.';
128 return null; 128 return null;
129 }); 129 });
130 }); 130 });
131 } 131 }
132 132
133 /** 133 /**
134 * Returns a future that completes to the revision hash of [id]. 134 * Returns a future that completes to the revision hash of [id].
135 */ 135 */
136 Future<String> _revisionAt(PackageId id) { 136 Future<String> _revisionAt(PackageId id) {
137 return runProcess("git", ["rev-parse", _getEffectiveRef(id)], 137 return runProcess("git", ["rev-parse", _getEffectiveRef(id)],
138 workingDir: _repoCachePath(id), pipeStderr: true).transform((result) { 138 workingDir: _repoCachePath(id)).transform((result) {
139 if (!result.success) throw 'Git failed.'; 139 if (!result.success) throw 'Git failed.';
140 return result.stdout[0]; 140 return result.stdout[0];
141 }); 141 });
142 } 142 }
143 143
144 /** 144 /**
145 * Returns the path to the revision-specific cache of [id]. 145 * Returns the path to the revision-specific cache of [id].
146 */ 146 */
147 Future<String> _revisionCachePath(PackageId id) { 147 Future<String> _revisionCachePath(PackageId id) {
148 return _revisionAt(id).transform((rev) { 148 return _revisionAt(id).transform((rev) {
149 var revisionCacheName = '${id.name}-$rev'; 149 var revisionCacheName = '${id.name}-$rev';
150 return join(systemCacheRoot, revisionCacheName); 150 return join(systemCacheRoot, revisionCacheName);
151 }); 151 });
152 } 152 }
153 153
154 /** 154 /**
155 * Clones the repo at the URI [from] to the path [to] on the local filesystem. 155 * Clones the repo at the URI [from] to the path [to] on the local filesystem.
156 */ 156 */
157 Future _clone(String from, String to) { 157 Future _clone(String from, String to) {
158 return runProcess("git", ["clone", from, to], pipeStdout: true, 158 return runProcess("git", ["clone", from, to]).transform((result) {
159 pipeStderr: true).transform((result) {
160 if (!result.success) throw 'Git failed.'; 159 if (!result.success) throw 'Git failed.';
161 return null; 160 return null;
162 }); 161 });
163 } 162 }
164 163
165 /** 164 /**
166 * Checks out the reference [ref] in [repoPath]. 165 * Checks out the reference [ref] in [repoPath].
167 */ 166 */
168 Future _checkOut(String repoPath, String ref) { 167 Future _checkOut(String repoPath, String ref) {
169 return runProcess("git", ["checkout", ref], pipeStdout: true, 168 return runProcess("git", ["checkout", ref], workingDir: repoPath)
170 pipeStderr: true, workingDir: repoPath).transform((result) { 169 .transform((result) {
171 if (!result.success) throw 'Git failed.'; 170 if (!result.success) throw 'Git failed.';
172 return null; 171 return null;
173 }); 172 });
174 } 173 }
175 174
176 /** 175 /**
177 * Returns the path to the canonical clone of the repository referred to by 176 * Returns the path to the canonical clone of the repository referred to by
178 * [id] (the one in `<system cache>/git/cache`). 177 * [id] (the one in `<system cache>/git/cache`).
179 */ 178 */
180 String _repoCachePath(PackageId id) { 179 String _repoCachePath(PackageId id) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 224
226 /** 225 /**
227 * Returns [description] if it's a description, or [PackageId.description] if 226 * Returns [description] if it's a description, or [PackageId.description] if
228 * it's a [PackageId]. 227 * it's a [PackageId].
229 */ 228 */
230 _getDescription(description) { 229 _getDescription(description) {
231 if (description is PackageId) return description.description; 230 if (description is PackageId) return description.description;
232 return description; 231 return description;
233 } 232 }
234 } 233 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698