12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/astel/unified_diff.rb', line 12
def unified(before, after, path:, context: 3)
validate_options(path, context)
return '' if before == after
operations = operations(before.lines(chomp: false), after.lines(chomp: false))
annotated = annotate(operations)
hunks = hunk_ranges(annotated, context)
output = String.new(encoding: Encoding::BINARY)
output << '--- a/'.b << path.to_s.b << "\n+++ b/".b << path.to_s.b << "\n".b
hunks.each { |range| append_hunk(output, annotated[range]) }
output
end
|