Commit e9ec241b authored by Stan Hu's avatar Stan Hu

Merge branch 'es_fix_for_unborn_head' into 'master'

[ES] Fix for unborn head

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/21038

See merge request !669
parents bc9fc90b c65b42aa
......@@ -1248,16 +1248,16 @@ class Repository
end
end
def head_exists?
exists? && !empty? && !rugged.head_unborn?
end
private
def cache
@cache ||= RepositoryCache.new(path_with_namespace, @project.id)
end
def head_exists?
exists? && !empty? && !rugged.head_unborn?
end
def file_on_head(regex)
tree(:head).blobs.find { |file| file.name =~ regex }
end
......
......@@ -7,7 +7,7 @@ class ElasticCommitIndexerWorker
project = Project.find(project_id)
repository = project.repository
return true unless repository.exists? && !repository.empty?
return true unless repository.head_exists?
indexer = Gitlab::Elastic::Indexer.new
indexer.run(
......
......@@ -18,5 +18,14 @@ describe ElasticCommitIndexerWorker do
subject.perform(empty_project.id, '0000', '0000')
end
it 'returns true if repository has unborn head' do
project = create :project
rugged = double('rugged')
expect(rugged).to receive(:head_unborn?).and_return(true)
expect_any_instance_of(Repository).to receive(:rugged).and_return(rugged)
expect(subject.perform(project.id)).to be_truthy
end
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