Skip to content

[BUG] Increase pre* with pre-release identifiers without build #441

Closed

Description

@pellmont

What / Why

the semver package should be able to execute a increment premajor, preminor and prepatch for versioning schemes without a build number.
It for sure affects the standard maven versioning system (which is semver compliant).

Examples

Actual

0.0.1-SNAPSHOT premajor -> 1.0.0-SNAPSHOT.0
0.0.1-SNAPSHOT preminor -> 0.1.0-SNAPSHOT.0
0.0.1-SNAPSHOT prepatch -> 0.0.2-SNAPSHOT.0

Expected

0.0.1-SNAPSHOT premajor -> 1.0.0-SNAPSHOT
0.0.1-SNAPSHOT preminor -> 0.1.0-SNAPSHOT
0.0.1-SNAPSHOT prepatch -> 0.0.2-SNAPSHOT

Currently this package always sets a dot-separated build. I t would be desirable if the behavior could be chosen, or if it would at least respect the current versioning scheme.

Activity

  1. ljharb commented on Mar 24, 2022

    @ljharb
    Contributor

    Wouldn’t that mean you can only ever have one snapshot per version? That seems a bit short-sighted.

  2. pellmont commented on Mar 24, 2022

    @pellmont
    Author

    This is correct, for MAVEN repositories the SNAPSHOT versions are allowed to be updated. (internal it uses a timestamp for the different versions)

  3. ljharb commented on Mar 24, 2022

    @ljharb
    Contributor

    sounds like a build number. Why isn’t it part of the version number?

  4. astellingwerf commented on Mar 24, 2022

    @astellingwerf

    The whole idea of the snapshot version is that you don't need to update references to it with every new build. See also What is a SNAPSHOT version?.

  5. ljharb commented on Mar 24, 2022

    @ljharb
    Contributor

    Wouldn’t a semver range like 1.2.3-SNAPSHOT.0 do that?

  6. ljharb commented on Mar 24, 2022

    @ljharb
    Contributor

    Versions in semver are designed to be immutable - in other words, it’s not semver if it’s changing over time.

  7. astellingwerf commented on Mar 25, 2022

    @astellingwerf

    1.2.3-SNAPSHOT is a perfectly valid semver. See this overview of the spec, where I marked the choices for the different options using >>> in front.

            <valid semver> ::= <version core>
    >>>                      | <version core> "-" <pre-release>
                             | <version core> "+" <build>
                             | <version core> "-" <pre-release> "+" <build>
    
            <version core> ::= <major> "." <minor> "." <patch>
    
            <major> ::= <numeric identifier>
    
            <minor> ::= <numeric identifier>
            
            <patch> ::= <numeric identifier>
    
    >>>     <pre-release> ::= <dot-separated pre-release identifiers>
    
    >>>     <dot-separated pre-release identifiers> ::= <pre-release identifier>
                                                      | <pre-release identifier> "." <dot-separated pre-release identifiers>
    
            <build> ::= <dot-separated build identifiers>
    
            <dot-separated build identifiers> ::= <build identifier>
                                                | <build identifier> "." <dot-separated build identifiers>
    
    >>>     <pre-release identifier> ::= <alphanumeric identifier>
                                       | <numeric identifier>
    
            <build identifier> ::= <alphanumeric identifier>
                                 | <digits>
    
            <alphanumeric identifier> ::= <non-digit>
    >>>                                 | <non-digit> <identifier characters>
                                        | <identifier characters> <non-digit>
                                        | <identifier characters> <non-digit> <identifier characters>
    
            <numeric identifier> ::= "0"
                                   | <positive digit>
                                   | <positive digit> <digits>
    
            <identifier characters> ::= <identifier character>
    >>>                               | <identifier character> <identifier characters>
    
            <identifier character> ::= <digit>
    >>>                              | <non-digit>
    
    >>>     <non-digit> ::= <letter>
                          | "-"
    
            <digits> ::= <digit>
                       | <digit> <digits>
    
            <digit> ::= "0"
                      | <positive digit>
    
            <positive digit> ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
    
    >>>     <letter> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J"
    >>>                | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T"
                       | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | "b" | "c" | "d"
                       | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n"
                       | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x"
                       | "y" | "z"
    
  8. ljharb commented on Mar 25, 2022

    @ljharb
    Contributor

    Absolutely that string is valid semver. But its contents must never change - versions are immutable.

  9. astellingwerf commented on Mar 25, 2022

    @astellingwerf

    Fair enough, but whether I adhere to that rule should not be a problem when reasoning about the semver version. If we have semver version number 1.2.3-anything, and we order node-semver to increment the minor component, there's no reason to fiddle with the pre-release identifier. It should return 1.3.3-anything.

  10. ljharb commented on Mar 25, 2022

    @ljharb
    Contributor

    Fair enough.

    the standard maven versioning system (which is semver compliant).

    still worth establishing that it is not compliant, because snapshot contents change - and that by appending a .0, and relying on that instead, it would be, and this bug wouldn't apply.

  11. astellingwerf commented on Oct 20, 2022

    @astellingwerf

    The semver 2.0.0 spec mentions "increment" 16 times, but only for the major, minor, and patch versions. In it, I didn't see instructions on adding significant figures to any of the elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions