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-04-02 22:30:36 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-02 22:30:36 +0400
commit5f4445c3d384741c45242f077b3c0dbf76234ee8 (patch)
tree21962b2905103f2b3a585bda0ba6e60a669cb190 /lib/gitlab/git/tree.rb
parent7af16bbb0fdce36cf8b7e43e5cd64a712dfdaa1d (diff)
store commits for MR as array of hashes
Diffstat (limited to 'lib/gitlab/git/tree.rb')
-rw-r--r--lib/gitlab/git/tree.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/gitlab/git/tree.rb b/lib/gitlab/git/tree.rb
new file mode 100644
index 00000000000..b81ce550f4c
--- /dev/null
+++ b/lib/gitlab/git/tree.rb
@@ -0,0 +1,38 @@
+module Gitlab
+ module Git
+ class Tree
+ include Linguist::BlobHelper
+
+ attr_accessor :repository, :sha, :path, :ref, :raw_tree
+
+ def initialize(repository, sha, ref = nil, path = nil)
+ @repository, @sha, @ref = repository, sha, ref
+
+ # Load tree from repository
+ @commit = @repository.commit(sha)
+ @raw_tree = @repository.tree(@commit, path)
+ end
+
+ def empty?
+ data.blank?
+ end
+
+ def data
+ raw_tree.data
+ end
+
+ def is_blob?
+ tree.is_a?(Grit::Blob)
+ end
+
+ def up_dir?
+ path.present?
+ end
+
+ def readme
+ @readme ||= contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }
+ end
+ end
+ end
+end
+