Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #24 from BrunoDeBarros/master
Browse files Browse the repository at this point in the history
Pre-release numbers aren't ordered numerically.
  • Loading branch information
vierbergenlars committed Dec 14, 2012
2 parents bebc412 + 1ba526c commit 57387bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/vierbergenlars/SemVer/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,18 @@ static function gt($v1, $v2) {
if ($b1 < $b2)
return false;

if ($v1->getTag() === '' && $v2->getTag() === '')
return false;
if ($v1->getTag() === '' && $v2->getTag() !== '')
return true; //v1 has no tag, v2 has tag
if ($v1->getTag() !== '' && $v2->getTag() === '')
return false; //v1 has tag, v2 has no tag
if ($v1->getTag() > $v2->getTag())
return true;
if ($v1->getTag() < $v2->getTag())
return false;

// both have tags, sort them naturally to see which one is greater.
$array = array($v1->getTag(), $v2->getTag());
natsort($array);
return reset($array) != $v1->getTag();

}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/regression_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ class regressionTest extends \UnitTestCase {
function testBug23() {
$this->assertTrue(SemVer\version::lt('3.0.0', '4.0.0-beta.1'), '3.0.0 < 4.0.0-beta.1 (Bug #23)');
}

function testBug24() {
$this->assertFalse(SemVer\version::gt('4.0.0-beta.9', '4.0.0-beta.10'), '4.0.0-beta.9 < 4.0.0-beta.10 (Bug #24)');
}

}

0 comments on commit 57387bb

Please sign in to comment.