Ensure we don't check a commit's description for revert message if it has no description
This commit is contained in:
parent
96ce80d578
commit
96ed5c5114
|
@ -232,7 +232,7 @@ class Commit
|
||||||
end
|
end
|
||||||
|
|
||||||
def reverts_commit?(commit)
|
def reverts_commit?(commit)
|
||||||
description.include?(commit.revert_description)
|
description? && description.include?(commit.revert_description)
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge_commit?
|
def merge_commit?
|
||||||
|
|
|
@ -118,4 +118,38 @@ eos
|
||||||
it { expect(data[:modified]).to eq([".gitmodules"]) }
|
it { expect(data[:modified]).to eq([".gitmodules"]) }
|
||||||
it { expect(data[:removed]).to eq([]) }
|
it { expect(data[:removed]).to eq([]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#reverts_commit?' do
|
||||||
|
let(:another_commit) { double(:commit, revert_description: "This reverts commit #{commit.sha}") }
|
||||||
|
|
||||||
|
it { expect(commit.reverts_commit?(another_commit)).to be_falsy }
|
||||||
|
|
||||||
|
context 'commit has no description' do
|
||||||
|
before { allow(commit).to receive(:description?).and_return(false) }
|
||||||
|
|
||||||
|
it { expect(commit.reverts_commit?(another_commit)).to be_falsy }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "another_commit's description does not revert commit" do
|
||||||
|
before { allow(commit).to receive(:description).and_return("Foo Bar") }
|
||||||
|
|
||||||
|
it { expect(commit.reverts_commit?(another_commit)).to be_falsy }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "another_commit's description reverts commit" do
|
||||||
|
before { allow(commit).to receive(:description).and_return("Foo #{another_commit.revert_description} Bar") }
|
||||||
|
|
||||||
|
it { expect(commit.reverts_commit?(another_commit)).to be_truthy }
|
||||||
|
end
|
||||||
|
|
||||||
|
context "another_commit's description reverts merged merge request" do
|
||||||
|
before do
|
||||||
|
revert_description = "This reverts merge request !foo123"
|
||||||
|
allow(another_commit).to receive(:revert_description).and_return(revert_description)
|
||||||
|
allow(commit).to receive(:description).and_return("Foo #{another_commit.revert_description} Bar")
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(commit.reverts_commit?(another_commit)).to be_truthy }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue