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

_clean_version. with semantic version with underscore returns wrong version #138

Open
briandfoy opened this issue Jun 17, 2024 · 10 comments

Comments

@briandfoy
Copy link

This is related to briandfoy/cpan-mini-inject#11. It seems that _clean_version does the wrong thing with semantic versions that have a dev component:

$ perl -MCPAN::Meta::Converter -MCPAN::Meta -E 'say CPAN::Meta->VERSION; say CPAN::Meta::Converter::_clean_version("v1.0.0_03")'
2.150010
v1.0.3
@karenetheridge
Copy link
Member

This looks correct to me. In what way do you believe it is wrong?

@briandfoy
Copy link
Author

If the version of a module is v1.0.0_03, then the version is not v1.0.3. See the linked ticket for the user report.

@XSven
Copy link

XSven commented Jun 18, 2024

@karenetheridge
v1.0.3 refers to a stable bugfix release and v1.0.0_03 refers to the 3rd development/trial/dev/alpha release of the final release which will have the v1.0.0 version specification.

@karenetheridge
Copy link
Member

I don't think that's how it works. The concept of alpha/trial doesn't exist in canonical versions, so the underscore is removed and 0_03 becomes a 3.

note the PV value: "\x01\x00\x03"

$; perl -MDevel::Peek -wle'Dump v1.0.0_03'
SV = PVMG(0x13d037d30) at 0x13d017c18
  REFCNT = 1
  FLAGS = (RMG,POK,IsCOW,READONLY,PROTECT,pPOK)
  IV = 0
  NV = 0
  PV = 0x6000006848f0 "\x01\x00\x03"\0
  CUR = 3
  LEN = 16
  COW_REFCNT = 0
  MAGIC = 0x600000a806f0
    MG_VIRTUAL = 0
    MG_TYPE = PERL_MAGIC_vstring(V)
    MG_LEN = 9
    MG_PTR = 0x6000006848e0 "v1.0.0_03"

@Leont
Copy link
Member

Leont commented Jun 18, 2024

I don't think that's how it works. The concept of alpha/trial doesn't exist in canonical versions, so the underscore is removed and 0_03 becomes a 3.

That's a v-string, not a version object.

@Grinnz
Copy link
Contributor

Grinnz commented Jun 18, 2024

It is still equivalent to version v1.0.3 as the underscore does not have semantic value in any versions since version.pm 0.9915.

@Grinnz
Copy link
Contributor

Grinnz commented Jun 18, 2024

@XSven
Copy link

XSven commented Jun 19, 2024

I have read the guide to versions already and I have read the section about "Underscores in Versions" again. It seems that I have done something wrong because I haven't followed the recommendation not to use underscores in tuple versions. But my use case remains:

How to specify the 3rd trial release of a 1.0.0 (tuple version) target release?

Semantic Versioning would allow this 1.0.0-alpha.3. What is offered by Perl? The post hasn't provided an answer, at least I couldn't find it.

@Grinnz
Copy link
Contributor

Grinnz commented Jun 19, 2024

The indication of a trial release is not required to be done through the version. The most compatible and consistent way to achieve that is to to release with a module version of 'v1.0.0' and include -TRIAL3 at the end of the archive name, and a release_status of 'testing'. (modern authoring tools will automate the release status and -TRIAL when told to do a trial release, but I don't know if any will automate numbered trials.)

@Grinnz
Copy link
Contributor

Grinnz commented Jun 19, 2024

An option if you wish to do it through the pure version, though not recommended because it is not consistently interpreted, is to append another segment to the version and include an underscore in it somewhere.

briandfoy added a commit to briandfoy/cpan-mini-inject that referenced this issue Jul 30, 2024
This path overrides CPAN::Meta::Converter::_clean_version
so that the string in the the `provides` is passed on 
literally instead of interpreted. If you use something
like v1.0.0_02, you get the same string back. This is 
despite the wisdom of using that (see the GitHub thread).

This is related to Perl-Toolchain-Gang/CPAN-Meta#138 which 
makes the same change (but has not been merged).

Note that all of this depends on the `provides` section
having the right value. If you generate META.json or 
META.yaml with the current CPAN::Meta, it may modify
the version value that it puts under `provides` even though
the top-level `version` is unmolested. That is, this
fix is half the fix and the rest depends on the distro.

If this really bugs you, you'll have to hand-edit
the META.* until the other side of the fix is in.
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

5 participants