File tree Expand file tree Collapse file tree
lib/overcommit/hook/commit_msg
spec/overcommit/hook/commit_msg Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55* Fix ` Scalastyle ` pre-commit hook to capture messages with no line number
66* Fix ` CoffeeLint ` pre-commit hook detection of modified lines
77* Fix ` Jscs ` pre-commit hook to work with ` jscs ` 3.0.0+
8+ * Fix ` CapitalizedSubject ` pre-commit hook to ignore commit message subjects
9+ starting with ` fixup! ` or ` squash! ` special prefixes
810
911## 0.33.0
1012
Original file line number Diff line number Diff line change @@ -4,12 +4,19 @@ class CapitalizedSubject < Base
44 def run
55 return :pass if empty_message?
66
7- first_letter = commit_message_lines [ 0 ] . to_s . match ( /^[[:punct:]]*(.)/ ) [ 1 ]
8- unless first_letter =~ /[[:upper:]]/
7+ subject = commit_message_lines [ 0 ] . to_s
8+ first_letter = subject . match ( /^[[:punct:]]*(.)/ ) [ 1 ]
9+ unless special_prefix? ( subject ) || first_letter =~ /[[:upper:]]/
910 return :warn , 'Subject should start with a capital letter'
1011 end
1112
1213 :pass
1314 end
15+
16+ private
17+
18+ def special_prefix? ( subject )
19+ subject =~ /^(fixup|squash)!/
20+ end
1421 end
1522end
Original file line number Diff line number Diff line change 7979
8080 it { should warn }
8181 end
82+
83+ context 'when subject starts with special "fixup!" prefix' do
84+ let ( :commit_msg ) { <<-MSG }
85+ fixup! commit
86+
87+ This was created by running git commit --fixup=...
88+ MSG
89+
90+ it { should pass }
91+ end
92+
93+ context 'when subject starts with special "squash!" prefix' do
94+ let ( :commit_msg ) { <<-MSG }
95+ squash! commit
96+
97+ This was created by running git commit --squash=...
98+ MSG
99+
100+ it { should pass }
101+ end
82102end
You can’t perform that action at this time.
0 commit comments