@@ -764,7 +764,7 @@ def check_commit_msg(message, files):
764764 does not contain required marker.
765765
766766 '''
767- if re .match (r'$ Merge branch \'.+?\' into .+' , message ):
767+ if re .match (r'^ Merge branch \'.+?\' into .+' , message ):
768768 # Not checking for JIRA in commit message generated by github
769769 pass
770770 elif NO_JIRA_MARKER not in message :
@@ -809,6 +809,20 @@ def _test(input, is_jira=True):
809809 _test ('BLD-1234word' , False )
810810
811811
812+ class TestCheckCommitMessage (unittest .TestCase ):
813+ def test_various_strings (self ):
814+ def _test (input , is_good = True ):
815+ rc = check_commit_msg (input , [])
816+ self .assertEqual (rc == 0 , is_good )
817+ _test ('ABC-1234' )
818+ _test ('Some changes for ABC-1234 ticket' )
819+ _test ('Trivail change NO_JIRA' )
820+ _test ("Merge branch 'main' into my_branch" )
821+ _test ("Merge branch 'branch_1' into branch_2" )
822+ _test ('I forgot to add the jira marker!' , False )
823+ _test ('Close but no cigar abc-1234' , False )
824+
825+
812826def commit_hook (merge = False ):
813827 retval = 0
814828 files = get_commit_files ()
0 commit comments