Skip to content

More correct requirement specifiers #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 15, 2019
Merged

More correct requirement specifiers #45

merged 3 commits into from
Feb 15, 2019

Conversation

deivid-rodriguez
Copy link
Contributor

The way prereleases are designed by rubygems is the following. The first segment containing a non numeric character is considered the begining of the prerelease part of the version. For example, in "5.0.1.x", "5.0.1" is the release part, and "x" is the prerelease part (it could contain more segments, but in this case is just one). The way versions are compared is. Each of the segments in the release part (left to right) is compared to each other (assuming 0 is one of the versions don't have the segment). If every thing is the same, the prerelease parts are compared in the same way, except that segments containing non numeric characters are compared lexicographically. That means that 5.0.1.rc1 would be considered lower than 5.0.1.x, and thus wouldn't be allowed here.

The funny part is that this currently works the way one would expect, but it's only due to what I consider a bug in rubygems. See rubygems/rubygems#2597.

@deivid-rodriguez
Copy link
Contributor Author

Actually, after having a look at #42, the current version is exactly what we want (not allow 5.0.1 prereleases), although >= 5.0.1 would be a bit clearer and technically more correct. Anyways, this PR is not really needed even if rubygems behavior was fixed.

@deivid-rodriguez
Copy link
Contributor Author

I changed the PR to the most correct version, just in case :)

Technically, if the rails team released a new "5.0.1.zeitgeist"
prerelease version and rubygems behavior was fixed according to
rubygems/rubygems#2597, this requirement would
no longer do what it's supposed to do.

This will clearly not happen, but I wanted to raise awareness of this
xD.
@rafaelfranca rafaelfranca merged commit 21014e4 into rails:master Feb 15, 2019
ghost pushed a commit to rubygems/rubygems that referenced this pull request Apr 15, 2019
2651: Restore transitiveness of version comparison r=bronzdoc a=deivid-rodriguez

# Description:

This is an alternative to #2597 fix to #2595.

I strongly think this is the best way to fix this, even if it _could_ create some incompatibility with some gems relying on things like "~> 5.x" being lower than _all_ 5.0.0 prereleases.

As explained in that discussion, the official way that's recommended in the docs to match all prereleases is "~> 5.a", because "a" is the first string in lexicographical order.

I created PRs to the two gems I found relying on this:

* rails/activemodel-serializers-xml#17
* rails/rails-controller-testing#45

I would consider this a bug fix and ship it normally on a bug fix release, but I can understand if others prefer a more conservative approach.

# Tasks:

- [x] Describe the problem / feature
- [x] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).

Co-authored-by: John Hawthorn <[email protected]>
pombredanne pushed a commit to aboutcode-org/univers that referenced this pull request Dec 7, 2021
2651: Restore transitiveness of version comparison r=bronzdoc a=deivid-rodriguez

# Description:

This is an alternative to #2597 fix to #2595.

I strongly think this is the best way to fix this, even if it _could_ create some incompatibility with some gems relying on things like "~> 5.x" being lower than _all_ 5.0.0 prereleases.

As explained in that discussion, the official way that's recommended in the docs to match all prereleases is "~> 5.a", because "a" is the first string in lexicographical order.

I created PRs to the two gems I found relying on this:

* rails/activemodel-serializers-xml#17
* rails/rails-controller-testing#45

I would consider this a bug fix and ship it normally on a bug fix release, but I can understand if others prefer a more conservative approach.

# Tasks:

- [x] Describe the problem / feature
- [x] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).

Co-authored-by: John Hawthorn <[email protected]>
pombredanne pushed a commit to aboutcode-org/univers that referenced this pull request Dec 7, 2021
2651: Restore transitiveness of version comparison r=bronzdoc a=deivid-rodriguez

# Description:

This is an alternative to #2597 fix to #2595.

I strongly think this is the best way to fix this, even if it _could_ create some incompatibility with some gems relying on things like "~> 5.x" being lower than _all_ 5.0.0 prereleases.

As explained in that discussion, the official way that's recommended in the docs to match all prereleases is "~> 5.a", because "a" is the first string in lexicographical order.

I created PRs to the two gems I found relying on this:

* rails/activemodel-serializers-xml#17
* rails/rails-controller-testing#45

I would consider this a bug fix and ship it normally on a bug fix release, but I can understand if others prefer a more conservative approach.

# Tasks:

- [x] Describe the problem / feature
- [x] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).

Co-authored-by: John Hawthorn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants