Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Repository::log_at method #699

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.oid)
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, **kwargs)
unless remote_or_url.kind_of? Remote
remote_or_url = remotes[remote_or_url] || remotes.create_anonymous(remote_or_url)
Expand Down