Sha256: 2e9d176b4d3076ef1dba786478a7f481aab3276cf58a65f5d567b422f3ae7826
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module Gitlab module Git class Tree attr_accessor :id, :name, :path, :type, :mode, :commit_id class << self def where(repository, sha, path = '/') commit = Commit.find(repository, sha) grit_tree = commit.tree / path 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, ) end else [] end end end def initialize(options) %w(id name path type mode commit_id).each do |key| self.send("#{key}=", options[key.to_sym]) end end def dir? type == :tree end def file? type == :blob end def submodule? type == :submodule end def readme? name =~ /^readme/i end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gitlab_git-3.0.0.beta1 | lib/gitlab_git/tree.rb |