-
-
Notifications
You must be signed in to change notification settings - Fork 304
fix(1694): changelog_merge_prerelease not working on cz bump #1700
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
base: v4-11-0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -314,6 +314,8 @@ def __call__(self) -> None: | |||||||||
| "extras": self.extras, | ||||||||||
| "incremental": True, | ||||||||||
| "dry_run": dry_run, | ||||||||||
| "during_version_bump": self.arguments["prerelease"] | ||||||||||
| is None, # governs logic for merge_prerelease | ||||||||||
|
Comment on lines
+317
to
+318
Member
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. Nitpicky, but can it be on one line?
Suggested change
|
||||||||||
| } | ||||||||||
| if self.changelog_to_stdout: | ||||||||||
| changelog_cmd = Changelog( | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |||||
| from unittest.mock import MagicMock, call | ||||||
|
|
||||||
| import pytest | ||||||
| from freezegun import freeze_time | ||||||
|
|
||||||
| import commitizen.commands.bump as bump | ||||||
| from commitizen import cli, cmd, defaults, git, hooks | ||||||
|
|
@@ -1705,3 +1706,66 @@ def test_is_initial_tag(mocker: MockFixture, tmp_commitizen_project): | |||||
| # Test case 4: No current tag, user denies | ||||||
| mocker.patch("questionary.confirm", return_value=mocker.Mock(ask=lambda: False)) | ||||||
| assert bump_cmd._is_initial_tag(None, is_yes=False) is False | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"]) | ||||||
| @pytest.mark.usefixtures("tmp_commitizen_project") | ||||||
| @freeze_time("2025-01-01") | ||||||
|
Member
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. Use the pytest fixture to be consistent with other tests.
Suggested change
(the import can be removed) |
||||||
| def test_changelog_config_flag_merge_prerelease( | ||||||
| mocker: MockFixture, changelog_path, config_path, file_regression, test_input | ||||||
| ): | ||||||
| with open(config_path, "a") as f: | ||||||
| f.write("changelog_merge_prerelease = true\n") | ||||||
| f.write("update_changelog_on_bump = true\n") | ||||||
| f.write("annotated_tag = true\n") | ||||||
|
|
||||||
| create_file_and_commit("irrelevant commit") | ||||||
| mocker.patch("commitizen.git.GitTag.date", "1970-01-01") | ||||||
| git.tag("0.1.0") | ||||||
|
|
||||||
| create_file_and_commit("feat: add new output") | ||||||
| create_file_and_commit("fix: output glitch") | ||||||
| testargs = ["cz", "bump", "--prerelease", test_input, "--yes"] | ||||||
| mocker.patch.object(sys, "argv", testargs) | ||||||
| cli.main() | ||||||
|
|
||||||
| testargs = ["cz", "bump", "--changelog"] | ||||||
| mocker.patch.object(sys, "argv", testargs) | ||||||
| cli.main() | ||||||
|
|
||||||
| with open(changelog_path) as f: | ||||||
| out = f.read() | ||||||
|
|
||||||
| file_regression.check(out, extension=".md") | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize("test_input", ["rc", "alpha", "beta"]) | ||||||
| @pytest.mark.usefixtures("tmp_commitizen_project") | ||||||
| @freeze_time("2025-01-01") | ||||||
|
Member
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. Same:
Suggested change
|
||||||
| def test_changelog_config_flag_merge_prerelease_only_prerelease_present( | ||||||
| mocker: MockFixture, changelog_path, config_path, file_regression, test_input | ||||||
| ): | ||||||
| with open(config_path, "a") as f: | ||||||
| f.write("changelog_merge_prerelease = true\n") | ||||||
| f.write("update_changelog_on_bump = true\n") | ||||||
| f.write("annotated_tag = true\n") | ||||||
|
|
||||||
| create_file_and_commit("feat: more relevant commit") | ||||||
| testargs = ["cz", "bump", "--prerelease", test_input, "--yes"] | ||||||
| mocker.patch.object(sys, "argv", testargs) | ||||||
| cli.main() | ||||||
|
|
||||||
| create_file_and_commit("feat: add new output") | ||||||
| create_file_and_commit("fix: output glitch") | ||||||
| testargs = ["cz", "bump", "--prerelease", test_input, "--yes"] | ||||||
| mocker.patch.object(sys, "argv", testargs) | ||||||
| cli.main() | ||||||
|
|
||||||
| testargs = ["cz", "bump", "--changelog"] | ||||||
| mocker.patch.object(sys, "argv", testargs) | ||||||
| cli.main() | ||||||
|
|
||||||
| with open(changelog_path) as f: | ||||||
| out = f.read() | ||||||
|
|
||||||
| file_regression.check(out, extension=".md") | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ## 0.2.0 (2025-01-01) | ||
|
|
||
| ### Feat | ||
|
|
||
| - add new output | ||
|
|
||
| ### Fix | ||
|
|
||
| - output glitch | ||
|
|
||
| ## 0.1.0 (1970-01-01) | ||
|
Collaborator
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. Quick question, is this expected?
Author
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 assume you mean the empty version I would say yes. Reason is that an annotated tag is created on a version that has no eligible commits e.g.
Collaborator
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. Thanks for detailed explanation. I don't think it's a blocker. @woile wdyt |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ## 0.2.0 (2025-01-01) | ||
|
|
||
| ### Feat | ||
|
|
||
| - add new output | ||
|
|
||
| ### Fix | ||
|
|
||
| - output glitch | ||
|
|
||
| ## 0.1.0 (1970-01-01) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ## 0.2.0 (2025-01-01) | ||
|
|
||
| ### Feat | ||
|
|
||
| - add new output | ||
| - more relevant commit | ||
|
|
||
| ### Fix | ||
|
|
||
| - output glitch |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ## 0.2.0 (2025-01-01) | ||
|
|
||
| ### Feat | ||
|
|
||
| - add new output | ||
| - more relevant commit | ||
|
|
||
| ### Fix | ||
|
|
||
| - output glitch |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ## 0.2.0 (2025-01-01) | ||
|
|
||
| ### Feat | ||
|
|
||
| - add new output | ||
| - more relevant commit | ||
|
|
||
| ### Fix | ||
|
|
||
| - output glitch |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ## 0.2.0 (2025-01-01) | ||
|
|
||
| ### Feat | ||
|
|
||
| - add new output | ||
|
|
||
| ### Fix | ||
|
|
||
| - output glitch | ||
|
|
||
| ## 0.1.0 (1970-01-01) |
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.