Skip to content

Commit 90e3679

Browse files
authored
Allow ReplaceBranch to use skip_if (#809)
* Allow ReplaceBranch to use skip_if * Fix linting error * Clearify specs * Use bash instead of sh in spec
1 parent 2214dd1 commit 90e3679

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/overcommit/hook/prepare_commit_msg/replace_branch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def skipped_commit_types
8585
end
8686

8787
def skip?
88-
skipped_commit_types.include?(commit_message_source)
88+
super || skipped_commit_types.include?(commit_message_source)
8989
end
9090
end
9191
end

spec/overcommit/hook/prepare_commit_msg/replace_branch_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ def remove_file(name)
7070
expect(File.read('COMMIT_EDITMSG')).to eq("[123] \n")
7171
end
7272
end
73+
74+
context 'when skip_if exits with a zero status' do
75+
let(:config) { new_config('skip_if' => ['bash', '-c', 'exit 0']) }
76+
77+
it { is_expected.to pass }
78+
79+
it 'does not change the commit message' do
80+
expect(File.read('COMMIT_EDITMSG')).to eq("\n")
81+
end
82+
end
83+
84+
context 'when skip_if exits with a non-zero status' do
85+
let(:config) { new_config('skip_if' => ['bash', '-c', 'exit 1']) }
86+
87+
it { is_expected.to pass }
88+
89+
it 'does change the commit message' do
90+
expect(File.read('COMMIT_EDITMSG')).to eq("[#123]\n")
91+
end
92+
end
7393
end
7494

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

0 commit comments

Comments
 (0)