Index: sdk/lib/_internal/pub/lib/src/source/git.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/source/git.dart b/sdk/lib/_internal/pub/lib/src/source/git.dart |
index afec7bf0a70e15388184b967b7ae6c3611c9640a..09a6a44ffcc75f51d01fd7878558ef6c8cad0a49 100644 |
--- a/sdk/lib/_internal/pub/lib/src/source/git.dart |
+++ b/sdk/lib/_internal/pub/lib/src/source/git.dart |
@@ -20,6 +20,10 @@ class GitSource extends Source { |
final bool shouldCache = true; |
+ /// The paths to the canonical clones of repositories for which "git fetch" |
+ /// has already been run during this run of pub. |
+ final _updatedRepos = new Set<String>(); |
+ |
GitSource(); |
/// Clones a Git repo to the local filesystem. |
@@ -151,8 +155,13 @@ class GitSource extends Source { |
/// [id]. |
/// |
/// This assumes that the canonical clone already exists. |
- Future _updateRepoCache(PackageId id) => |
- git.run(["fetch"], workingDir: _repoCachePath(id)); |
+ Future _updateRepoCache(PackageId id) { |
+ var path = _repoCachePath(id); |
+ if (_updatedRepos.contains(path)) return new Future.value(); |
+ return git.run(["fetch"], workingDir: path).then((_) { |
+ _updatedRepos.add(path); |
+ }); |
+ } |
/// Runs "git rev-parse" in the canonical clone of the repository referred to |
/// by [id] on the effective ref of [id]. |