Class: CleoQualityReview::ChangesDiff

Inherits:
Object
  • Object
show all
Defined in:
lib/cleo_quality_review/changes_diff.rb

Overview

Captures the git diff used for a quality review run

Instance Method Summary collapse

Constructor Details

#initialize(target_files:, command_runner:) ⇒ ChangesDiff

Returns a new instance of ChangesDiff.

Parameters:

  • target_files (Array<String>)

    files included in the review

  • command_runner (CommandRunner)

    for executing git commands



14
15
16
17
# File 'lib/cleo_quality_review/changes_diff.rb', line 14

def initialize(target_files:, command_runner:)
  @target_files = target_files
  @command_runner = command_runner
end

Instance Method Details

#review_idString

Returns deterministic review identifier for this diff.

Returns:

  • (String)

    deterministic review identifier for this diff



27
28
29
# File 'lib/cleo_quality_review/changes_diff.rb', line 27

def review_id
  Digest::SHA256.hexdigest(to_s)
end

#to_sString

Returns combined tracked and untracked diff content.

Returns:

  • (String)

    combined tracked and untracked diff content



21
22
23
# File 'lib/cleo_quality_review/changes_diff.rb', line 21

def to_s
  @to_s ||= [tracked_changes_diff, untracked_changes_diff].reject(&:empty?).join("\n")
end