最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ruby - Get a file's commit history with Rugged - Stack Overflow

programmeradmin1浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论