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

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

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

noirbizarre
Copy link
Member

@noirbizarre noirbizarre commented Apr 18, 2024

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)

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 97.53%. Comparing base (120d514) to head (d30fa81).
Report is 283 commits behind head on master.

Files Patch % Lines
commitizen/version_schemes.py 92.85% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1072      +/-   ##
==========================================
+ Coverage   97.33%   97.53%   +0.19%     
==========================================
  Files          42       55      +13     
  Lines        2104     2477     +373     
==========================================
+ Hits         2048     2416     +368     
- Misses         56       61       +5     
Flag Coverage Δ
unittests 97.53% <92.85%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@woile woile left a comment

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
Copy link
Member Author

noirbizarre commented Apr 18, 2024

I'll do a dedicated PR dropping all deprecations. Given it will breaking, maybe we should discuss what other breaking changes we want to include (like maybe #996 (comment)).
I'll open an issue to track those: #1073

@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
17 of 18 checks passed
@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