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

helper methods to get actual Objects, not just information about them #799

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions lib/rugged/diff/delta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def typechange?
status == :typechange
end

def old_blob
owner.owner.lookup(old_file[:oid]) unless added?
end

def new_blob
owner.owner.lookup(new_file[:oid]) unless deleted?
end

def inspect
"#<#{self.class.name}:#{object_id} {old_file: #{old_file.inspect}, new_file: #{new_file.inspect}, similarity: #{similarity.inspect}, status: #{status.inspect}>"
end
Expand Down
5 changes: 5 additions & 0 deletions lib/rugged/tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def diff(other = nil, options = nil)
Tree.diff(repo, self, other, options)
end

def lookup(entry_id)
entry = get_entry(entry_id)
owner.lookup(entry[:oid]) if entry
end

def inspect
data = "#<Rugged::Tree:#{object_id} {oid: #{oid}}>\n"
self.each { |e| data << " <\"#{e[:name]}\" #{e[:oid]}>\n" }
Expand Down