From d1ed0f995e1d7bea13e7aa20cc9eb764f18641fd Mon Sep 17 00:00:00 2001 From: Iaroslav Gridin Date: Fri, 9 Jun 2017 21:57:45 +0300 Subject: [PATCH] Add Repository::log_at method Convenient shortcut for browsing commit log --- lib/rugged/repository.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/rugged/repository.rb b/lib/rugged/repository.rb index abc51c51b..10b95aa31 100644 --- a/lib/rugged/repository.rb +++ b/lib/rugged/repository.rb @@ -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)