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

Side by Side 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, 4 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Handles version numbers, following the [Semantic Versioning][semver] spec. 5 /// Handles version numbers, following the [Semantic Versioning][semver] spec.
6 /// 6 ///
7 /// [semver]: http://semver.org/ 7 /// [semver]: http://semver.org/
8 library pub.version; 8 library pub.version;
9 9
10 import 'dart:math'; 10 import 'dart:math';
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 includeMin == other.includeMin && 467 includeMin == other.includeMin &&
468 includeMax == other.includeMax; 468 includeMax == other.includeMax;
469 } 469 }
470 470
471 bool get isEmpty => false; 471 bool get isEmpty => false;
472 472
473 bool get isAny => min == null && max == null; 473 bool get isAny => min == null && max == null;
474 474
475 /// Tests if [other] matches falls within this version range. 475 /// Tests if [other] matches falls within this version range.
476 bool allows(Version other) { 476 bool allows(Version other) {
477 if (min != null && other < min) return false; 477 if (min != null) {
478 if (min != null && !includeMin && other == min) return false; 478 if (other < min) return false;
479 if (max != null && other > max) return false; 479 if (!includeMin && other == min) return false;
480 if (max != null && !includeMax && other == max) return false; 480 }
481
482 if (max != null) {
483 if (other > max) return false;
484 if (!includeMax && other == max) return false;
485
486 // If the max isn't itself a pre-release, don't allow any pre-release
487 // versions of the max.
488 //
489 // See: https://www.npmjs.org/doc/misc/semver.html
490 if (!includeMax &&
491 !max.isPreRelease && other.isPreRelease &&
492 other.major == max.major && other.minor == max.minor &&
493 other.patch == max.patch) {
494 return false;
495 }
496 }
497
481 return true; 498 return true;
482 } 499 }
483 500
484 VersionConstraint intersect(VersionConstraint other) { 501 VersionConstraint intersect(VersionConstraint other) {
485 if (other.isEmpty) return other; 502 if (other.isEmpty) return other;
486 503
487 // A range and a Version just yields the version if it's in the range. 504 // A range and a Version just yields the version if it's in the range.
488 if (other is Version) { 505 if (other is Version) {
489 return allows(other) ? other : VersionConstraint.empty; 506 return allows(other) ? other : VersionConstraint.empty;
490 } 507 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 583
567 class _EmptyVersion implements VersionConstraint { 584 class _EmptyVersion implements VersionConstraint {
568 const _EmptyVersion(); 585 const _EmptyVersion();
569 586
570 bool get isEmpty => true; 587 bool get isEmpty => true;
571 bool get isAny => false; 588 bool get isAny => false;
572 bool allows(Version other) => false; 589 bool allows(Version other) => false;
573 VersionConstraint intersect(VersionConstraint other) => this; 590 VersionConstraint intersect(VersionConstraint other) => this;
574 String toString() => '<empty>'; 591 String toString() => '<empty>';
575 } 592 }
OLDNEW
« 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