Skip to content

PreRelease comparison bug? #61

@vsimon

Description

@vsimon

In looking at the ComparePreReleases test cases...

func TestComparePreReleases(t *testing.T) {
	cases := []struct {
		v1       string
		v2       string
		expected int
	}{
...
            {"5.4-alpha", "5.4-alpha.beta", 1},
}

I'm noticing that 5.4-alpha is larger (has a higher precedence) than 5.4-alpha.beta. However when reading over the precedence rules of pre-releases in semver (https://semver.org/#spec-item-11)

A larger set of pre-release fields has a higher precedence than a smaller set, 
if all of the preceding identifiers are equal. 
Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.

In this test case, all the preceding identifiers are equal - "5.4" - and the larger set "alpha.beta" has a lower precedence than the smaller set "alpha". Shouldn't it have a higher precedence?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions