Skip to content

Commit d0c37a0

Browse files
committed
Pass SingleLineSubject hook when commit message is empty
1 parent 7b11e0a commit d0c37a0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/overcommit/hook/commit_msg/single_line_subject.rb

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module Overcommit::Hook::CommitMsg
22
# Ensures commit message subject lines are followed by a blank line.
33
class SingleLineSubject < Base
44
def run
5+
return :pass if empty_message?
6+
57
unless commit_message_lines[1].to_s.strip.empty?
68
return :warn, 'Subject should be one line and followed by a blank line'
79
end

spec/overcommit/hook/commit_msg/single_line_subject_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77

88
before do
99
subject.stub(:commit_message_lines).and_return(commit_msg.split("\n"))
10+
subject.stub(:empty_message?).and_return(commit_msg.empty?)
11+
end
12+
13+
context 'when commit message is empty' do
14+
let(:commit_msg) { '' }
15+
16+
it { should pass }
1017
end
1118

1219
context 'when subject is separated from body by a blank line' do

0 commit comments

Comments
 (0)