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):
81
81
# Get commit message from file (--commit-msg-file)
82
82
if self .commit_msg_file :
83
83
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 :])
86
89
return [git .GitCommit (rev = "" , title = commit_title , body = commit_body )]
87
90
elif self .commit_msg :
91
+ self .commit_msg = self ._filter_comments (self .commit_msg )
88
92
return [git .GitCommit (rev = "" , title = "" , body = self .commit_msg )]
89
93
90
94
# Get commit messages from git log (--rev-range)
91
95
return git .get_commits (end = self .rev_range )
92
96
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
+
93
101
@staticmethod
94
102
def validate_commit_message (commit_msg : str , pattern : str ) -> bool :
95
103
if commit_msg .startswith ("Merge" ) or commit_msg .startswith ("Revert" ):
You can’t perform that action at this time.
0 commit comments