Sha256: 4eab88aa1283a96a5fe7d7b9f485a4d77778c0d50549b443a7aabed3f11c0955
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
module Dandelion class Tree attr_reader :commit def initialize(repo, commit) @repo = repo @commit = commit end def data(path) submodule = @repo.submodules[path] if submodule # TODO nil else info, obj = object(path) content(info, obj) end end private def object(path) object = @commit.tree info = {} path.split('/').each do |name| info = object[name] return nil unless info return nil unless info[:type] object = @repo.lookup(info[:oid]) return nil unless object end [info, object] end def content(info, object) # https://github.com/libgit2/libgit2/blob/development/include/git2/types.h if info[:filemode] == 0120000 symlink_content(object) else blob_content(object) end end def blob_content(object) object.read_raw.data end def symlink_content(object) path = object.read_raw.data result = data(path) result ||= IO.binread(path) # external link result end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dandelion-0.4.17 | lib/dandelion/tree.rb |
dandelion-0.4.16 | lib/dandelion/tree.rb |
dandelion-0.4.15 | lib/dandelion/tree.rb |
dandelion-0.4.14 | lib/dandelion/tree.rb |