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

Unified Diff: sdk/lib/_internal/pub/lib/src/package.dart

Issue 228703006: Add “pub cache repair” to forcibly re-install previously cached packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 6 years, 8 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
Index: sdk/lib/_internal/pub/lib/src/package.dart
diff --git a/sdk/lib/_internal/pub/lib/src/package.dart b/sdk/lib/_internal/pub/lib/src/package.dart
index 7d25a2ea68fae64408aba579e23df90ab1e2a595..8f6f61768b744c400cb11f580b7885ac9407918c 100644
--- a/sdk/lib/_internal/pub/lib/src/package.dart
+++ b/sdk/lib/_internal/pub/lib/src/package.dart
@@ -15,6 +15,18 @@ final _README_REGEXP = new RegExp(r"^README($|\.)", caseSensitive: false);
/// A named, versioned, unit of code and resource reuse.
class Package {
+ /// Compares [a] and [b] orders them by name then version number.
+ ///
+ /// This is normally used as a [Comparator] to pass to sort. This does not
+ /// take a package's description or root directory into account, so multiple
+ /// distinct packages may order the same.
+ static int orderByNameAndVersion(Package a, Package b) {
+ var name = a.name.compareTo(b.name);
+ if (name != 0) return name;
+
+ return a.version.compareTo(b.version);
+ }
+
/// The path to the directory containing the package.
final String dir;

Powered by Google App Engine
This is Rietveld 408576698