-
Notifications
You must be signed in to change notification settings - Fork 458
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
When ratcheting, check dirty files from Git first #706
When ratcheting, check dirty files from Git first #706
Conversation
Thanks, looks like a great PR. I agree the maven/gradle interface is tricky, #554 could improve that. I am swamped for the next several days, but I will come back and help make sure this gets merged sometime next week, unless someone else on the team beats me to it :) |
oldTree.reset(oldReader, sha); | ||
|
||
Git git = new Git(repository); | ||
List<DiffEntry> diffs = git.diff() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.setPathFilter
would speed this up a bunch for multimodule projects
Somewhere or other, we set a jgit version. The newest version of JGit includes support for a new index format which cgit has had for a while. So updating that might fix some things... |
Thanks for the comments! I'll have a look at both things when I have the time 🙂 |
Still trying to figure out why too many files are returned.. so far I've noticed that the I put wrong in quotation marks because I can get the same SHA by running Using |
For the files that disagree, does |
Yes, I've tried setting up JGit in another project too, and eventually ran into the same issues. The line endings are the same in both branches (using another branch for the But the The old code works correctly, but maybe that's because |
3cbeca0
to
567db30
Compare
DiffCommand suffered from not taking smudge/clean filters into account
567db30
to
1ae409e
Compare
So.. this was a good time for me to dive deeper into Git internals. It does indeed seem like it was a smudge/clean problem. Maybe it could've been done with the That was quite straight-forward, but then there were the special cases of e.g. a file that was modified in the index and in the working tree, but where the working tree matched the local repository. Luckily you had test cases for this (and a couple other ones), please take a look to see if you think they're handled appropriately. It's still a lot faster for me than before, with 1-10 modified files the Maven execution took 3.5-4.8 seconds, when previously it was around 15 seconds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, great PR. Thanks for digging in, sorry for slow feedback. I have just one teensy change I'd like to request. Once this last bit gets fixed, I'll merge and release.
plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java
Outdated
Show resolved
Hide resolved
lib-extra/src/main/java/com/diffplug/spotless/extra/GitRatchet.java
Outdated
Show resolved
Hide resolved
plugin-maven/src/main/java/com/diffplug/spotless/maven/AbstractSpotlessMojo.java
Show resolved
Hide resolved
515c16c
to
13c7b2b
Compare
Your comments all make sense, I've implemented the changes! |
Oops, I made a mistake. Easy for me to fix, just commenting here to document:
Super easy for me to fix, but I should not have merged this before asking for an entry in the root |
Sorry for that, glad you got a compile error! |
My fault, not yours :) Released in |
Regarding #701
Spent a lot of time getting the thing set up. IntelliJ refused to cooperate, Gradle isn't my strong suit, and debugging Maven when run through Gradle had its challenges too...
At first it wouldn't run the Maven plugin build at all, but I realized it was because I was using Java 11.
The
SpecificFilesTest
fail because I'm on Windows, they can probably be fixed by adding enoughpattern.replace("/", "\\\\\\\\")
statements.There is still an issue with this code that I haven't been able to figure out. The
diff
picks up a lot more files than I have actually changed (~400 instead of 3). I believe it's related to line ending normalization, if I rungit add --renormalize .
it changes a lot of files, probably the same files that thediff
picks up.But if I run
git diff
manually against the same merge base, or if I run the old plugin version, they don't have this problem.So that still needs to be fixed, if you have any idea do tell. Even so, it's about three times faster for me than before.