2018-10-22 03:00:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-04 07:41:37 -04:00
|
|
|
module Gitlab
|
|
|
|
class WikiFileFinder < FileFinder
|
2018-12-02 16:47:33 -05:00
|
|
|
BATCH_SIZE = 100
|
|
|
|
|
2018-06-04 07:41:37 -04:00
|
|
|
attr_reader :repository
|
|
|
|
|
|
|
|
def initialize(project, ref)
|
|
|
|
@project = project
|
|
|
|
@ref = ref
|
|
|
|
@repository = project.wiki.repository
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-12-02 16:47:33 -05:00
|
|
|
def search_filenames(query)
|
2018-06-04 07:41:37 -04:00
|
|
|
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
|