23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/file_helper.rb', line 23
def compare(commit, file_name, lines, context=nil, diff=nil)
if diff.nil?
Loggr.instance.info("COMPARE COMMIT: #{commit.id}")
else
Loggr.instance.info("COMPARE fdiff: #{fdiff_stat(diff)}")
end
real_file = `git show #{commit.id}:#{file_name}`
.encode("UTF-8", invalid: :replace)
.lines
.map(&:chomp)
return if real_file.length == 0
if real_file.length != lines.length && diff.nil?
puts "FILE SIZE MISMATCH:"
puts "REAL: #{real_file.length}"
puts "RECONSTRUCT: #{lines.length}"
byebug
1
end
lines
.each_with_index
.map do |line, line_number|
if real_file[line_number] != line.gsub(/\r$/, "")
puts "MISMATCH: #{commit.id}:#{file_name}"
puts "REAL:"
print_context(real_file, line_number)
puts "RECONSTRUCT"
print_context(lines, line_number)
byebug
1
end
end
end
|