diff options
author | Nick Thomas <nick@gitlab.com> | 2018-08-14 22:28:46 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-08-14 22:28:46 +0100 |
commit | ffd164d27f674b554fdffbffa828a9715c93ee60 (patch) | |
tree | fcb940d28e7cf83a853fa802394c2f1b6f12a4fa /lib | |
parent | 6343964b9c7acac25d946545778c8ae6523773da (diff) | |
download | gitlab-ce-ffd164d27f674b554fdffbffa828a9715c93ee60.tar.gz |
Fix bugs in Gitlab::Template::Finders preventing instances from BaseTemplate.all from loading content
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/template/finders/base_template_finder.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/template/finders/repo_template_finder.rb | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/gitlab/template/finders/base_template_finder.rb b/lib/gitlab/template/finders/base_template_finder.rb index 473b05257c6..a5105439b12 100644 --- a/lib/gitlab/template/finders/base_template_finder.rb +++ b/lib/gitlab/template/finders/base_template_finder.rb @@ -21,7 +21,7 @@ module Gitlab def category_directory(category) return @base_dir unless category.present? - @base_dir + @categories[category] + File.join(@base_dir, @categories[category]) end class << self diff --git a/lib/gitlab/template/finders/repo_template_finder.rb b/lib/gitlab/template/finders/repo_template_finder.rb index 33f07fa0120..29bc2393ff9 100644 --- a/lib/gitlab/template/finders/repo_template_finder.rb +++ b/lib/gitlab/template/finders/repo_template_finder.rb @@ -27,7 +27,7 @@ module Gitlab directory = select_directory(file_name) raise FileNotFoundError if directory.nil? - category_directory(directory) + file_name + File.join(category_directory(directory), file_name) end def list_files_for(dir) @@ -37,8 +37,8 @@ module Gitlab entries = @repository.tree(:head, dir).entries - names = entries.map(&:name) - names.select { |f| f =~ self.class.filter_regex(@extension) } + paths = entries.map(&:path) + paths.select { |f| f =~ self.class.filter_regex(@extension) } end private @@ -47,10 +47,10 @@ module Gitlab return [] unless @commit # Insert root as directory - directories = ["", @categories.keys] + directories = ["", *@categories.keys] directories.find do |category| - path = category_directory(category) + file_name + path = File.join(category_directory(category), file_name) @repository.blob_at(@commit.id, path) end end |