diff options
author | Austin Ziegler <austin@zieglers.ca> | 2019-02-02 22:52:28 -0500 |
---|---|---|
committer | Austin Ziegler <austin@zieglers.ca> | 2019-02-04 10:33:18 -0500 |
commit | 15169228be42559f98fa6729d5f6bb32edad44e3 (patch) | |
tree | 0fe1626255811fae6b3c85ce406f0dc02c4987a2 /lib/diff/lcs/ldiff.rb | |
parent | 3a89de07745fea52f611e6955f61c11ffd68c754 (diff) | |
download | diff-lcs-15169228be42559f98fa6729d5f6bb32edad44e3.tar.gz |
Resolve multiple issues for 1.4
- Resolve ldiff output issues: Resolves #5 and #6 by adding system-output
comparison calls to `bin/ldiff` compared against some pre-generated output.
There is some timestamp manipulation involved with the output comparison,
as the timestamps are unstable because of the way that git clone works.
- Resolved a problem with bin/ldiff --context output.
- Resolved a Numeric/Integer OptParse issue: later versions of Ruby had
problems working with an `OptParse` option specification of `Numeric`; this
has been changed to `Integer`.
Diffstat (limited to 'lib/diff/lcs/ldiff.rb')
-rw-r--r-- | lib/diff/lcs/ldiff.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/diff/lcs/ldiff.rb b/lib/diff/lcs/ldiff.rb index d385f72..2862267 100644 --- a/lib/diff/lcs/ldiff.rb +++ b/lib/diff/lcs/ldiff.rb @@ -30,14 +30,14 @@ class << Diff::LCS::Ldiff o.banner = "Usage: #{File.basename($0)} [options] oldfile newfile" o.separator '' o.on( - '-c', '-C', '--context [LINES]', Numeric, + '-c', '-C', '--context [LINES]', Integer, 'Displays a context diff with LINES lines', 'of context. Default 3 lines.' ) do |ctx| @format = :context @lines = ctx || 3 end o.on( - '-u', '-U', '--unified [LINES]', Numeric, + '-u', '-U', '--unified [LINES]', Integer, 'Displays a unified diff with LINES lines', 'of context. Default 3 lines.' ) do |ctx| @format = :unified @@ -134,9 +134,9 @@ class << Diff::LCS::Ldiff end if (@format == :unified) or (@format == :context) - ft = File.stat(file_old).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.%N %z') + ft = File.stat(file_old).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.000000000 %z') output << "#{char_old} #{file_old}\t#{ft}\n" - ft = File.stat(file_new).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.%N %z') + ft = File.stat(file_new).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.000000000 %z') output << "#{char_new} #{file_new}\t#{ft}\n" end @@ -155,7 +155,7 @@ class << Diff::LCS::Ldiff file_length_difference = hunk.file_length_difference next unless oldhunk - next if @lines.postive? and hunk.merge(oldhunk) + next if @lines.positive? and hunk.merge(oldhunk) output << oldhunk.diff(@format) << "\n" ensure @@ -163,7 +163,10 @@ class << Diff::LCS::Ldiff end end - output << oldhunk.diff(@format) << "\n" + last = oldhunk.diff(@format) + last << "\n" if last.respond_to?(:end_with?) && !last.end_with?("\n") + + output << last output.reverse_each { |e| real_output << e.diff(:ed_finish) } if @format == :ed |