sourcegraph / go-diff

Unified diff parser and printer for Go
https://sourcegraph.com/github.com/sourcegraph/go-diff
Other
425 stars 47 forks source link

Add handling added/deleted files in diff #50

Closed sofiia-tesliuk closed 4 years ago

sofiia-tesliuk commented 4 years ago

Related issue: https://github.com/sourcegraph/go-diff/issues/49 closes #49

There are some changes from planned implementation:

Then for this file example, the output below for ReadAllFiles() would be expected. my_diff.txt

diff -u source_a/file_1.txt  source_b/file_1.txt
--- source_a/file_1.txt   2020-07-28 12:54:18.000000000 +0000
+++ source_b/file_1.txt  2020-07-28 12:54:18.000000000 +0000
@@ -2,3 +3,4 @@
 To be, or not to be, that is the question:
-Whether 'tis nobler in the mind to suffer
+The slings and arrows of outrageous fortune,
+Or to take arms against a sea of troubles
 And by opposing end them. To die—to sleep,
Only in source_a: file_2.txt
Only in source_b: file_3.txt
ReadAllFiles(myMultiFileDiffReader) -> {
    FileDiff{
        OrigName: “source_a/file_1.txt”, 
        OrigTime: ..., 
        NewName: “source_b/file_1.txt”, 
        NewTime: …,
        Entended: ..., 
        Hunks: …
    },

    FileDiff{
        OrigName: “source_a/file_2.txt”, 
        OrigTime: nil, 
        NewName: "", 
        NewTime: nil
        …
    }, 

    FileDiff{
        OrigName: “source_b/file_3.txt”, 
        OrigTime: nil, 
        NewName: "", 
        …
    }

}, nil
codecov[bot] commented 4 years ago

Codecov Report

Merging #50 into master will increase coverage by 1.17%. The diff coverage is 90.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   28.31%   29.48%   +1.17%     
==========================================
  Files           5        5              
  Lines        1155     1177      +22     
==========================================
+ Hits          327      347      +20     
- Misses        783      784       +1     
- Partials       45       46       +1     
Impacted Files Coverage Δ
diff/diff.go 86.48% <ø> (ø)
diff/print.go 45.67% <60.00%> (+0.94%) :arrow_up:
diff/parse.go 82.04% <100.00%> (+0.99%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f935979...29fa046. Read the comment docs.

keegancsmith commented 4 years ago

BTW thank you so much for the great pull request!