diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-01 17:00:28 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-10-01 17:00:28 +0300 |
commit | ae9dd6276267e0df2d9c2da3b89393e4ee212175 (patch) | |
tree | 4db4314bd54eda3bce6b3c67b719f1f5097fb68a /app/models/tree.rb | |
parent | e219cf7246c6a0495e4507deaffeba11e79f13b8 (diff) | |
download | gitlab-ce-ae9dd6276267e0df2d9c2da3b89393e4ee212175.tar.gz |
Update code to work with gitlab_git 3
Diffstat (limited to 'app/models/tree.rb')
-rw-r--r-- | app/models/tree.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/app/models/tree.rb b/app/models/tree.rb index 042050527c1..5fbad19b468 100644 --- a/app/models/tree.rb +++ b/app/models/tree.rb @@ -1,17 +1,25 @@ class Tree - attr_accessor :raw + attr_accessor :entries, :readme - def initialize(repository, sha, ref = nil, path = nil) - @raw = Gitlab::Git::Tree.new(repository, sha, ref, path) + def initialize(repository, sha, path = '/') + path = '/' if path.blank? + git_repo = repository.raw_repository + @entries = Gitlab::Git::Tree.where(git_repo, sha, path) + + if readme_tree = @entries.find(&:readme?) + @readme = Gitlab::Git::Blob.find(git_repo, sha, readme_tree.name) + end end - def method_missing(m, *args, &block) - @raw.send(m, *args, &block) + def trees + @entries.select(&:dir?) end - def respond_to?(method) - return true if @raw.respond_to?(method) + def blobs + @entries.select(&:file?) + end - super + def submodules + @entries.select(&:submodule?) end end |