Perl-Toolchain-Gang / CPAN-Meta

Specifications for CPAN distribution META files
37 stars 40 forks source link

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

Open briandfoy opened 5 months ago

briandfoy commented 5 months ago

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 commented 5 months ago

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

briandfoy commented 5 months ago

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 commented 5 months ago

@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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

For further edification: https://blogs.perl.org/users/grinnz/2018/04/a-guide-to-versions-in-perl.html

XSven commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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.