Sha256: a8551b2387d775095ee57a4b21827b736c0085d6d97f1853d149818a9c3dea59
Contents?: true
Size: 948 Bytes
Versions: 4
Compression:
Stored size: 948 Bytes
Contents
module Dandelion class Tree attr_reader :commit def initialize(repo, commit) @repo = repo @commit = commit end def data(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 content(info, object) end private 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.10 | lib/dandelion/tree.rb |
dandelion-0.4.9 | lib/dandelion/tree.rb |
dandelion-0.4.8 | lib/dandelion/tree.rb |
dandelion-0.4.7 | lib/dandelion/tree.rb |