Skip to content

Commit a08c9b8

Browse files
committed
helper methods to get actual Objects, not just information about them
avoids having to have the caller keep looking up objects directly from the repo
1 parent 33873e5 commit a08c9b8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/rugged/diff/delta.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ def typechange?
5050
status == :typechange
5151
end
5252

53+
def old_blob
54+
owner.lookup(old_file[:oid]) unless added?
55+
end
56+
57+
def new_blob
58+
owner.lookup(new_file[:oid]) unless deleted?
59+
end
60+
5361
def inspect
5462
"#<#{self.class.name}:#{object_id} {old_file: #{old_file.inspect}, new_file: #{new_file.inspect}, similarity: #{similarity.inspect}, status: #{status.inspect}>"
5563
end

lib/rugged/tree.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ def diff(other = nil, options = nil)
164164
Tree.diff(repo, self, other, options)
165165
end
166166

167+
def lookup(entry_id)
168+
entry = get_entry(entry_id)
169+
owner.lookup(entry[:oid]) if entry
170+
end
171+
167172
def inspect
168173
data = "#<Rugged::Tree:#{object_id} {oid: #{oid}}>\n"
169174
self.each { |e| data << " <\"#{e[:name]}\" #{e[:oid]}>\n" }

0 commit comments

Comments
 (0)