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 6493fe2

Browse files
BogayLee-W
authored andcommitted
refactor(Check): remove the extra preprocessing of commit message file
1 parent c247670 commit 6493fe2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

‎commitizen/commands/check.py‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,18 @@ def __call__(self):
8282
out.success("Commit validation: successful!")
8383

8484
def _get_commits(self):
85+
msg = None
8586
# Get commit message from file (--commit-msg-file)
8687
if self.commit_msg_file is not None:
8788
# Enter this branch if commit_msg_file is "".
8889
with open(self.commit_msg_file, "r", encoding="utf-8") as commit_file:
8990
msg = commit_file.read()
91+
# Get commit message from command line (--message)
92+
elif self.commit_msg:
93+
msg = self.commit_msg
94+
if msg is not None:
9095
msg = self._filter_comments(msg)
91-
msg = msg.lstrip("\n")
92-
commit_title = msg.split("\n")[0]
93-
commit_body = "\n".join(msg.split("\n")[1:])
94-
return [git.GitCommit(rev="", title=commit_title, body=commit_body)]
95-
elif self.commit_msg is not None:
96-
# Enter this branch if commit_msg is "".
97-
self.commit_msg = self._filter_comments(self.commit_msg)
98-
return [git.GitCommit(rev="", title="", body=self.commit_msg)]
96+
return [git.GitCommit(rev="", title="", body=msg)]
9997

10098
# Get commit messages from git log (--rev-range)
10199
return git.get_commits(end=self.rev_range)

0 commit comments

Comments
(0)

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