'Obtain all commits in all branches Using Ruby Rugged

Using the Rugged gem, I want to obtain all commits in all branches, similar to this git command line:

$ git log --all

Walker requires a branch, so the following only works for the specified branch:

repo = Rugged::Repository.new(working_dir)
walker = Rugged::Walker.new(repo)
walker.sorting(Rugged::SORT_DATE)
walker.push(repo.branches['master'].target_id)
walker.each do |commit|
  # do stuff
end

walker.push seems to be a requirement for walker to return a value, but I do not want to filter out any branches.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source