简体   繁体   English

坚固地获取文件/路径的所有提交

[英]get all commit of a file/path with rugged

I would like to get the list of all the commits for a file/path but I don't know how to do it. 我想获取文件/路径的所有提交的列表,但我不知道该怎么做。

For example I want all the commit of the file "test", to get oid of each commit and thanks to this oid, I will get the blob of all revision for this file. 例如,我想要文件“ test”的所有提交,以获取每个提交的oid,并且由于有了这个oid,我将获得此文件的所有修订版的Blob。

Is it possible ? 可能吗 ?

Thanks ! 谢谢 !

We can get all commits by this way : 我们可以通过这种方式获取所有提交:

      tab = []
      walker = Rugged::Walker.new(repo)
      walker.sorting(Rugged::SORT_DATE)
      walker.push(repo.head.target)
      walker.each do |commit|
        if commit.diff(paths: ["path_of_file"]).size > 0
           tab.push(commit)
        end
      end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM