@@ -97,12 +97,10 @@ def check_subject_uses_imperative(commit_message):
9797 third_person_blob = TextBlob (third_person_prefix + first_line )
9898 non_third_person_blob = TextBlob (non_third_person_prefix + first_line )
9999
100- first_word , third_person_result = third_person_blob .tags [
101- words_in_third_person_prefix_blob
102- ]
103- _ , non_third_person_result = non_third_person_blob .tags [
104- words_in_non_third_person_prefix_blob
105- ]
100+ tags = third_person_blob .tags
101+ first_word , third_person_result = tags [words_in_third_person_prefix_blob ]
102+ tags = non_third_person_blob .tags
103+ _ , non_third_person_result = tags [words_in_non_third_person_prefix_blob ]
106104
107105 # We need to determine whether the first word is a non-third person verb
108106 # when parsed in a non-third person blob. However, there were some
@@ -167,6 +165,12 @@ def check(
167165 return all_rules_verified
168166
169167
168+ def strip_prefix (commit_message ):
169+ if ":" in commit_message :
170+ return commit_message [commit_message .index (":" ) + 1 :].strip ()
171+ return commit_message
172+
173+
170174def main ():
171175 parser_description = (
172176 "Bad commit message blocker: Avoid bad commit messages in your repository"
@@ -183,6 +187,13 @@ def main():
183187 help = "The maximum allowed length for a line in the commit body" ,
184188 default = DEFAULT_BODY_LIMIT ,
185189 )
190+ parser .add_argument (
191+ "--conventional-commit" ,
192+ help = "Whether the commit message follows the conventional commit format,"
193+ " e.g. 'feat: add new feature'" ,
194+ type = bool ,
195+ default = False ,
196+ )
186197 args = parser .parse_args ()
187198
188199 commit_message = args .message .strip ()
@@ -197,6 +208,9 @@ def main():
197208 + CliColors .ENDC
198209 )
199210
211+ if args .conventional_commit :
212+ commit_message = strip_prefix (commit_message )
213+
200214 all_rules_verified = check (
201215 commit_message , int (args .subject_limit ), int (args .body_limit )
202216 )
0 commit comments