8000 `ddev_version_constraint` provides incorrect result: `> 1.24.4` is true for `1.24.4` · Issue #7266 · ddev/ddev · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ddev_version_constraint provides incorrect result: > 1.24.4 is true for 1.24.4 #7266

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

Open
hanoii opened this issue May 5, 2025 · 2 comments

Comments

@hanoii
Copy link
Collaborator
hanoii commented May 5, 2025

This relates to how and why we added pre-releases as part of the code:

ddev/pkg/ddevapp/utils.go

Lines 551 to 555 in c5ad791

normalizedConstraint := constraint
if !strings.Contains(normalizedConstraint, "-") {
// Allow pre-releases to be included in the constraint validation
// @see https://github.com/Masterminds/semver#working-with-prerelease-versions
normalizedConstraint += "-0"

So > 1.24.4 becomes > 1.24.4-0 and a full release (1.24.4) is actually higher.

I played a bit with the code but I really couldn't come up with a solution I like. Furthermore, now that I looked into this, I don't like the normalization at all, specially as the constraint can really really complex, so just appending -0 might not work for all cases. We did it because of dev versions (IIRC). I wonder if we should simply exclude this and let the user add pre-releases to the constraints when needed.

i.e.

This is a command I am using to work around this: ddev debug match-constraint "> 1.24.4-0 <= 1.24.4-zzzzzz || > 1.24.4" which is rather odd.

Ideally, I'd expect that > 1.24.4 would work for regular versions and also accept something like 1.24.5-44

The current version on dev using the git tags gives you 1.24.4-commits-hash-dirty which, evenmore for the semver library, is just wrong because it only uses the last part of the dash as pre-release.

I don't have a solution so far. I am inclined to remove any normalization and let the user define the constraints, if not we might have to look for another semver library.

@hanoii
Copy link
Collaborator Author
hanoii commented May 5, 2025

@rfay
Copy link
Member
rfay commented May 5, 2025

Nice work. I thought the -alpha0 suffix was good enough all those years :)

@stasadev stasadev changed the title Small issue with ddev version constraints, > 1.24.4 is true for 1.2.4 Small issue with ddev version constraints, > 1.24.4 is true for 1.24.4 May 6, 2025
@rfay rfay changed the title Small issue with ddev version constraints, > 1.24.4 is true for 1.24.4 ddev_version_constraint provides incorrect result: > 1.24.4 is true for 1.24.4 May 6, 2025
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

No branches or pull requests

2 participants
0