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

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

Issue 432913002: Don't allow pre-release versions of the max in "<" constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | sdk/lib/_internal/pub/test/cache/add/all_adds_all_matching_versions_test.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/version.dart
diff --git a/sdk/lib/_internal/pub/lib/src/version.dart b/sdk/lib/_internal/pub/lib/src/version.dart
index 50cfb0c57123c22b22bbf0f65164932f6e1d86f9..b68c3eda4a854ef7e4822f1b5336c195ed90353e 100644
--- a/sdk/lib/_internal/pub/lib/src/version.dart
+++ b/sdk/lib/_internal/pub/lib/src/version.dart
@@ -474,10 +474,27 @@ class VersionRange implements VersionConstraint {
/// Tests if [other] matches falls within this version range.
bool allows(Version other) {
- if (min != null && other < min) return false;
- if (min != null && !includeMin && other == min) return false;
- if (max != null && other > max) return false;
- if (max != null && !includeMax && other == max) return false;
+ if (min != null) {
+ if (other < min) return false;
+ if (!includeMin && other == min) return false;
+ }
+
+ if (max != null) {
+ if (other > max) return false;
+ if (!includeMax && other == max) return false;
+
+ // If the max isn't itself a pre-release, don't allow any pre-release
+ // versions of the max.
+ //
+ // See: https://www.npmjs.org/doc/misc/semver.html
+ if (!includeMax &&
+ !max.isPreRelease && other.isPreRelease &&
+ other.major == max.major && other.minor == max.minor &&
+ other.patch == max.patch) {
+ return false;
+ }
+ }
+
return true;
}
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/test/cache/add/all_adds_all_matching_versions_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698