fd80132
fd80132

Reputation: 41

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.

Is it possible ?

Thanks !

Upvotes: 0

Views: 656

Answers (1)

fd80132
fd80132

Reputation: 41

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

Upvotes: 1

Related Questions