-
-
Notifications
You must be signed in to change notification settings - Fork 286
feat(bump): add functionality to write the next version to stdout #1195
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(bump): add functionality to write the next version to stdout #1195
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1195 +/- ##
==========================================
+ Coverage 97.33% 97.61% +0.27%
==========================================
Files 42 55 +13
Lines 2104 2516 +412
==========================================
+ Hits 2048 2456 +408
- Misses 56 60 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Adds a --get-next flag which determines the next version and writes it to stdout.
76c6975
to
476be78
Compare
Thanks for the contribution! It looks good 🎉 . Could you add a comparison in the docs with Moreover, should this be part of the |
The idea looks great! I'll take a look this weekend when leading yet another dev sprint haha |
Thanks for the feedback, I've just added some additional information to the documentation. |
did not actually have the time to check it this weekend 🤦♂️ will try to do it these days! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few nitpicks. non-blocking
@@ -190,6 +192,9 @@ def __call__(self) -> None: # noqa: C901 | |||
"--prerelease-offset cannot be combined with MANUAL_VERSION" | |||
) | |||
|
|||
if get_next: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not required in this PR, but I feel we could move these validations out as a separate function 🤔
|
||
|
||
@pytest.mark.usefixtures("tmp_commitizen_project") | ||
def test_bump_get_next__changelog_is_not_allowed(mocker: MockFixture): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we can combine these not_allowed
test cases
I'm planning on merging it these days. But please do let me know if you want to take a look 🙂 @woile @noirbizarre |
Adds a --get-next flag which determines the next version and writes it to stdout.
Description
The new
--get-next
flag can be used to determine the next version based on the available commits, and output it to stdout. This can be useful in CI, for example to determine the version for a preview build image.Checklist
./scripts/format
and./scripts/test
locally to ensure this change passes linter check and testExpected behavior
When provided, the
--get-next
flag makes commitizen behave similarly to--dry-run
, it doesn't change any files and it doesn't create a tag. It determines the next version the same way a dry run does. It writes the next version to stdout, with no other output.The flag can't be used with
--changelog
,--changelog-to-stdout
andMANUAL_VERSION
, aNotAllowed
exception will be raised if these options are provided together with--get-next
.An example use case is assigning the output to a variable in CI.
Steps to Test This Pull Request
poetry run cz bump --get-next
poetry run cz bump --dry-run
Additional context