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

Unified Diff: utils/pub/git_source.dart

Issue 12079112: Make a bunch of stuff in pub synchronous. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after merge. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/error_group.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/git_source.dart
diff --git a/utils/pub/git_source.dart b/utils/pub/git_source.dart
index 2b46706c8a8b168187fa463610ade1b2dddad1dd..b53c7257ad6d78431ffcd11a9807f3d478cef8c4 100644
--- a/utils/pub/git_source.dart
+++ b/utils/pub/git_source.dart
@@ -42,21 +42,19 @@ class GitSource extends Source {
"Please ensure Git is correctly installed.");
}
- return ensureDir(join(systemCacheRoot, 'cache'));
- }).then((_) => _ensureRepoCache(id))
- .then((_) => _revisionCachePath(id))
+ ensureDir(join(systemCacheRoot, 'cache'));
+ return _ensureRepoCache(id);
+ }).then((_) => _revisionCachePath(id))
.then((path) {
revisionCachePath = path;
- return exists(revisionCachePath);
- }).then((exists) {
- if (exists) return;
+ if (entryExists(revisionCachePath)) return;
return _clone(_repoCachePath(id), revisionCachePath, mirror: false);
}).then((_) {
var ref = _getEffectiveRef(id);
if (ref == 'HEAD') return;
return _checkOut(revisionCachePath, ref);
}).then((_) {
- return Package.load(id.name, revisionCachePath, systemCache.sources);
+ return new Package(id.name, revisionCachePath, systemCache.sources);
});
}
@@ -106,10 +104,9 @@ class GitSource extends Source {
/// future that completes once this is finished and throws an exception if it
/// fails.
Future _ensureRepoCache(PackageId id) {
- var path = _repoCachePath(id);
- return exists(path).then((exists) {
- if (!exists) return _clone(_getUrl(id), path, mirror: true);
-
+ return defer(() {
+ var path = _repoCachePath(id);
+ if (!entryExists(path)) return _clone(_getUrl(id), path, mirror: true);
return git.run(["fetch"], workingDir: path).then((result) => null);
});
}
@@ -135,9 +132,10 @@ class GitSource extends Source {
/// the working tree, but instead makes the repository a local mirror of the
/// remote repository. See the manpage for `git clone` for more information.
Future _clone(String from, String to, {bool mirror: false}) {
- // Git on Windows does not seem to automatically create the destination
- // directory.
- return ensureDir(to).then((_) {
+ return defer(() {
+ // Git on Windows does not seem to automatically create the destination
+ // directory.
+ ensureDir(to);
var args = ["clone", from, to];
if (mirror) args.insertRange(1, 1, "--mirror");
return git.run(args);
« no previous file with comments | « utils/pub/error_group.dart ('k') | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698