Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 76d23d5

Browse files
committedJun 9, 2017
Add Repository::log_at method
Convenient shortcut for browsing commit log
1 parent 4d8ae7f commit 76d23d5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎lib/rugged/repository.rb

+18
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,24 @@ def blob_at(revision, path)
207207
(blob.type == :blob) ? blob : nil
208208
end
209209

210+
# Get log at path for specified object
211+
#
212+
# obj - Object in question
213+
# path - The String file path.
214+
#
215+
# Returns an Array of Rugged::Commit objects
216+
def log_at(obj, path)
217+
walker = Rugged::Walker.new(self)
218+
walker.sorting(Rugged::SORT_DATE)
219+
walker.push(obj)
220+
en = Enumerator.new do |y|
221+
walker.each do |commit|
222+
y << commit if commit.diff(paths: [path]).size > 0
223+
end
224+
end
225+
return en
226+
end
227+
210228
def fetch(remote_or_url, *args)
211229
unless remote_or_url.kind_of? Remote
212230
remote_or_url = remotes[remote_or_url] || remotes.create_anonymous(remote_or_url)

0 commit comments

Comments
 (0)
Please sign in to comment.