class Mutest::Repository::Diff
Diff
between two objects in repository
Constants
- HEAD
Public Instance Methods
touches?(path, line_range)
click to toggle source
Test
if diff changes file at line range
@param [Pathname] path @param [Range<Integer>] line_range
@return [Boolean]
@raise [RepositoryError]
when git command failed
# File lib/mutest/repository.rb, line 37 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) raise RepositoryError, "Command #{command} failed!" unless status.success? !stdout.empty? end
Private Instance Methods
tracks?(path)
click to toggle source
Test
if path is tracked in repository
FIXME: Cache results, to avoid spending time on producing redundant results.
@param [Pathname] path
@return [Boolean]
# File lib/mutest/repository.rb, line 62 def tracks?(path) command = %W[git ls-files --error-unmatch -- #{path}] config.kernel.system( *command, out: File::NULL, err: File::NULL ) end
within_working_directory?(path)
click to toggle source
Test
if the path is within the current working directory
@param [Pathname] path
@return [TrueClass, nil]
# File lib/mutest/repository.rb, line 76 def within_working_directory?(path) working_directory = config.pathname.pwd path.ascend { |parent| return true if working_directory.eql?(parent) } end