Commit afe86792 authored by Stan Hu's avatar Stan Hu

Rename branches_exist? -> includes_branches?

parent d96c24d8
...@@ -43,7 +43,7 @@ class PostReceive ...@@ -43,7 +43,7 @@ class PostReceive
return false unless user return false unless user
# Expire the branches cache so we have updated data for this push # Expire the branches cache so we have updated data for this push
post_received.project.repository.expire_branches_cache if post_received.branches_exist? post_received.project.repository.expire_branches_cache if post_received.includes_branches?
post_received.enum_for(:changes_refs).with_index do |(oldrev, newrev, ref), index| post_received.enum_for(:changes_refs).with_index do |(oldrev, newrev, ref), index|
service_klass = service_klass =
......
...@@ -27,12 +27,10 @@ module Gitlab ...@@ -27,12 +27,10 @@ module Gitlab
end end
end end
def branches_exist? def includes_branches?
changes_refs do |_oldrev, _newrev, ref| enum_for(:changes_refs).any? do |_oldrev, _newrev, ref|
return true if Gitlab::Git.branch_ref?(ref) # rubocop:disable Cop/AvoidReturnFromBlocks Gitlab::Git.branch_ref?(ref)
end end
false
end end
private private
......
...@@ -7,7 +7,7 @@ describe ::Gitlab::GitPostReceive do ...@@ -7,7 +7,7 @@ describe ::Gitlab::GitPostReceive do
subject { described_class.new(project, "project-#{project.id}", changes.dup, {}) } subject { described_class.new(project, "project-#{project.id}", changes.dup, {}) }
describe '#branches_exist?' do describe '#includes_branches?' do
context 'with no branches' do context 'with no branches' do
let(:changes) do let(:changes) do
<<~EOF <<~EOF
...@@ -18,7 +18,7 @@ describe ::Gitlab::GitPostReceive do ...@@ -18,7 +18,7 @@ describe ::Gitlab::GitPostReceive do
end end
it 'returns false' do it 'returns false' do
expect(subject.branches_exist?).to be_falsey expect(subject.includes_branches?).to be_falsey
end end
end end
...@@ -32,7 +32,7 @@ describe ::Gitlab::GitPostReceive do ...@@ -32,7 +32,7 @@ describe ::Gitlab::GitPostReceive do
end end
it 'returns true' do it 'returns true' do
expect(subject.branches_exist?).to be_truthy expect(subject.includes_branches?).to be_truthy
end end
end end
...@@ -45,7 +45,7 @@ describe ::Gitlab::GitPostReceive do ...@@ -45,7 +45,7 @@ describe ::Gitlab::GitPostReceive do
end end
it 'returns false' do it 'returns false' do
expect(subject.branches_exist?).to be_falsey expect(subject.includes_branches?).to be_falsey
end end
end end
end end
......
...@@ -61,16 +61,21 @@ describe PostReceive do ...@@ -61,16 +61,21 @@ describe PostReceive do
end end
context "branches" do context "branches" do
let(:changes) { '123456 789012 refs/heads/tést' } let(:changes) do
<<~EOF
'123456 789012 refs/heads/tést1'
'123456 789012 refs/heads/tést2'
EOF
end
it 'expires the branches cache' do it 'expires the branches cache' do
expect(project.repository).to receive(:expire_branches_cache) expect(project.repository).to receive(:expire_branches_cache).once
described_class.new.perform(gl_repository, key_id, base64_changes) described_class.new.perform(gl_repository, key_id, base64_changes)
end end
it 'calls Git::BranchPushService' do it 'calls Git::BranchPushService' do
expect_next_instance_of(Git::BranchPushService) do |service| expect_any_instance_of(Git::BranchPushService) do |service|
expect(service).to receive(:execute).and_return(true) expect(service).to receive(:execute).and_return(true)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment