Renamed text? method in ElasticSearch module to text_in_repo?

parent 84ac9253
---
title: Replacing old blob methods in ElasticSerach module
merge_request: 9418
author:
type: fixed
......@@ -13,7 +13,7 @@ module Elasticsearch
@id = raw_blob_hash[:oid]
@blob = repo.lookup(@id)
@mode = raw_blob_hash[:mode].to_s(8)
@mode = (raw_blob_hash[:mode] || raw_blob_hash[:filemode]).to_s(8)
@size = @blob.size
@path = encode!(raw_blob_hash[:path])
@name = @path.split('/').last
......
......@@ -74,7 +74,7 @@ module Elasticsearch
end
def delete_blob(blob)
return unless blob.text?
return unless blob.text_in_repo?
{
delete: {
......@@ -246,7 +246,6 @@ module Elasticsearch
result = []
target_sha = repository_for_indexing.head.target.oid
if repository_for_indexing.bare?
tree = repository_for_indexing.lookup(target_sha).tree
result.push(recurse_blobs_index_hash(tree))
......@@ -254,7 +253,7 @@ module Elasticsearch
repository_for_indexing.index.each do |blob|
b = LiteBlob.new(repository_for_indexing, blob)
if b.text?
if b.text_in_repo?
result.push(
{
id: "#{target_sha}_#{b.path}",
......@@ -277,7 +276,7 @@ module Elasticsearch
blob[:path] = path + blob[:name]
b = LiteBlob.new(repository_for_indexing, blob)
if b.text?
if b.text_in_repo?
result.push(
{
id: "#{repository_for_indexing.head.target.oid}_#{path}#{blob[:name]}",
......
......@@ -32,6 +32,21 @@ describe Repository, :elastic do
expect(project.repository.search('def | popen extension:md')[:blobs][:total_count]).to eq(1)
end
it 'can delete blobs' do
project = create :project, :repository
blob = project.repository.blob_at('b83d6e391c22777fca1ed3012fce84f633d7fed0', 'files/ruby/popen.rb')
expect(project.repository.delete_blob(blob)[:delete]).not_to be_empty
end
it 'can return the index as a json' do
project = create :project, :repository
index = project.repository.as_indexed_json
expect(index[:blobs]).not_to be_empty
expect(index[:commits]).not_to be_empty
end
def search_and_check!(on, query, type:, per: 1000)
results = on.search(query, type: type, per: per)["#{type}s".to_sym][:results]
......
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