debian-mirror-gitlab/lib/gitlab/wiki_file_finder.rb

24 lines
481 B
Ruby
Raw Normal View History

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
attr_reader :repository
def initialize(project, ref)
@project = project
@ref = ref
@repository = project.wiki.repository
end
private
2019-12-26 22:10:19 +05:30
def search_paths(query)
2018-11-08 19:23:39 +05:30
safe_query = Regexp.escape(query.tr(' ', '-'))
safe_query = Regexp.new(safe_query, Regexp::IGNORECASE)
2019-12-26 22:10:19 +05:30
paths = repository.ls_files(ref)
2018-11-08 19:23:39 +05:30
2019-12-26 22:10:19 +05:30
paths.grep(safe_query)
2018-11-08 19:23:39 +05:30
end
end
end