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

Unified Diff: sdk/lib/_internal/pub/lib/src/source/git.dart

Issue 221733002: Don't run "git fetch" multiple times for the same repository. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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].
« 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