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

Pre-release numbers aren't ordered numerically. #24

Merged
merged 4 commits into from
Dec 14, 2012
Merged

Pre-release numbers aren't ordered numerically. #24

merged 4 commits into from
Dec 14, 2012

Conversation

pocketarc
Copy link
Contributor

The following returns true:

\vierbergenlars\SemVer\version::gt('4.0.0-beta.9', '4.0.0-beta.10')

When it really shouldn't. I used PHP's natsort() as a quick fix for this (it sorts the two tags naturally). I'm not sure if this fits in well with how you do things, so feel free to change it in whatever way you see fit, but it has solved my problem.

@pocketarc
Copy link
Contributor Author

Also worth noting is that my build passed in Travis, so there were no tests for this at all. I haven't created new unit tests for this, but if I do, I'll add them to the pull request.

@vierbergenlars
Copy link
Owner

Thanks for your pull request @BrunoDEBARROS. I did never realize this problem.

However, there are a few small problems with your fix. I'll put those in the diff

if ($v1->getTag() < $v2->getTag())
return false;

if (!isset($t[$v1->getTag()]) && !isset($t[$v2->getTag()])) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Variable $t is never defined. It was in an older version.
    Because I improved tag handling, it is no longer necessary to check for the cases '' or '-' or '--', because they are simply never created on tags.
  • Is this condition necessary? Isn't it easier to first check for no tags and then return false (as they are equal and not greater)

@pocketarc
Copy link
Contributor Author

Regarding #1, you're right. My apologies, I built this into an older version of the codebase. I've updated this.
Regarding #2, you're also right. I've updated this.

Let me know what you think.

@vierbergenlars
Copy link
Owner

I think it looks pretty good.
I'll merge it this weekend as I don't have time tomorrow and it's getting quite late for me right now.

It would be nice if you could add some unit tests, but if you don't have time, i'll have a look at it next week.

@pocketarc
Copy link
Contributor Author

Added a test to your regressionTest. I noticed that for issue #23 you changed quite a few of the tests, but as far as I know, it was just updating tests that rely on old behavior, so I'm not sure if you want tests to be added elsewhere, or if you want more test cases for this issue. Let me know.

@vierbergenlars
Copy link
Owner

I think one test is enough to cover this case.
A lot of tests were changed in a previous release, but those tests were relying on an internal workaround that was fixed together with bug #23.
Merging right now, a new release will be published tomorrow

vierbergenlars added a commit that referenced this pull request Dec 14, 2012
Pre-release numbers aren't ordered numerically.
@vierbergenlars vierbergenlars merged commit 57387bb into vierbergenlars:master Dec 14, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants