Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pellmont opened this issue Mar 24, 2022 · 11 comments · Fixed by #548
Closed

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

pellmont opened this issue Mar 24, 2022 · 11 comments · Fixed by #548
Labels
Bug thing that needs fixing

Comments

@pellmont
Copy link

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.

@ljharb
Copy link
Contributor

ljharb commented Mar 24, 2022

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

@pellmont
Copy link
Author

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

@ljharb
Copy link
Contributor

ljharb commented Mar 24, 2022

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

@astellingwerf
Copy link

astellingwerf commented Mar 24, 2022

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?.

@ljharb
Copy link
Contributor

ljharb commented Mar 24, 2022

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

@ljharb
Copy link
Contributor

ljharb commented Mar 24, 2022

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

@astellingwerf
Copy link

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"

@ljharb
Copy link
Contributor

ljharb commented Mar 25, 2022

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

@astellingwerf
Copy link

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.

@ljharb
Copy link
Contributor

ljharb commented Mar 25, 2022

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.

@darcyclarke darcyclarke added the Bug thing that needs fixing label Jul 28, 2022
@astellingwerf
Copy link

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
Labels
Bug thing that needs fixing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants