File tree 2 files changed +14
-8
lines changed
lib/overcommit/hook/commit_msg
spec/overcommit/hook/commit_msg
2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,17 @@ def find_errors_in_subject(subject)
21
21
max_subject_width =
22
22
config [ 'max_subject_width' ] +
23
23
special_prefix_length ( subject )
24
- min_subject_width = config [ 'min_subject_width' ]
25
- return unless subject . length > max_subject_width || subject . length < min_subject_width
26
24
27
- @errors << "Please keep the subject <= #{ max_subject_width } and >= " \
28
- "#{ min_subject_width } characters"
25
+ if subject . length > max_subject_width
26
+ @errors << "Commit message subject must be <= #{ max_subject_width } characters"
27
+ return
28
+ end
29
+
30
+ min_subject_width = config [ 'min_subject_width' ]
31
+ if subject . length < min_subject_width
32
+ @errors << "Commit message subject must be >= #{ min_subject_width } characters"
33
+ return
34
+ end
29
35
end
30
36
31
37
def find_errors_in_body ( lines )
Original file line number Diff line number Diff line change 90
90
A message line that is way too long. A message line that is way too long.
91
91
MSG
92
92
93
- it { should warn /keep.*subject <= 60.*\n .*line 3.*> 72.*/im }
93
+ it { should warn /subject.* <= 60.*\n .*line 3.*> 72.*/im }
94
94
end
95
95
96
96
context 'when custom lengths are specified' do
109
109
context 'when subject is longer than 70 characters' do
110
110
let ( :commit_msg ) { 'A' * 71 }
111
111
112
- it { should warn /subject/ }
112
+ it { should warn /subject must be <= 70 / }
113
113
end
114
114
115
115
context 'when subject is less than 4 characters' do
116
116
let ( :commit_msg ) { 'A' * 3 }
117
117
118
- it { should warn /subject/ }
118
+ it { should warn /subject must be >= 4 / }
119
119
end
120
120
121
121
context 'when subject is 70 characters or fewer' do
153
153
This line is longer than #{ 'A' * 80 } characters.
154
154
MSG
155
155
156
- it { should warn /keep.*subject <= 70.*\n .*line 3.*> 80.* /im }
156
+ it { should warn /subject.* <= 70.*\n .*line 3.*> 80/im }
157
157
end
158
158
end
159
159
end
You can’t perform that action at this time.
0 commit comments