Class: Pronto::Git::Line
- Inherits:
-
Struct
- Object
- Struct
- Pronto::Git::Line
- Extended by:
- Forwardable
- Defined in:
- lib/pronto/git/line.rb
Constant Summary collapse
- COMPARISON_ATTRIBUTES =
%i[content line_origin old_lineno new_lineno].freeze
Instance Attribute Summary collapse
-
#hunk ⇒ Object
Returns the value of attribute hunk.
-
#line ⇒ Object
Returns the value of attribute line.
-
#patch ⇒ Object
Returns the value of attribute patch.
Instance Method Summary collapse
Instance Attribute Details
#hunk ⇒ Object
Returns the value of attribute hunk
3 4 5 |
# File 'lib/pronto/git/line.rb', line 3 def hunk @hunk end |
#line ⇒ Object
Returns the value of attribute line
3 4 5 |
# File 'lib/pronto/git/line.rb', line 3 def line @line end |
#patch ⇒ Object
Returns the value of attribute patch
3 4 5 |
# File 'lib/pronto/git/line.rb', line 3 def patch @patch end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/pronto/git/line.rb', line 33 def ==(other) return false if other.nil? return true if line.nil? && other.line.nil? COMPARISON_ATTRIBUTES.all? do |attribute| send(attribute) == other.send(attribute) end end |
#commit_line ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/pronto/git/line.rb', line 23 def commit_line @commit_line ||= begin patches = patch.repo.show_commit(commit_sha) result = patches.find_line(patch.new_file_full_path, blame[:orig_start_line_number]) result || self # no commit_line means that it was just added end end |
#commit_sha ⇒ Object
19 20 21 |
# File 'lib/pronto/git/line.rb', line 19 def commit_sha blame[:final_commit_id] if blame end |
#position ⇒ Object
12 13 14 15 16 17 |
# File 'lib/pronto/git/line.rb', line 12 def position hunk_index = patch.hunks.find_index { |h| h.header == hunk.header } line_index = patch.lines.find_index(line) line_index + hunk_index + 1 end |