Method: MetaCommit::Git::Repo#walk_by_commits

Defined in:
lib/meta_commit/git/repo.rb

#walk_by_commits {|previous_commit, current_commit| ... } ⇒ Object

Starts commit walker and yields following commits for easier iteration

Yields:

  • (previous_commit, current_commit)


35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/meta_commit/git/repo.rb', line 35

def walk_by_commits
  walker = Rugged::Walker.new(@repo)
  walker.sorting(Rugged::SORT_REVERSE)
  walker.push(@repo.last_commit.oid)
  previous_commit = nil
  walker.each do |current_commit|
    # skip first commit
    previous_commit = current_commit if previous_commit.nil?
    next if previous_commit == current_commit
    yield(previous_commit, current_commit)
    previous_commit = current_commit
  end
end