Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d8bc74

Browse files
authored
Merge pull request #382 from shifqu/fix-convetional-commits-schema-pattern
Fix conventional commits schema pattern
2 parents 6082b64 + e107411 commit 5d8bc74

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

‎commitizen/cz/conventional_commits/conventional_commits.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ def schema(self) -> str:
178178

179179
def schema_pattern(self) -> str:
180180
PATTERN = (
181-
r"(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)!?"
182-
r"(\(\S+\))?:(\s.*)"
181+
r"(build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)"
182+
r"(\(\S+\))?!?:(\s.*)"
183183
)
184184
return PATTERN
185185

‎tests/commands/test_check_command.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,15 @@ def test_check_conventional_commit_succeeds(mocker, capsys):
124124
assert "Commit validation: successful!" in out
125125

126126

127-
def test_check_no_conventional_commit(config, mocker, tmpdir):
127+
@pytest.mark.parametrize(
128+
"commit_msg", ("feat!(lang): removed polish language", "no conventional commit",),
129+
)
130+
def test_check_no_conventional_commit(commit_msg, config, mocker, tmpdir):
128131
with pytest.raises(InvalidCommitMessageError):
129132
error_mock = mocker.patch("commitizen.out.error")
130133

131134
tempfile = tmpdir.join("temp_commit_file")
132-
tempfile.write("no conventional commit")
135+
tempfile.write(commit_msg)
133136

134137
check_cmd = commands.Check(
135138
config=config, arguments={"commit_msg_file": tempfile}
@@ -141,6 +144,7 @@ def test_check_no_conventional_commit(config, mocker, tmpdir):
141144
@pytest.mark.parametrize(
142145
"commit_msg",
143146
(
147+
"feat(lang)!: removed polish language",
144148
"feat(lang): added polish language",
145149
"feat: add polish language",
146150
"bump: 0.0.1 -> 1.0.0",

‎tests/test_cz_conventional_commits.py‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,15 @@ def test_info(config):
132132
assert isinstance(info, str)
133133

134134

135-
def test_process_commit(config):
135+
@pytest.mark.parametrize(
136+
("commit_message", "expected_message"),
137+
[
138+
("test(test_scope): this is test msg", "this is test msg",),
139+
("test(test_scope)!: this is test msg", "this is test msg",),
140+
("test!(test_scope): this is test msg", "",),
141+
],
142+
)
143+
def test_process_commit(commit_message, expected_message, config):
136144
conventional_commits = ConventionalCommitsCz(config)
137-
message = conventional_commits.process_commit("test(test_scope): this is test msg")
138-
assert message == "this is test msg"
145+
message = conventional_commits.process_commit(commit_message)
146+
assert message == expected_message

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /