Skip to content

test: add test for 'additional' types in conventional commits #728

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
merged 7 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commitizen/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Settings(TypedDict, total=False):
MINOR = "MINOR"
PATCH = "PATCH"

bump_pattern = r"^(BREAKING[\-\ ]CHANGE|feat|fix|refactor|perf)(\(.+\))?(!)?"
bump_pattern = r"^(((BREAKING[\-\ ]CHANGE|feat|fix|refactor|perf)(\(.+\))?(!)?)|\w+!)"
bump_map = OrderedDict(
(
(r"^.+!$", MAJOR),
Expand All @@ -112,5 +112,5 @@ class Settings(TypedDict, total=False):
change_type_order = ["BREAKING CHANGE", "Feat", "Fix", "Refactor", "Perf"]
bump_message = "bump: version $current_version → $new_version"

commit_parser = r"^(?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P<scope>[^()\r\n]*)\)|\()?(?P<breaking>!)?:\s(?P<message>.*)?" # noqa
commit_parser = r"^((?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P<scope>[^()\r\n]*)\)|\()?(?P<breaking>!)?|\w+!):\s(?P<message>.*)?" # noqa
version_parser = r"(?P<version>([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?(\w+)?)"
15 changes: 15 additions & 0 deletions tests/commands/test_changelog_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,21 @@ def test_breaking_change_content_v1_multiline(
file_regression.check(out, extension=".md")


@pytest.mark.usefixtures("tmp_commitizen_project")
def test_breaking_change_content_v1_with_exclamation_mark(
mocker: MockFixture, capsys, file_regression
):
commit_message = "chore!: drop support for py36"
create_file_and_commit(commit_message)
testargs = ["cz", "changelog", "--dry-run"]
mocker.patch.object(sys, "argv", testargs)
with pytest.raises(DryRunExit):
cli.main()
out, _ = capsys.readouterr()

file_regression.check(out, extension=".md")


@pytest.mark.usefixtures("tmp_commitizen_project")
def test_changelog_config_flag_increment(
mocker: MockFixture, changelog_path, config_path, file_regression
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Unreleased


- drop support for py36

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think of this @Lee-W @jenstroeger ?

It won't show the title ### BREAKING CHANGE. But it's the best I could do with the new regex, I cannot repeat the breaking group in here:

https://github.com/commitizen-tools/commitizen/pull/728/files#diff-c951de16d627d82e01eb3ce8d7c4f0b28973ffe147520620762e7140ede2dd80R115

7 changes: 7 additions & 0 deletions tests/test_bump_find_increment.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"fix(setup.py): future is now required for every python version",
]

MAJOR_INCREMENTS_EXCLAMATION_OTHER_TYPE_CC = [
"chore!: drop support for Python 3.9",
"docs(README): motivation",
"fix(setup.py): future is now required for every python version",
]

PATCH_INCREMENTS_SVE = ["readme motivation PATCH", "fix setup.py PATCH"]

MINOR_INCREMENTS_SVE = [
Expand All @@ -67,6 +73,7 @@
(MINOR_INCREMENTS_CC, "MINOR"),
(MAJOR_INCREMENTS_BREAKING_CHANGE_CC, "MAJOR"),
(MAJOR_INCREMENTS_BREAKING_CHANGE_ALT_CC, "MAJOR"),
(MAJOR_INCREMENTS_EXCLAMATION_OTHER_TYPE_CC, "MAJOR"),
(MAJOR_INCREMENTS_EXCLAMATION_CC, "MAJOR"),
(NONE_INCREMENT_CC, None),
),
Expand Down