lib/gitlab_git/tree.rb in gitlab_git-3.0.0.pre vs lib/gitlab_git/tree.rb in gitlab_git-3.0.0.rc1
- old
+ new
@@ -1,35 +1,36 @@
module Gitlab
module Git
class Tree
- attr_accessor :id, :name, :path, :type, :mode, :commit_id
+ attr_accessor :id, :name, :path, :type, :mode, :commit_id, :submodule_url
class << self
def where(repository, sha, path = '/')
commit = Commit.find(repository, sha)
grit_tree = commit.tree / path
- if grit_tree
+ if grit_tree && grit_tree.respond_to?(:contents)
grit_tree.contents.map do |entry|
type = entry.class.to_s.split("::").last.downcase.to_sym
Tree.new(
id: entry.id,
name: entry.name,
type: type,
mode: entry.mode,
path: path == '/' ? entry.name : File.join(path, entry.name),
commit_id: sha,
+ submodule_url: (type == :submodule) ? entry.url(sha) : nil
)
end
else
[]
end
end
end
def initialize(options)
- %w(id name path type mode commit_id).each do |key|
+ %w(id name path type mode commit_id submodule_url).each do |key|
self.send("#{key}=", options[key.to_sym])
end
end
def dir?