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

Unified Diff: lib/src/command/cache_add.dart

Issue 1528523003: Clean up the semantics of package descriptions. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 5 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 | « no previous file | lib/src/entrypoint.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/command/cache_add.dart
diff --git a/lib/src/command/cache_add.dart b/lib/src/command/cache_add.dart
index d39fe96e12d691c778b8d4e324f867f4e1428668..3bc01e50a10a192e4ab2e0f8123a98ef42160575 100644
--- a/lib/src/command/cache_add.dart
+++ b/lib/src/command/cache_add.dart
@@ -10,7 +10,7 @@ import 'package:pub_semver/pub_semver.dart';
import '../command.dart';
import '../log.dart' as log;
-import '../package.dart';
+import '../source/hosted.dart';
import '../utils.dart';
/// Handles the `cache add` pub command.
@@ -59,18 +59,16 @@ class CacheAddCommand extends PubCommand {
var source = cache.sources["hosted"];
// TODO(rnystrom): Allow specifying the server.
- var ids = await source.getVersions(
- new PackageRef(package, 'hosted', package));
- var versions = ids.map((id) => id.version)
- .where(constraint.allows).toList();
+ var ids = (await source.getVersions(HostedSource.refFor(package)))
+ .where((id) => constraint.allows(id.version))
+ .toList();
- if (versions.isEmpty) {
+ if (ids.isEmpty) {
// TODO(rnystrom): Show most recent unmatching version?
fail("Package $package has no versions that match $constraint.");
}
- downloadVersion(version) async {
- var id = new PackageId(package, source.name, version, package);
+ downloadVersion(id) async {
if (cache.contains(id)) {
// TODO(rnystrom): Include source and description if not hosted.
// See solve_report.dart for code to harvest.
@@ -84,12 +82,12 @@ class CacheAddCommand extends PubCommand {
if (argResults["all"]) {
// Install them in ascending order.
- versions.sort();
- await Future.forEach(versions, downloadVersion);
+ ids.sort((id1, id2) => id1.version.compareTo(id2.version));
+ await Future.forEach(ids, downloadVersion);
} else {
// Pick the best matching version.
- versions.sort(Version.prioritize);
- await downloadVersion(versions.last);
+ ids.sort((id1, id2) => Version.prioritize(id1.version, id2.version));
+ await downloadVersion(ids.last);
}
}
}
« no previous file with comments | « no previous file | lib/src/entrypoint.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698