Skip to content

fix(changelog): skip non-compliant commit subjects when building changelog #536

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 1 commit into from
Jul 22, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ConventionalCommitsCz(BaseCommitizen):
"refactor": "Refactor",
"perf": "Perf",
}
changelog_pattern = defaults.bump_pattern

def questions(self) -> Questions:
questions: Questions = [
Expand Down
18 changes: 18 additions & 0 deletions tests/commands/test_changelog_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,3 +872,21 @@ def test_changelog_from_rev_latest_version_dry_run(
out, _ = capsys.readouterr()

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


@pytest.mark.usefixtures("tmp_commitizen_project")
def test_invalid_subject_is_skipped(mocker, capsys):
"""Fix #510"""
non_conformant_commit_title = (
"Merge pull request #487 from manang/master\n\n"
"feat: skip merge messages that start with Pull request\n"
)
create_file_and_commit(non_conformant_commit_title)
create_file_and_commit("feat: a new world")
testargs = ["cz", "changelog", "--dry-run"]
mocker.patch.object(sys, "argv", testargs)
with pytest.raises(DryRunExit):
cli.main()
out, _ = capsys.readouterr()

assert out == ("## Unreleased\n\n### Feat\n\n- a new world\n\n")