Sha256: 7584c731e395301eee8e9ac4f5f2a1d2b65f431b0df773f72a771bad858e3333
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
module Gitrb class Commit < Gitrb::Object attr_accessor :tree, :parent, :author, :committer, :message def initialize(options = {}) super(options) @parent = [options[:parent]].flatten.compact @tree = options[:tree] @author = options[:author] @committer = options[:committer] @message = options[:message] parse(options[:data]) if options[:data] end def type 'commit' end def date (committer && committer.date) || (author && author.date) end def ==(other) Commit === other and id == other.id end def save repository.put(self) id end def dump [ "tree #{tree.id}", @parent.map { |p| "parent #{p.id}" }, "author #{author.dump}", "committer #{committer.dump}", '', message ].flatten.join("\n") end def to_s id end private def parse(data) headers, @message = data.split("\n\n", 2) repository.encode(@message) headers.split("\n").each do |header| key, value = header.split(' ', 2) case key when 'parent' @parent << Reference.new(:repository => repository, :id => repository.encode(value)) when 'author' @author = User.parse(repository.encode(value)) when 'committer' @committer = User.parse(repository.encode(value)) when 'tree' @tree = Reference.new(:repository => repository, :id => repository.encode(value)) end end self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gitrb-0.0.5 | lib/gitrb/commit.rb |
gitrb-0.0.4 | lib/gitrb/commit.rb |