Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-01 18:00:28 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-01 18:00:28 +0400
commitae9dd6276267e0df2d9c2da3b89393e4ee212175 (patch)
tree4db4314bd54eda3bce6b3c67b719f1f5097fb68a /app/models/tree.rb
parente219cf7246c6a0495e4507deaffeba11e79f13b8 (diff)
Update code to work with gitlab_git 3
Diffstat (limited to 'app/models/tree.rb')
-rw-r--r--app/models/tree.rb24
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