Commit 88f9ed3d authored by Douwe Maan's avatar Douwe Maan

Move finding of contributing file from tree to repository.

parent dbd347bf
...@@ -197,7 +197,12 @@ class Repository ...@@ -197,7 +197,12 @@ class Repository
end end
def contribution_guide def contribution_guide
cache.fetch(:contribution_guide) { tree(:head).contribution_guide } cache.fetch(:contribution_guide) do
tree(:head).blobs.find do |file|
file.contributing?
end
end
end
end end
def head_commit def head_commit
......
class Tree class Tree
include Gitlab::MarkdownHelper include Gitlab::MarkdownHelper
attr_accessor :entries, :readme, :contribution_guide attr_accessor :entries, :readme
def initialize(repository, sha, path = '/') def initialize(repository, sha, path = '/')
path = '/' if path.blank? path = '/' if path.blank?
...@@ -28,11 +28,6 @@ class Tree ...@@ -28,11 +28,6 @@ class Tree
readme_path = path == '/' ? readme_tree.name : File.join(path, readme_tree.name) readme_path = path == '/' ? readme_tree.name : File.join(path, readme_tree.name)
@readme = Gitlab::Git::Blob.find(git_repo, sha, readme_path) @readme = Gitlab::Git::Blob.find(git_repo, sha, readme_path)
end end
if contribution_tree = @entries.find(&:contributing?)
contribution_path = path == '/' ? contribution_tree.name : File.join(path, contribution_tree.name)
@contribution_guide = Gitlab::Git::Blob.find(git_repo, sha, contribution_path)
end
end end
def trees def trees
......
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