Class: Mutant::Repository::Diff Private

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/mutant/repository.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Diff between two objects in repository

Constant Summary collapse

HEAD =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'HEAD'.freeze

Instance Method Summary collapse

Instance Method Details

#touches?(path, line_range) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if diff changes file at line range

Parameters:

  • path (Pathname)
  • line_range (Range<Fixnum>)

Returns:

  • (Boolean)

Raises:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mutant/repository.rb', line 36

def touches?(path, line_range)
  return false unless within_working_directory?(path) && tracks?(path)

  command = %W[
    git log
    #{from}...#{to}
    -L #{line_range.begin},#{line_range.end}:#{path}
  ]

  stdout, status = config.open3.capture2(*command, binmode: true)

  fail RepositoryError, "Command #{command} failed!" unless status.success?

  !stdout.empty?
end