File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change 1818#  the commit message file is the last remaining arg
1919msg_file=" $1 " 
2020
21- #  join types with | to form regex ORs
22- r_types=" ($( IFS=' |' ;  echo  " ${types[*]} " )  )" 
23- #  optional (scope)
24- r_scope=" (\([[:alnum:] \/-]+\))?" 
25- #  optional breaking change indicator and colon delimiter
26- r_delim=' !?:' 
27- #  subject line, body, footer
28- r_subject="  [[:alnum:]].+" 
29- #  the full regex pattern
30- pattern=" ^$r_types$r_scope$r_delim$r_subject $" 
21+ commit_msg_type_regex=' feat|fix|refactor|style|test|docs|build' 
22+ commit_msg_scope_regex=' .{1,20}' 
23+ commit_msg_subject_regex=' .{1,100}' 
24+ commit_msg_regex=" ^(${commit_msg_type_regex} )(\(${commit_msg_scope_regex} \))?: (${commit_msg_subject_regex} )\$ " 
3125merge_msg_regex=" ^Merge branch '.+'\$ " 
3226
27+ commit_msg_header=$( git show -s --format=%s $msg_file ) 
28+ 
3329#  Check if commit is conventional commit
34- if  grep -Eq  " $pattern  | $ merge_msg_regex"   " $msg_file " ;  then 
30+ if  !  [[  " $commit_msg_header  "   =~  ( ${commit_msg_regex} ) | ( ${ merge_msg_regex} ) ]] ;  then 
3531    exit  0
3632fi 
3733
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments