Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/overcommit/hook/prepare_commit_msg/replace_branch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def skipped_commit_types
end

def skip?
skipped_commit_types.include?(commit_message_source)
super || skipped_commit_types.include?(commit_message_source)
end
end
end
20 changes: 20 additions & 0 deletions spec/overcommit/hook/prepare_commit_msg/replace_branch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ def remove_file(name)
expect(File.read('COMMIT_EDITMSG')).to eq("[123] \n")
end
end

context 'when skip_if exits with a zero status' do
let(:config) { new_config('skip_if' => ['bash', '-c', 'exit 0']) }

it { is_expected.to pass }

it 'does not change the commit message' do
expect(File.read('COMMIT_EDITMSG')).to eq("\n")
end
end

context 'when skip_if exits with a non-zero status' do
let(:config) { new_config('skip_if' => ['bash', '-c', 'exit 1']) }

it { is_expected.to pass }

it 'does change the commit message' do
expect(File.read('COMMIT_EDITMSG')).to eq("[#123]\n")
end
end
end

context "when the checked out branch doesn't matches the pattern" do
Expand Down