summaryrefslogtreecommitdiff
path: root/app/models/tree.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2012-09-17 12:38:59 -0400
committerRobert Speicher <rspeicher@gmail.com>2012-09-26 16:32:21 -0400
commite33cbb9b4252e2617bcb4c3f850c47aae43e4d83 (patch)
treeb335b89356875b8ce854e9514156996af66ed48a /app/models/tree.rb
parent884eb732977ee785c48a954542e8735cd572e1fe (diff)
downloadgitlab-ce-e33cbb9b4252e2617bcb4c3f850c47aae43e4d83.tar.gz
Add TreeController and spec
Diffstat (limited to 'app/models/tree.rb')
-rw-r--r--app/models/tree.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/tree.rb b/app/models/tree.rb
index d65e50ab817..88e8f2f4663 100644
--- a/app/models/tree.rb
+++ b/app/models/tree.rb
@@ -1,5 +1,5 @@
class Tree
- include Linguist::BlobHelper
+ include Linguist::BlobHelper
attr_accessor :path, :tree, :project, :ref
delegate :contents,
@@ -14,8 +14,8 @@ class Tree
to: :tree
def initialize(raw_tree, project, ref = nil, path = nil)
- @project, @ref, @path = project, ref, path,
- @tree = if path
+ @project, @ref, @path = project, ref, path
+ @tree = if path.present?
raw_tree / path.dup.force_encoding('ascii-8bit')
else
raw_tree
@@ -26,6 +26,10 @@ class Tree
tree.is_a?(Grit::Blob)
end
+ def invalid?
+ tree.nil?
+ end
+
def empty?
data.blank?
end