Sha256: b6b877644ce5e9d04d3b402a2b335acb74aab9e54a86978214b887de41fd63f4

Contents?: true

Size: 1.52 KB

Versions: 30

Compression:

Stored size: 1.52 KB

Contents

# Copyright (C) the Rugged contributors.  All rights reserved.
#
# This file is part of Rugged, distributed under the MIT license.
# For full terms see the included LICENSE file.

module Rugged
  class Commit

    def self.prettify_message(msg, strip_comments = true)
      Rugged::prettify_message(msg, strip_comments)
    end

    def inspect
      "#<Rugged::Commit:#{object_id} {message: #{message.inspect}, tree: #{tree.inspect}, parents: #{parent_oids}}>"
    end

    def header_field?(field)
      !!header_field(field)
    end

    # Return a diff between this commit and its first parent or another commit or tree.
    #
    # See Rugged::Tree#diff for more details.
    def diff(*args)
      args.unshift(parents.first) if args.size == 1 && args.first.is_a?(Hash)
      self.tree.diff(*args)
    end

    # Return a diff between this commit and the workdir.
    #
    # See Rugged::Tree#diff_workdir for more details.
    def diff_workdir(options = {})
      self.tree.diff_workdir(options)
    end

    # The time when this commit was made effective. This is the same value
    # as the +:time+ attribute for +commit.committer+.
    #
    # Returns a Time object
    def time
      @time ||= Time.at(self.epoch_time)
    end

    def to_hash
      {
        :message => message,
        :committer => committer,
        :author => author,
        :tree => tree,
        :parents => parents,
      }
    end

    def modify(new_args, update_ref=nil)
      args = self.to_hash.merge(new_args)
      Commit.create(args, update_ref)
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rugged-0.28.5 lib/rugged/commit.rb
rugged-1.0.0 lib/rugged/commit.rb
rugged-0.99.0 lib/rugged/commit.rb
rugged-0.27.10.1 lib/rugged/commit.rb
rugged-0.28.4.1 lib/rugged/commit.rb
rugged-0.28.4 lib/rugged/commit.rb
rugged-0.27.10 lib/rugged/commit.rb
rugged-0.28.3.1 lib/rugged/commit.rb
rugged-0.27.9 lib/rugged/commit.rb
rugged-0.28.2 lib/rugged/commit.rb
rugged-0.28.1 lib/rugged/commit.rb
rugged-0.28.0 lib/rugged/commit.rb
rugged-0.27.7 lib/rugged/commit.rb
rugged-0.27.5 lib/rugged/commit.rb
rugged-0.26.7 lib/rugged/commit.rb
rugged-0.26.6 lib/rugged/commit.rb
rugged-0.27.4 lib/rugged/commit.rb
rugged-0.27.2 lib/rugged/commit.rb
rugged-0.27.1 lib/rugged/commit.rb
rugged-0.27.0 lib/rugged/commit.rb