Jira (PUP-11077) Passing SemVer prerelease or build as a hash doesn't work

0 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Jun 1, 2021, 6:40:02 PM6/1/21
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-11077
Passing SemVer prerelease or build as a hash doesn't work
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/06/01 3:39 PM
Priority: Normal Normal
Reporter: Josh Cooper

The language specification says you should be able to pass the SemVer prerelease and build components as a hash. However, the values are corrupted when SemVer objects are created this way:

❯ bx puppet apply  -e 'notice(SemVer(major => 1, minor => 0, patch => 0, prerelease => "alpha"))'
Notice: Scope(Class[main]): 1.0.0-a.l.p.h.a
...
❯ bx puppet apply  -e 'notice(SemVer(major => 1, minor => 0, patch => 0, build => "123"))'       
Notice: Scope(Class[main]): 1.0.0+1.2.3
...

Note the extra dots in the output. The problem is that the SemVer data type needs to pass the build and prerelease components as a single element array when calling SemanticPuppet::Version.new(.., prerelease, build)

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Jun 1, 2021, 6:47:03 PM6/1/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
The [language specification|https://github.com/puppetlabs/puppet-specifications/blob/master/language/types_values_variables.md#semvernew] says you should be able to pass the SemVer {{prerelease}} and {{build}} components as a hash. However, the values are corrupted when SemVer objects are created this way:

{noformat}

❯ bx puppet apply  -e 'notice(SemVer(major => 1, minor => 0, patch => 0, prerelease => "alpha"))'
Notice: Scope(Class[main]): 1.0.0-a.l.p.h.a
...
❯ bx puppet apply  -e 'notice(SemVer(major => 1, minor => 0, patch => 0, build => "123"))'       
Notice: Scope(Class[main]): 1.0.0+1.2.3
...
{noformat}

Note the extra dots in the output.
This leads to confusing behavior:

{noformat}
❯ bx puppet apply  -e 'notice(SemVer(major => 1, minor => 0, patch => 0, build => "123") == SemVer("1.0.0+123"))'
Notice: Scope(Class[main]): false
{noformat}

Passing the build and prerelease components in the string version does work, because internally {{SemanticPuppet::Version.parse}} converts the [String component to an array|https://github.com/puppetlabs/semantic_puppet/blob/3ef28a432846c0d5492be1af3a412a1695b4b4b6/lib/semantic_puppet/version.rb#L38].

The problem is that the SemVer data type needs to pass the build and prerelease components as a single element array when calling {{SemanticPuppet::Version.new(.., prerelease, build)}}

Josh Cooper (Jira)

unread,
Jun 1, 2021, 8:00:02 PM6/1/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Platform Core KANBAN

Josh Cooper (Jira)

unread,
Jun 1, 2021, 8:00:03 PM6/1/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jun 1, 2021, 8:00:03 PM6/1/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jun 1, 2021, 8:00:10 PM6/1/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jun 1, 2021, 8:05:02 PM6/1/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
The [language specification|https://github.com/puppetlabs/puppet-specifications/blob/master/language/types_values_variables.md#semvernew] says you should be able to pass the SemVer {{prerelease}} and {{build}} components as a hash or list of arguments . However, the values are corrupted when SemVer objects are created this way:


{noformat}
❯ bx puppet apply  -e 'notice(SemVer(major => 1, minor => 0, patch => 0, prerelease => "alpha"))'
Notice: Scope(Class[main]): 1.0.0-a.l.p.h.a
...
❯ bx puppet apply  -e 'notice(SemVer(major => 1, minor => 0, patch => 0, build => "123"))'       
Notice: Scope(Class[main]): 1.0.0+1.2.3
...
{noformat}

Note the extra dots in the output. This leads to confusing behavior:

{noformat}
❯ bx puppet apply  -e 'notice(SemVer(major => 1, minor => 0, patch => 0, build => "123") == SemVer("1.0.0+123"))'
Notice: Scope(Class[main]): false
{noformat}

Passing the build and prerelease components in the string version does work, because internally {{SemanticPuppet::Version.parse}} converts the [String component to an array|https://github.com/puppetlabs/semantic_puppet/blob/3ef28a432846c0d5492be1af3a412a1695b4b4b6/lib/semantic_puppet/version.rb#L38].

The problem is that the SemVer data type needs to pass the build and prerelease components as a single element array when calling {{SemanticPuppet::Version.new(.., prerelease, build)}}

Gabriel Nagy (Jira)

unread,
Jun 8, 2021, 9:31:03 AM6/8/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Jun 8, 2021, 9:31:04 AM6/8/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jun 8, 2021, 10:00:04 AM6/8/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: Fixes a bug that prevented the build and prerelease components of the SemVer data type from being passed as a list of arguments or hash:

SemVer(major => 1, minor => 0, patch => 0, prerelease => "beta", build => "123")
SemVer(1, 0, 0, "beta", "123")

Christine Yoon (Jira)

unread,
Jun 21, 2021, 3:59:01 PM6/21/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages