diff --git a/commitizen/git.py b/commitizen/git.py index 058ba89a00..a2531a87e4 100644 --- a/commitizen/git.py +++ b/commitizen/git.py @@ -21,7 +21,7 @@ def __init__(self, rev, title, body=""): @property def message(self): - return f"{self.title}\n\n{self.body}" + return f"{self.title}\n\n{self.body}".strip() def __repr__(self): return f"{self.title} ({self.rev})" diff --git a/tests/test_git.py b/tests/test_git.py index ef7cb2cdc9..3a6638b329 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -47,3 +47,10 @@ def test_get_tag_names(mocker): "commitizen.cmd.run", return_value=FakeCommand(out="", err="No tag available") ) assert git.get_tag_names() == [] + + +def test_git_message_with_empty_body(): + commit_title = "Some Title" + commit = git.GitCommit("test_rev", "Some Title", body="") + + assert commit.message == commit_title