feat(schemes): adds support for SemVer 2.0 (dot in pre-releases) (fix #1025) by noirbizarre · Pull Request #1072 · commitizen-tools/commitizen · GitHub
Skip to content

feat(schemes): adds support for SemVer 2.0 (dot in pre-releases) (fix #1025) - #1072

Merged
noirbizarre merged 1 commit into
commitizen-tools:masterfrom
noirbizarre:feature/semver2
Apr 18, 2024
Merged

feat(schemes): adds support for SemVer 2.0 (dot in pre-releases) (fix #1025)#1072
noirbizarre merged 1 commit into
commitizen-tools:masterfrom
noirbizarre:feature/semver2

Conversation

@noirbizarre

@noirbizarre noirbizarre commented Apr 18, 2024

Copy link
Copy Markdown
Member

Description

This PR adds a semver2 version scheme which is applying strict prerelease formatting as described in SemVer 2 Item 9 and Semver 2.0.0 Item 11, meaning:

  • each prelease identifier should be separated by a dot
  • dash is part of the identifier, not a separator
  • precedence rules should be applied on identifiers

As a consequence, the 1.2.3-alpha0 form is not respecting those rules (1.2.3-alpha10 has not proper precedence over 1.2.3-alpha2), nor 1.2.3-alpha.0-dev.0 as its prerelease identifiers will be alpha, 0-dev, 0 while it should be alpha, 0, dev and 0.

Note that Semver 2 is underspecified on this point (there is no formal description of what are the expected prerelease identifiers, only example) and so this PR chose to stay close to the examples (use of alpha and beta instead of a and b), but this is choice, not a specification requirement.

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

SemVer 2.0 versions are properly parsed and bumped, the resulting version is SemVer 2,0 compliant too.

Steps to Test This Pull Request

  1. Defined version_scheme = "semver2" in you commitizen config
  2. Bump a dev release, it should have the form x.y.z-dev.D
  3. Bump an alpha release, it should have the form x.y.z-alpha.A
  4. Bump an alpha dev release, it should have the form x.y.z-alpha.A.dev.D

Additional context

Fixes #1025

Note

I think it's time for removing the version-type deprecated by vesion-scheme (in another PR)

@codecov

codecov Bot commented Apr 18, 2024

Copy link
Copy Markdown

@woile woile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work again 🎉
I'm in for a breaking change cleaning up some old deprecated flags.

@noirbizarre

noirbizarre commented Apr 18, 2024

Copy link
Copy Markdown
Member Author

@noirbizarre noirbizarre changed the title feat(schemes): adds support for SemVer 2.0 (dot in pre-releases) feat(schemes): adds support for SemVer 2.0 (dot in pre-releases) (fix #1025) Apr 18, 2024
@noirbizarre
noirbizarre merged commit 2ad26e0 into commitizen-tools:master Apr 18, 2024
@noirbizarre
noirbizarre deleted the feature/semver2 branch April 18, 2024 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated pre-release part of SemVer differs from SemVer spec

2 participants