File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -81,15 +81,23 @@ def _get_commits(self):
8181 # Get commit message from file (--commit-msg-file)
8282 if self .commit_msg_file :
8383 with open (self .commit_msg_file , "r" , encoding = "utf-8" ) as commit_file :
84- commit_title = commit_file .readline ()
85- commit_body = commit_file .read ()
84+ msg = commit_file .read ()
85+ msg = self ._filter_comments (msg )
86+ msg = msg .lstrip ("\n " )
87+ commit_title = msg .split ("\n " )[0 ]
88+ commit_body = "\n " .join (msg .split ("\n " )[1 :])
8689 return [git .GitCommit (rev = "" , title = commit_title , body = commit_body )]
8790 elif self .commit_msg :
91+ self .commit_msg = self ._filter_comments (self .commit_msg )
8892 return [git .GitCommit (rev = "" , title = "" , body = self .commit_msg )]
8993
9094 # Get commit messages from git log (--rev-range)
9195 return git .get_commits (end = self .rev_range )
9296
97+ def _filter_comments (self , msg : str ) -> str :
98+ lines = [line for line in msg .split ('\n ' ) if not line .startswith ('#' )]
99+ return "\n " .join (lines )
100+
93101 @staticmethod
94102 def validate_commit_message (commit_msg : str , pattern : str ) -> bool :
95103 if commit_msg .startswith ("Merge" ) or commit_msg .startswith ("Revert" ):
You can’t perform that action at this time.
0 commit comments