Skip to content

Commit

Permalink
Add Repository::log_at method
Browse files Browse the repository at this point in the history
Convenient shortcut for browsing commit log
  • Loading branch information
Voker57 committed Jun 9, 2017
1 parent 4d8ae7f commit 76d23d5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/rugged/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,24 @@ def blob_at(revision, path)
(blob.type == :blob) ? blob : nil
end

# Get log at path for specified object
#
# obj - Object in question
# path - The String file path.
#
# Returns an Array of Rugged::Commit objects
def log_at(obj, path)
walker = Rugged::Walker.new(self)
walker.sorting(Rugged::SORT_DATE)
walker.push(obj)
en = Enumerator.new do |y|
walker.each do |commit|
y << commit if commit.diff(paths: [path]).size > 0
end
end
return en
end

def fetch(remote_or_url, *args)
unless remote_or_url.kind_of? Remote
remote_or_url = remotes[remote_or_url] || remotes.create_anonymous(remote_or_url)
Expand Down

0 comments on commit 76d23d5

Please sign in to comment.