sourcegraph / go-diff

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

Handle rename-and-mode-change in empty file diffs & clean up code #58

Closed mrnugget closed 3 years ago

mrnugget commented 3 years ago

This is a bit of a follow-up to https://github.com/sourcegraph/go-diff/pull/57 in that it adds another test for file mode changes, in which a file's mode has changed and it has been renamed. I also duplicated the test added in #57 for single file diffs, so these tests are next to each other.

Besides that I used t.Run in the the two test functions I was working with to make it easier to see which test is failing and I tried to clean up the parsing code as best as I could. Tests helped a lot here.

codecov[bot] commented 3 years ago

Codecov Report

Merging #58 (3a166d4) into master (d1e74e0) will decrease coverage by 1.29%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
- Coverage   75.11%   73.82%   -1.30%     
==========================================
  Files           4        4              
  Lines         446      424      -22     
==========================================
- Hits          335      313      -22     
  Misses         63       63              
  Partials       48       48              
Impacted Files Coverage Δ
diff/parse.go 80.41% <100.00%> (-1.38%) :arrow_down:

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 d1e74e0...3a166d4. Read the comment docs.

mrnugget commented 3 years ago

so I trust the conditions from before mapped to the same behavior 🤷‍♂️

Yeah. The tests cover this pretty well, I think. And I added a test for a missing case. So I'm confident that nothing broke.