Class: Rugged::Diff::Line
- Inherits:
-
Object
- Object
- Rugged::Diff::Line
- Defined in:
- lib/pronto/rugged/diff/line.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #commit ⇒ Object
- #commit_line ⇒ Object
- #commit_sha ⇒ Object
- #patch ⇒ Object
- #position ⇒ Object
Instance Method Details
#==(other) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/pronto/rugged/diff/line.rb', line 42 def ==(other) content == other.content && line_origin == other.line_origin && old_lineno == other.old_lineno && new_lineno == other.new_lineno end |
#commit ⇒ Object
15 16 17 18 19 |
# File 'lib/pronto/rugged/diff/line.rb', line 15 def commit @commit ||= begin repo.lookup(commit_sha) if commit_sha end end |
#commit_line ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pronto/rugged/diff/line.rb', line 27 def commit_line @commit_line ||= begin diff = commit.show patches = diff ? diff.patches : [] commit_patch = patches.find do |p| patch.new_file_full_path == p.new_file_full_path end lines = commit_patch ? commit_patch.lines : [] result = lines.find { |l| blameline.lineno == l.new_lineno } result || self # no commit_line means that it was just added end end |
#commit_sha ⇒ Object
21 22 23 24 25 |
# File 'lib/pronto/rugged/diff/line.rb', line 21 def commit_sha @commit_sha ||= begin blameline.commit.id if blameline end end |
#patch ⇒ Object
4 5 6 |
# File 'lib/pronto/rugged/diff/line.rb', line 4 def patch hunk.owner end |
#position ⇒ Object
8 9 10 11 12 13 |
# File 'lib/pronto/rugged/diff/line.rb', line 8 def position hunk_index = patch.hunks.find_index { |h| h.header == hunk.header } line_index = patch.lines.find_index(self) line_index + hunk_index + 1 end |