Skip to content
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: update default changelog titles #1143

Open
wants to merge 1 commit into
base: v5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 11 additions & 4 deletions commitizen/cz/conventional_commits/conventional_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@ class ConventionalCommitsCz(BaseCommitizen):
bump_map_major_version_zero = defaults.bump_map_major_version_zero
commit_parser = r"^((?P<change_type>feat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P<scope>[^()\r\n]*)\)|\()?(?P<breaking>!)?|\w+!):\s(?P<message>.*)?" # noqa
change_type_map = {
"feat": "Feat",
"fix": "Fix",
"refactor": "Refactor",
"perf": "Perf",
"feat": "New features",
"fix": "Bug fixes",
"refactor": "Code refactoring",
"perf": "Performance improvements",
}
change_type_order = [
"BREAKING CHANGE",
"New features",
"Bug fixes",
"Code refactoring",
"Performance improvements",
]
changelog_pattern = defaults.bump_pattern

def questions(self) -> Questions:
Expand Down
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from commitizen.config import BaseConfig
from commitizen.cz import registry
from commitizen.cz.base import BaseCommitizen
from commitizen.cz.conventional_commits import ConventionalCommitsCz
from tests.utils import create_file_and_commit

SIGNER = "GitHub Action"
Expand Down Expand Up @@ -253,3 +254,17 @@ def any_changelog_format(config: BaseConfig) -> ChangelogFormat:
"""For test not relying on formats specifics, use the default"""
config.settings["changelog_format"] = defaults.CHANGELOG_FORMAT
return get_changelog_format(config)


@pytest.fixture(autouse=True)
def default_change_type_map(mocker: MockerFixture) -> None:
mocker.patch.object(
ConventionalCommitsCz,
"change_type_map",
{
"feat": "Feat",
Copy link
Member

Choose a reason for hiding this comment

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

Why are the tests using the old format?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not want to change the tests. So I applied mocking instead to hard-coding the new values.

IMHO: For tests, the names should not matter, I guess. The point is what the values are actually used for.

Copy link
Member

Choose a reason for hiding this comment

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

It might be a bit confusing as these are no longer the actual default_change_type_map when someone's tracing the test cases, they might be misled

"fix": "Fix",
"refactor": "Refactor",
"perf": "Perf",
},
)
Loading