Skip to content
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

Allow release versions such as v1.2.3 and release-1.2.3 (as well as other patterns recognized by composer) #37

Closed
Ocramius opened this issue Apr 15, 2018 · 22 comments · Fixed by #199
Assignees
Milestone

Comments

@Ocramius
Copy link
Member

Ref: #35 (comment)

@ntzm
Copy link
Contributor

ntzm commented Apr 26, 2018

Should this be something that is dealt with in nikolaposa/version?

@Ocramius
Copy link
Member Author

@ntzm yeah

@ntzm
Copy link
Contributor

ntzm commented Apr 28, 2018

I opened an issue here: nikolaposa/version#12, looks like it won't be until 3.0 that it's considered

@ciaranmcnulty
Copy link
Contributor

This is pretty important, AFAIK v1.2.3 was not only supported it was encouraged by composer, at least at one stage

@Ocramius
Copy link
Member Author

Talked with @nikolaposa in person about this, and it will likely happen when he has time and willpower (PHP Serbia aftermath first)

@nikolaposa
Copy link
Contributor

nikolaposa commented May 27, 2018

Support for v1.2.3 has already been implemented in /~https://github.com/nikolaposa/version/releases/tag/3.0.0 (15: Relaxed version parsing). I'll consider adding support for release- prefix for 3.1.0.

btw Are there any other prefixes besides v and release that would be worth considering?

@Ocramius
Copy link
Member Author

Maybe @alcohol can answer that

@ntzm
Copy link
Contributor

ntzm commented May 27, 2018

Looking through the composer source, seems it's just release- and v

@nikolaposa
Copy link
Contributor

I mean, if I'm going to introduce that change, I would like it to be something that is not only Composer-specific, but more general, hence the question.

@alcohol
Copy link

alcohol commented May 28, 2018

Composer does not strictly follow semver formatting. If you look at /~https://github.com/composer/semver (specifically, the tests) you'll see it is very similar but there are a few deviations for legacy reasons. I think the v prefix is the only prefix we support. The release- prefix is not supported btw, but it is stripped for legacy reasons AFAIK.

@nikolaposa
Copy link
Contributor

Version parsing was relaxed to supports both v and release- Composer-recognized prefixes in nikolaposa/version:^3.2.0 so I assume this one is fixed?

@Ocramius
Copy link
Member Author

Still need a way to get the symbol name back though, as otherwise we cannot really run a git checkout command with a valid REF

@nikolaposa
Copy link
Contributor

Got it. Can you refer me to some relevant places in code base so I can become more familiar with entire flow and how/whether Version is used in conjunction with other components, i.e. VersionCollection?

@Ocramius
Copy link
Member Author

I think VersionCollection is only used during sorting, lemme dig up the relevant code location

@Ocramius
Copy link
Member Author

@nikolaposa
Copy link
Contributor

Oh, I see the problem now. Versions retrieved from the repository are successfully parsed but their initial form is lost, so casting them back to string yields undesired result.

I'll see what I can do. 🤔 But everything suggests that I'll have to relax my strict adherence to semver.org and the idea that prefix is not part of the version number. Encapsulating that behaviour in a new object as I suggested here would make VersionCollection uselues for your scenario. This will be a fun weekend. :)

@Ocramius
Copy link
Member Author

It would also break (pseudo-code) Version::fromString('1.2.3') == Version::fromString('v1.2.3'), so only ->equals() is viable now.

I also noticed an edge case: we could have duplicate versions (already happened in doctrine) due to v1.2.3 and 1.2.3 both being valid tags on a repository

@nikolaposa
Copy link
Contributor

Something like this: nikolaposa/version@87ab652 could definitely solve the part with constructing and casting Version from/to string. But comparison problem would still remain as the $prefix is used solely for the purpose of preserving the original context.

@Ocramius
Copy link
Member Author

Seems about right

@nikolaposa
Copy link
Contributor

nikolaposa commented Dec 28, 2019

I'm not a huge fan of the idea of getPrefix() becoming part of Version public API, so as an alternative solution I could introduce VersionNumber that would be the SemVer-compliant object, and have the existing Version, with the same API + getPrefix() behaviour proxy to it.

That way I could avoid making some serious BC breaks, as Version behaviour would remain the same from the outside.

@nikolaposa
Copy link
Contributor

I was thinking about v1.2.3 == 1.2.3 scenario. While it might be true that those are not the same versions, I have no idea what reasoning is valid in the case of other comparisons:

$v1 = Version::fromString('v1.2.3');
$v2 = Version::fromString('release-1.2.3');
var_dump($v1->isEqualTo($v2)); //false
var_dump($v1->isGreaterThan($v2)); //???
var_dump($v1->isLessThan($v2)); //???

If it's not equal, is it higher, is it lower? You can't really tell, because prefix does not carry any semantical meaning, unlike pre-release or build extensions for example that are compared lexically in ASCII sort order.

@Ocramius
Copy link
Member Author

Ocramius commented Dec 28, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment