2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
module Gitlab
|
|
|
|
class WikiFileFinder < FileFinder
|
2019-02-13 22:33:31 +05:30
|
|
|
BATCH_SIZE = 100
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
attr_reader :repository
|
|
|
|
|
|
|
|
def initialize(project, ref)
|
|
|
|
@project = project
|
|
|
|
@ref = ref
|
|
|
|
@repository = project.wiki.repository
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
def search_filenames(query)
|
2018-11-08 19:23:39 +05:30
|
|
|
safe_query = Regexp.escape(query.tr(' ', '-'))
|
|
|
|
safe_query = Regexp.new(safe_query, Regexp::IGNORECASE)
|
|
|
|
filenames = repository.ls_files(ref)
|
|
|
|
|
|
|
|
filenames.grep(safe_query).first(BATCH_SIZE)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|