Skip to content

Conversation

@woile
Copy link
Member

@woile woile commented Oct 30, 2025

Description

Allow the ability to just print major or minor from a version when using cz version -p.

This is useful, because under some scenarios, users may need just a chunk of the version. Example:

  • github actions recommend using a vX tag, where X is the major, this tag is moved to the latest commit usually.
  • docker image tags
  • api versioning
  • go modules

Checklist

Code Changes

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
  • Update the documentation for the changes

Documentation Changes

  • Run poetry doc locally to ensure the documentation pages renders correctly

Expected Behavior

cz version -p major should render the major part only

cz version -p minor should render the minor part only

Closes #1638

@woile
Copy link
Member Author

woile commented Oct 30, 2025

how am I supposed to fix Run codespell to check for common misspellings in files?

@Lee-W
Copy link
Member

Lee-W commented Oct 30, 2025

I usually use pre-commit run codespell --all-files

@woile woile force-pushed the feat/version-info branch from df79339 to 2fa851b Compare October 31, 2025 10:53
@woile
Copy link
Member Author

woile commented Oct 31, 2025

Fixed! 🤞🏻

@Lee-W Lee-W added this to the 4.10.0 milestone Nov 2, 2025
@woile woile force-pushed the feat/version-info branch from 2fa851b to 7ca2b16 Compare November 4, 2025 12:26
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.18%. Comparing base (120d514) to head (7ca2b16).
⚠️ Report is 807 commits behind head on master.

Files with missing lines Patch % Lines
commitizen/commands/version.py 84.61% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1639      +/-   ##
==========================================
+ Coverage   97.33%   98.18%   +0.85%     
==========================================
  Files          42       58      +16     
  Lines        2104     2706     +602     
==========================================
+ Hits         2048     2657     +609     
+ Misses         56       49       -7     
Flag Coverage Δ
unittests 98.18% <84.61%> (+0.85%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


try:
version_scheme = get_version_scheme(self.config.settings)
except VersionSchemeUnknown:
Copy link
Member Author

Choose a reason for hiding this comment

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

@Lee-W do you think I need this try/catch here? If get_version_scheme fails, then VersionSchemeUnknown would be propagated and properly displayed by commitizen_excepthook, right?

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.

Cannot install the project because of poetthepoet

3 participants