0

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 !

fd80132
  • 41
  • 2
  • 6
  • git log will show you the commits for a specific path, you could use this. – cbz Apr 29 '15 at 09:59
  • But your solution is for git, not rugged – fd80132 Apr 29 '15 at 10:20
  • In that case look at the answers to this earlier question: http://stackoverflow.com/questions/21302073/access-git-log-data-using-ruby-rugged-gem – cbz Apr 29 '15 at 10:32

1 Answers1

1

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
fd80132
  • 41
  • 2
  • 6
  • Bear in mind that this way will step through all commits in the entire repository and then filter on file path - so it will scale linearly to how many commits there are in your repo. – cbz Apr 29 '15 at 12:08
  • Yes, I know, but unfortunatly it's the only solution I found. – fd80132 Apr 30 '15 at 11:31