-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Merged
Lee-W
merged 4 commits into
commitizen-tools:master
from
marcelblijleven:feature/add-get-next-flag
Aug 11, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
476be78
feat(bump): add functionality to write the next version to stdout
marcelblijleven 6068a82
Merge branch 'master' into feature/add-get-next-flag
marcelblijleven 5f3ba4a
docs(bump): add comparison between --get-next and --dry-run
marcelblijleven 008c652
docs(bump): reword "--get-next" description
Lee-W File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
DryRunExit, | ||
ExitCode, | ||
ExpectedExit, | ||
GetNextExit, | ||
InvalidManualVersion, | ||
NoCommitsFoundError, | ||
NoneIncrementExit, | ||
|
@@ -1462,3 +1463,63 @@ def test_bump_command_shows_description_when_use_help_option( | |
|
||
out, _ = capsys.readouterr() | ||
file_regression.check(out, extension=".txt") | ||
|
||
|
||
@pytest.mark.usefixtures("tmp_commitizen_project") | ||
def test_bump_get_next(mocker: MockFixture, capsys): | ||
create_file_and_commit("feat: new file") | ||
|
||
testargs = ["cz", "bump", "--yes", "--get-next"] | ||
mocker.patch.object(sys, "argv", testargs) | ||
with pytest.raises(GetNextExit): | ||
cli.main() | ||
|
||
out, _ = capsys.readouterr() | ||
assert "0.2.0" in out | ||
|
||
tag_exists = git.tag_exist("0.2.0") | ||
assert tag_exists is False | ||
|
||
|
||
@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 commentThe reason will be displayed to describe this comment to others. Learn more. I feel we can combine these |
||
create_file_and_commit("feat: new file") | ||
|
||
testargs = ["cz", "bump", "--yes", "--get-next", "--changelog"] | ||
mocker.patch.object(sys, "argv", testargs) | ||
|
||
with pytest.raises(NotAllowed): | ||
cli.main() | ||
|
||
|
||
@pytest.mark.usefixtures("tmp_commitizen_project") | ||
def test_bump_get_next__changelog_to_stdout_is_not_allowed(mocker: MockFixture): | ||
create_file_and_commit("feat: new file") | ||
|
||
testargs = ["cz", "bump", "--yes", "--get-next", "--changelog-to-stdout"] | ||
mocker.patch.object(sys, "argv", testargs) | ||
|
||
with pytest.raises(NotAllowed): | ||
cli.main() | ||
|
||
|
||
@pytest.mark.usefixtures("tmp_commitizen_project") | ||
def test_bump_get_next__manual_version_is_not_allowed(mocker: MockFixture): | ||
create_file_and_commit("feat: new file") | ||
|
||
testargs = ["cz", "bump", "--yes", "--get-next", "0.2.1"] | ||
mocker.patch.object(sys, "argv", testargs) | ||
|
||
with pytest.raises(NotAllowed): | ||
cli.main() | ||
|
||
|
||
@pytest.mark.usefixtures("tmp_commitizen_project") | ||
def test_bump_get_next__no_eligible_commits_raises(mocker: MockFixture): | ||
create_file_and_commit("chore: new commit") | ||
|
||
testargs = ["cz", "bump", "--yes", "--get-next"] | ||
mocker.patch.object(sys, "argv", testargs) | ||
|
||
with pytest.raises(NoneIncrementExit): | ||
cli.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 🤔