Skip to content

Commit 008a8c6

Browse files
authored
Merge pull request #166 from vBLFTePebWNi6c/fix_git_commit_message
fix(git): fix returned value for GitCommit.message when body is empty
2 parents 985f391 + f21693e commit 008a8c6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

commitizen/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, rev, title, body=""):
2121

2222
@property
2323
def message(self):
24-
return f"{self.title}\n\n{self.body}"
24+
return f"{self.title}\n\n{self.body}".strip()
2525

2626
def __repr__(self):
2727
return f"{self.title} ({self.rev})"

tests/test_git.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ def test_get_tag_names(mocker):
4747
"commitizen.cmd.run", return_value=FakeCommand(out="", err="No tag available")
4848
)
4949
assert git.get_tag_names() == []
50+
51+
52+
def test_git_message_with_empty_body():
53+
commit_title = "Some Title"
54+
commit = git.GitCommit("test_rev", "Some Title", body="")
55+
56+
assert commit.message == commit_title

0 commit comments

Comments
 (0)