Created
          July 16, 2015 03:25 
        
      - 
      
- 
        Save ylt6/8d750addfdd76745f705 to your computer and use it in GitHub Desktop. 
    Find out the last commit for specific file using rugged
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def last_commit_for_path_within_head_repo(path) | |
| # equal to `git rev-list --max-count 1 HEAD #{path}` | |
| walker = Rugged::Walker.new(Rugged:Repository) | |
| walker.sorting(Rugged::SORT_DATE) | |
| walker.push(head_commit) | |
| walker.hide(base_commit) | |
| walker.each { |commit| | |
| return commit.oid if commit.diff(paths: [path]).size > 0 | |
| } | |
| base_commit | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment