Skip to content

NewConstraintIC interprets a dash in the prerelease tag as a range separator #59

@carolynvs

Description

@carolynvs

In golang/dep, we are using semver.NewConstraintIC to parse raw strings as constraints and some of them aren't being handled as expected:

  • v1.12.0-g2fd980e properly returns (semver.rangeConstraint) ^1.12.0-g2fd980e
  • v0.12.0-12-g2fd980e returns (semver.rangeConstraint) >=0.12.0, <=12.0.0-g2fd980e, when I expected ^1.12.0-g2fd980e
  • v1.12.0-2-g2fd980e returns (semver.rangeConstraint) >=1.12.0, <=2.0.0-g2fd980e, when I expected ^v1.12.0-2-g2fd980e.
  • v1.3.1-1-gf12c623 returns an unexpected (semver.none) . I expected ^1.3.1-1-gf12c623, or at the very least an error.

Essentially the dash in the prerelease tag is causing the function parse the input a range between v1.3.1 to 1-gf12c623.

I'm going to try having it first check if the input string is a valid version first, and if that pans out, submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2Related to the 2.x version used by dep

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions