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 Oct 14, 2019
1 parent 3de6a0a commit 9d64ebf
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 @@ -250,6 +250,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 9d64ebf

Please sign in to comment.