Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 7, 2021

Conversation

mrnugget
Copy link
Contributor

@mrnugget mrnugget commented Jan 5, 2021

This is a bit of a follow-up to #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
Copy link

codecov bot commented Jan 5, 2021

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%) ⬇️

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.

Copy link

@chrispine chrispine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests seem to pass, so I trust the conditions from before mapped to the same behavior 🤷‍♂️

fd.NewName = "/dev/null"
}

return true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is finally readable, thanks so much!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be much better, but I had a lot of trouble introducing names for the reused-conditions (lineCount == 3) that wouldn't be confusing, so stopped. Maybe in the future we should revisit this.

@mrnugget
Copy link
Contributor Author

mrnugget commented Jan 7, 2021

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.

@mrnugget mrnugget merged commit 82e3467 into master Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants