-
Notifications
You must be signed in to change notification settings - Fork 358
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
support for semver version constraint operator #2976
Comments
Duplicate of #2102 (although I suggest different / possibly cleaner semantics), feel free to close. |
Sounds good, and thanks for suggesting this. For the first case, for example, in opam terms it would be more consistent to have
I think this is better because of the tilde semantics in our total ordering: I don't know though how to handle the 2nd/6th cases:
Maybe it makes perfect sense with semver in mind, but I find such a specific-case rule quite distasteful, or is it just me ? Now I can well understand that if the If we skip that last rule, one definition could be:
A number is defined as a maximal sequence of contiguous digits, as used by our version ordering. This may yield weird results with e.g.
(the reason for the "after a number" part is that we want |
Sounds good. But I think handling the major version 0 case is quite important, with 7.7% of packages in the repository (539/6997) having such a major version. Let me rephrase in a way that you'll perhaps find more elegant. If there is a sequence of zeroes at the head of the version:
Does this sound better? |
Sounds more intuitive, indeed. The definition for
Would that make sense ? |
Let's see...
I also think that
is far too lenient. For example this will consider things such as dates or even parts of git hashes (!) as semver version numbers. Which really doesn't seem good. I suggest, at least, requiring a semver version to appear at the beginning of the package version, so |
I am not so sure: for example, JS recently moved to have versions prefixed by For the definition, well spotted. So we would need to be more specific:
|
Dose has a Semantic versioning comparing function that can be used in opam. Tested on npm, so pretty solid (or at least it was last year). |
Discussed in opam dev meeting: putting this on the triage list for opam 2.2 to see if we can add this as a lightweight operator. |
I think we should take into account the debian versioning scheme when adding this feature. If The version in the upper constraint to make the above precise would be the greatest lower bound of the sequence {1.2, 1.2~, 1.2~~, 1.2~~~, ...}. This cannot be expressed without changing the version syntax, but an alternative would be to introduce a "significantly-less" operator, say |
I like this proposal, but I think a plain next-major constraint, as provided for npm and php composer as |
Many people prefer semantic versioning (although perhaps fewer in the opam ecosystem than elsewhere). Even when not followed entirely faithfully, semver-style version constraints greatly reduce the number of completely unconstrained dependency edges (which I believe currently are the majority in the repository) and thus downstream breakage and manual work for opam admin staff after a new major release of a popular package is released.
I propose opam to support the semver version constraint operator,
~
. The semantics are as follows:~ x.y.z
wherex > 0
expands to>= x.y.z & < x.y+1.0
~ x.y
wherex > 0
expands to>= x.y & < x+1.0
~ x
wherex > 0
expands to>= x & < x+1
~ 0.y.z
expands to>= 0.y.z & < 0.y+1.0
~ 0.y
expands to>= 0.y & < 0.y+1
You may notice that the behavior with major version 0 is not quite what the semver specification would naively imply (it says that at
0.y.z
anything may change at any time). This deviation is intentional and legal (semver does not define any such constraint operator), and provides a meaningful way for a package still in major version 0 to release bugfixes.You may also notice that there is no mention of alphanumeric versions (alpha, beta, etc). As far as I know these basically do not get used in opam repository so it seems pointless to drag in their (considerably complex and, I think, inexpressible through simple expansion) semantics.
The text was updated successfully, but these errors were encountered: