diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-03-17 10:33:25 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-03-18 14:08:26 +0100 |
commit | d328b4166ed235346e3ea841f178a52224c23c99 (patch) | |
tree | c94ae48603afb671056ac92d03660f935d5fa1b5 /app/models | |
parent | 6581aea3bf8e3529aa4fed85ccd923b2afb630b5 (diff) | |
download | gitlab-ce-d328b4166ed235346e3ea841f178a52224c23c99.tar.gz |
Fix tree readme.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/tree.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/models/tree.rb b/app/models/tree.rb index d3f9176c79c..f279e896cda 100644 --- a/app/models/tree.rb +++ b/app/models/tree.rb @@ -1,18 +1,23 @@ class Tree include Gitlab::MarkdownHelper - attr_accessor :entries + attr_accessor :repository, :sha, :path, :entries def initialize(repository, sha, path = '/') path = '/' if path.blank? - git_repo = repository.raw_repository - @entries = Gitlab::Git::Tree.where(git_repo, sha, path) + + @repository = repository + @sha = sha + @path = path + + git_repo = @repository.raw_repository + @entries = Gitlab::Git::Tree.where(git_repo, @sha, @path) end def readme return @readme if defined?(@readme) - available_readmes = @blobs.select(&:readme?) + available_readmes = blobs.select(&:readme?) if available_readmes.count == 0 return @readme = nil @@ -26,6 +31,7 @@ class Tree readme_path = path == '/' ? readme_tree.name : File.join(path, readme_tree.name) + git_repo = repository.raw_repository @readme = Gitlab::Git::Blob.find(git_repo, sha, readme_path) end |