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 library git_source; | 5 library git_source; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import '../../pkg/pathos/lib/path.dart' as path; | 9 import '../../pkg/pathos/lib/path.dart' as path; |
10 | 10 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 /// Attaches a specific commit to [id] to disambiguate it. | 110 /// Attaches a specific commit to [id] to disambiguate it. |
111 Future<PackageId> resolveId(PackageId id) { | 111 Future<PackageId> resolveId(PackageId id) { |
112 return _revisionAt(id).then((revision) { | 112 return _revisionAt(id).then((revision) { |
113 var description = {'url': _getUrl(id), 'ref': _getRef(id)}; | 113 var description = {'url': _getUrl(id), 'ref': _getRef(id)}; |
114 description['resolved-ref'] = revision; | 114 description['resolved-ref'] = revision; |
115 return new PackageId(id.name, this, id.version, description); | 115 return new PackageId(id.name, this, id.version, description); |
116 }); | 116 }); |
117 } | 117 } |
118 | 118 |
| 119 // TODO(keertip): Implement getCachedPackages(). |
| 120 |
119 /// Ensure that the canonical clone of the repository referred to by [id] (the | 121 /// Ensure that the canonical clone of the repository referred to by [id] (the |
120 /// one in `<system cache>/git/cache`) exists and is up-to-date. Returns a | 122 /// one in `<system cache>/git/cache`) exists and is up-to-date. Returns a |
121 /// future that completes once this is finished and throws an exception if it | 123 /// future that completes once this is finished and throws an exception if it |
122 /// fails. | 124 /// fails. |
123 Future _ensureRepoCache(PackageId id) { | 125 Future _ensureRepoCache(PackageId id) { |
124 return defer(() { | 126 return defer(() { |
125 var path = _repoCachePath(id); | 127 var path = _repoCachePath(id); |
126 if (!entryExists(path)) return _clone(_getUrl(id), path, mirror: true); | 128 if (!entryExists(path)) return _clone(_getUrl(id), path, mirror: true); |
127 return git.run(["fetch"], workingDir: path).then((result) => null); | 129 return git.run(["fetch"], workingDir: path).then((result) => null); |
128 }); | 130 }); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 return description['ref']; | 202 return description['ref']; |
201 } | 203 } |
202 | 204 |
203 /// Returns [description] if it's a description, or [PackageId.description] if | 205 /// Returns [description] if it's a description, or [PackageId.description] if |
204 /// it's a [PackageId]. | 206 /// it's a [PackageId]. |
205 _getDescription(description) { | 207 _getDescription(description) { |
206 if (description is PackageId) return description.description; | 208 if (description is PackageId) return description.description; |
207 return description; | 209 return description; |
208 } | 210 } |
209 } | 211 } |
OLD | NEW |