@ -32,7 +32,7 @@ class BodyMinLineCount(CommitRule):
line_count = len ( filtered )
line_count = len ( filtered )
min_line_count = self . options [ ' min-line-count ' ] . value
min_line_count = self . options [ ' min-line-count ' ] . value
if line_count < min_line_count :
if line_count < min_line_count :
message = " B ody has no content, should at least have {} line. " . format ( min_line_count )
message = " Commit b ody has no content, should at least have {} line(s) . " . format ( min_line_count )
return [ RuleViolation ( self . id , message , line_nr = 1 ) ]
return [ RuleViolation ( self . id , message , line_nr = 1 ) ]
class BodyMaxLineCount ( CommitRule ) :
class BodyMaxLineCount ( CommitRule ) :
@ -49,7 +49,7 @@ class BodyMaxLineCount(CommitRule):
line_count = len ( commit . message . body )
line_count = len ( commit . message . body )
max_line_count = self . options [ ' max-line-count ' ] . value
max_line_count = self . options [ ' max-line-count ' ] . value
if line_count > max_line_count :
if line_count > max_line_count :
message = " B ody contains too many lines ({0} > {1} ) " . format ( line_count , max_line_count )
message = " Commit b ody contains too many lines ({0} > {1} ) " . format ( line_count , max_line_count )
return [ RuleViolation ( self . id , message , line_nr = 1 ) ]
return [ RuleViolation ( self . id , message , line_nr = 1 ) ]
class SignedOffBy ( CommitRule ) :
class SignedOffBy ( CommitRule ) :
@ -72,14 +72,14 @@ class SignedOffBy(CommitRule):
return [ RuleViolation ( self . id , " Signed-off-by: must have a full name " , line_nr = 1 ) ]
return [ RuleViolation ( self . id , " Signed-off-by: must have a full name " , line_nr = 1 ) ]
else :
else :
return
return
return [ RuleViolation ( self . id , " B ody does not contain a ' Signed-off-by: ' line " , line_nr = 1 ) ]
return [ RuleViolation ( self . id , " Commit b ody does not contain a ' Signed-off-by: ' line " , line_nr = 1 ) ]
class TitleMaxLengthRevert ( LineRule ) :
class TitleMaxLengthRevert ( LineRule ) :
name = " title-max-length-no-revert "
name = " title-max-length-no-revert "
id = " UC5 "
id = " UC5 "
target = CommitMessageTitle
target = CommitMessageTitle
options_spec = [ IntOption ( ' line-length ' , 72 , " Max line length " ) ]
options_spec = [ IntOption ( ' line-length ' , 72 , " Max line length " ) ]
violation_message = " T itle exceeds max length ({0} > {1} ) "
violation_message = " Commit t itle exceeds max length ({0} > {1} ) "
def validate ( self , line , _commit ) :
def validate ( self , line , _commit ) :
max_length = self . options [ ' line-length ' ] . value
max_length = self . options [ ' line-length ' ] . value
@ -95,7 +95,7 @@ class TitleStartsWithSubsystem(LineRule):
def validate ( self , title , _commit ) :
def validate ( self , title , _commit ) :
regex = self . options [ ' regex ' ] . value
regex = self . options [ ' regex ' ] . value
pattern = re . compile ( regex , re . UNICODE )
pattern = re . compile ( regex , re . UNICODE )
violation_message = " T itle does not follow [subsystem]: [subject] (and should not start with literal subsys:)"
violation_message = " Commit t itle does not follow [subsystem]: [subject] (and should not start with literal subsys:)"
if not pattern . search ( title ) :
if not pattern . search ( title ) :
return [ RuleViolation ( self . id , violation_message , title ) ]
return [ RuleViolation ( self . id , violation_message , title ) ]
@ -104,7 +104,7 @@ class MaxLineLengthExceptions(LineRule):
id = " UC4 "
id = " UC4 "
target = CommitMessageBody
target = CommitMessageBody
options_spec = [ IntOption ( ' line-length ' , 80 , " Max line length " ) ]
options_spec = [ IntOption ( ' line-length ' , 80 , " Max line length " ) ]
violation_message = " L ine exceeds max length ({0} > {1} ) "
violation_message = " Commit body l ine exceeds max length ({0} > {1} ) "
def validate ( self , line , _commit ) :
def validate ( self , line , _commit ) :
max_length = self . options [ ' line-length ' ] . value
max_length = self . options [ ' line-length ' ] . value
@ -128,5 +128,5 @@ class BodyContainsBlockedTags(LineRule):
flags = re . IGNORECASE
flags = re . IGNORECASE
for tag in self . tags :
for tag in self . tags :
if re . search ( rf " ^ \ s* { tag } : " , line , flags = flags ) :
if re . search ( rf " ^ \ s* { tag } : " , line , flags = flags ) :
return [ RuleViolation ( self . id , f " B ody contains a blocked tag: { tag } " ) ]
return [ RuleViolation ( self . id , f " Commit b ody contains a blocked tag: { tag } " ) ]
return
return