File tree 3 files changed +12
-2
lines changed
lib/overcommit/hook/commit_msg
spec/overcommit/hook/commit_msg
3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ CommitMsg:
108
108
enabled : true
109
109
description : ' Check text width'
110
110
max_subject_width : 60
111
+ min_subject_width : 0
111
112
max_body_width : 72
112
113
113
114
TrailingPeriod :
Original file line number Diff line number Diff line change @@ -21,9 +21,11 @@ def find_errors_in_subject(subject)
21
21
max_subject_width =
22
22
config [ 'max_subject_width' ] +
23
23
special_prefix_length ( subject )
24
- return unless subject . length > max_subject_width
24
+ min_subject_width = config [ 'min_subject_width' ]
25
+ return unless subject . length > max_subject_width || subject . length < min_subject_width
25
26
26
- @errors << "Please keep the subject <= #{ max_subject_width } characters"
27
+ @errors << "Please keep the subject <= #{ max_subject_width } and >= " \
28
+ "#{ min_subject_width } characters"
27
29
end
28
30
29
31
def find_errors_in_body ( lines )
Original file line number Diff line number Diff line change 99
99
'CommitMsg' => {
100
100
'TextWidth' => {
101
101
'max_subject_width' => 70 ,
102
+ 'min_subject_width' => 4 ,
102
103
'max_body_width' => 80
103
104
}
104
105
}
111
112
it { should warn /subject/ }
112
113
end
113
114
115
+ context 'when subject is less than 4 characters' do
116
+ let ( :commit_msg ) { 'A' * 3 }
117
+
118
+ it { should warn /subject/ }
119
+ end
120
+
114
121
context 'when subject is 70 characters or fewer' do
115
122
let ( :commit_msg ) { 'A' * 70 }
116
123
You can’t perform that action at this time.
0 commit comments