# File lib/gitlab_git/tree.rb, line 6 def initialize(repository, sha, ref = nil, path = nil) @repository, @sha, @ref, @path = repository, sha, ref, path @path = nil if !@path || @path == '' # Load tree from repository @commit = Gitlab::Git::Commit.find(@repository, @sha) @raw_tree = @repository.tree(@commit, @path) end
# File lib/gitlab_git/tree.rb, line 28 def blobs entries.select { |t| t.is_a?(Grit::Blob) } end
# File lib/gitlab_git/tree.rb, line 20 def empty? trees.empty? && blobs.empty? end
# File lib/gitlab_git/tree.rb, line 16 def exists? raw_tree end
# File lib/gitlab_git/tree.rb, line 36 def is_blob? raw_tree.is_a?(Grit::Blob) end
# File lib/gitlab_git/tree.rb, line 44 def readme @readme ||= blobs.find { |c| c.name =~ /^readme/ } end
# File lib/gitlab_git/tree.rb, line 32 def submodules entries.select { |t| t.is_a?(Grit::Submodule) } end
# File lib/gitlab_git/tree.rb, line 24 def trees entries.select { |t| t.is_a?(Grit::Tree) } end
# File lib/gitlab_git/tree.rb, line 40 def up_dir? path && path != '' end
# File lib/gitlab_git/tree.rb, line 50 def entries raw_tree.contents end