class SimpleGit::Revwalk

Attributes

ptr[RW]

Public Class Methods

new(repo) click to toggle source
# File lib/simple_git/revwalk.rb, line 7
def initialize(repo)
  wrapper = RevwalkWrapper.new
  ret = Git2.git_revwalk_new(wrapper, repo.ptr)
  if ret != 0
    error = Git2::GitError.new(Git2.giterr_last)
    raise ArgumentError, error[:message].read_string
  end

  @repo = repo
  @ptr = wrapper[:revwalk]

  ObjectSpace.define_finalizer(self, self.class.finalize(@ptr))
end

Private Class Methods

finalize(ptr) click to toggle source
# File lib/simple_git/revwalk.rb, line 39
def self.finalize(ptr)
  proc { Git2.git_revwalk_free(ptr) }
end

Public Instance Methods

each() { |commit| ... } click to toggle source
# File lib/simple_git/revwalk.rb, line 29
def each
  oid = Oid.new

  while Git2.git_revwalk_next(oid.ptr, @ptr) == 0
    yield Commit.new(@repo, oid)
  end
end
push_head() click to toggle source
# File lib/simple_git/revwalk.rb, line 25
def push_head
  Git2.git_revwalk_push_head(@ptr)
end
sort(sort_type) click to toggle source
# File lib/simple_git/revwalk.rb, line 21
def sort(sort_type)
  Git2.git_revwalk_sorting(@ptr, sort_type)
end