Skip to content

Commit bf16b51

Browse files
committed
fix(commands/commit): use return_code to raise commit error, not stderr
1 parent e4a21be commit bf16b51

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

‎commitizen/commands/commit.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __call__(self):
7575

7676
c = git.commit(m)
7777

78-
if c.err:
78+
if c.return_code != 0:
7979
out.error(c.err)
8080

8181
# Create commit backup
@@ -86,10 +86,9 @@ def __call__(self):
8686

8787
if "nothing added" in c.out or "no changes added to commit" in c.out:
8888
out.error(c.out)
89-
elif c.err:
90-
out.error(c.err)
9189
else:
9290
with contextlib.suppress(FileNotFoundError):
9391
os.remove(self.temp_file)
92+
out.write(c.err)
9493
out.write(c.out)
9594
out.success("Commit successful!")

‎tests/commands/test_commit_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_commit_retry_works(config, mocker):
6565
}
6666

6767
commit_mock = mocker.patch("commitizen.git.commit")
68-
commit_mock.return_value = cmd.Command("", "error", "", "", 0)
68+
commit_mock.return_value = cmd.Command("", "error", "", "", 9)
6969
error_mock = mocker.patch("commitizen.out.error")
7070

7171
with pytest.raises(CommitError):

0 commit comments

Comments
 (0)