Skip to content

fix(git): fix returned value for GitCommit.message when body is empty #166

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 3 commits into from
Apr 22, 2020
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
2 changes: 1 addition & 1 deletion commitizen/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
Expand Down
7 changes: 7 additions & 0 deletions tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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