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

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

Issue 745153002: Make pub's binstubs resilient to changes in snapshot format. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years 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 | « sdk/lib/_internal/pub/lib/src/log.dart ('k') | sdk/lib/_internal/pub/lib/src/source/hosted.dart » ('j') | 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 9d08f83fc1e7588ba35494409bf0c9608a786c4f..58ab066ad33bf4982bccdd41671c1cfcbc79bc25 100644
--- a/sdk/lib/_internal/pub/lib/src/source/git.dart
+++ b/sdk/lib/_internal/pub/lib/src/source/git.dart
@@ -143,8 +143,8 @@ class GitSource extends CachedSource {
/// Resets all cached packages back to the pristine state of the Git
/// repository at the revision they are pinned to.
- Future<Pair<int, int>> repairCachedPackages() {
- if (!dirExists(systemCacheRoot)) return new Future.value(new Pair(0, 0));
+ Future<Pair<int, int>> repairCachedPackages() async {
+ if (!dirExists(systemCacheRoot)) return new Pair(0, 0);
var successes = 0;
var failures = 0;
@@ -159,25 +159,30 @@ class GitSource extends CachedSource {
// (pinned to different commits). The sort order of those is unspecified.
packages.sort(Package.orderByNameAndVersion);
- return Future.wait(packages.map((package) {
+ for (var package in packages) {
log.message("Resetting Git repository for "
"${log.bold(package.name)} ${package.version}...");
- // Remove all untracked files.
- return git.run(["clean", "-d", "--force", "-x"],
- workingDir: package.dir).then((_) {
+ try {
+ // Remove all untracked files.
+ await git.run(["clean", "-d", "--force", "-x"],
+ workingDir: package.dir);
+
// Discard all changes to tracked files.
- return git.run(["reset", "--hard", "HEAD"], workingDir: package.dir);
- }).then((_) {
+ await git.run(["reset", "--hard", "HEAD"], workingDir: package.dir);
+
successes++;
- }).catchError((error, stackTrace) {
- failures++;
+ } on git.GitException catch (error, stackTrace) {
log.error("Failed to reset ${log.bold(package.name)} "
"${package.version}. Error:\n$error");
log.fine(stackTrace);
failures++;
- }, test: (error) => error is git.GitException);
- })).then((_) => new Pair(successes, failures));
+
+ tryDeleteEntry(package.dir);
+ }
+ }
+
+ return new Pair(successes, failures);
}
/// Ensure that the canonical clone of the repository referred to by [id] (the
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/log.dart ('k') | sdk/lib/_internal/pub/lib/src/source/hosted.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698