admin管理员组

文章数量:1336568

I would like to use Rugged to get the commit history of a file, similar to what git log <filename> produces. But I can't seem to find a direct way to do this in the Rugged API. Perhaps I am overlooking it?

The best way I have found of doing it is by using a Rugged Walker:

walker = Rugged::Walker.new(repository)
walker.push(repository.head.target.oid)
history = []
walker.each do |commit|
  commit.diff.each_delta do |delta|
    history.push(some_commit_info) if delta.new_file[:path] == file_path
  end
end

Is there a more direct way of achieving this, rather than by taking this low level approach?

本文标签: rubyGet a file39s commit history with RuggedStack Overflow