Class: Gitlab::Diff::PositionTracer
- Inherits:
-
Object
- Object
- Gitlab::Diff::PositionTracer
- Defined in:
- lib/gitlab/diff/position_tracer.rb,
lib/gitlab/diff/position_tracer/base_strategy.rb,
lib/gitlab/diff/position_tracer/file_strategy.rb,
lib/gitlab/diff/position_tracer/line_strategy.rb,
lib/gitlab/diff/position_tracer/image_strategy.rb
Defined Under Namespace
Classes: BaseStrategy, FileStrategy, ImageStrategy, LineStrategy
Instance Attribute Summary collapse
-
#new_diff_refs ⇒ Object
Returns the value of attribute new_diff_refs.
-
#old_diff_refs ⇒ Object
Returns the value of attribute old_diff_refs.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
- #ac_diffs ⇒ Object
- #bd_diffs ⇒ Object
- #cd_diffs ⇒ Object
- #diff_file(position) ⇒ Object
-
#initialize(project:, old_diff_refs:, new_diff_refs:, paths: nil) ⇒ PositionTracer
constructor
A new instance of PositionTracer.
- #trace(old_position) ⇒ Object
Constructor Details
#initialize(project:, old_diff_refs:, new_diff_refs:, paths: nil) ⇒ PositionTracer
Returns a new instance of PositionTracer.
13 14 15 16 17 18 |
# File 'lib/gitlab/diff/position_tracer.rb', line 13 def initialize(project:, old_diff_refs:, new_diff_refs:, paths: nil) @project = project @old_diff_refs = old_diff_refs @new_diff_refs = new_diff_refs @paths = paths end |
Instance Attribute Details
#new_diff_refs ⇒ Object
Returns the value of attribute new_diff_refs.
10 11 12 |
# File 'lib/gitlab/diff/position_tracer.rb', line 10 def new_diff_refs @new_diff_refs end |
#old_diff_refs ⇒ Object
Returns the value of attribute old_diff_refs.
9 10 11 |
# File 'lib/gitlab/diff/position_tracer.rb', line 9 def old_diff_refs @old_diff_refs end |
#paths ⇒ Object
Returns the value of attribute paths.
11 12 13 |
# File 'lib/gitlab/diff/position_tracer.rb', line 11 def paths @paths end |
#project ⇒ Object
Returns the value of attribute project.
8 9 10 |
# File 'lib/gitlab/diff/position_tracer.rb', line 8 def project @project end |
Instance Method Details
#ac_diffs ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/gitlab/diff/position_tracer.rb', line 29 def ac_diffs @ac_diffs ||= compare( old_diff_refs.base_sha || old_diff_refs.start_sha, new_diff_refs.base_sha || new_diff_refs.start_sha, straight: true ) end |
#bd_diffs ⇒ Object
37 38 39 |
# File 'lib/gitlab/diff/position_tracer.rb', line 37 def bd_diffs @bd_diffs ||= compare(old_diff_refs.head_sha, new_diff_refs.head_sha, straight: true) end |
#cd_diffs ⇒ Object
41 42 43 |
# File 'lib/gitlab/diff/position_tracer.rb', line 41 def cd_diffs @cd_diffs ||= compare(new_diff_refs.start_sha, new_diff_refs.head_sha) end |
#diff_file(position) ⇒ Object
45 46 47 |
# File 'lib/gitlab/diff/position_tracer.rb', line 45 def diff_file(position) position.diff_file(project.repository) end |
#trace(old_position) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/gitlab/diff/position_tracer.rb', line 20 def trace(old_position) return unless old_diff_refs&.complete? && new_diff_refs&.complete? return unless old_position.diff_refs == old_diff_refs @ignore_whitespace_change = old_position.ignore_whitespace_change strategy(old_position).new(self).trace(old_position) end |