Closed alandonham closed 2 months ago
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
What type of PR is this? Bug fix
What package or component does this PR mostly affect? cmd/gazelle
What does this PR do? Why is it needed? This PR adds a workaround to strip trailing newlines from the resulting diff when running Gazelle in
mode=diff
. This aligns with the expected behavior of modern diff tools, which will ignore the last newline in a file. This is implemented to resolve an issue where modifying the end of a file caused Gazelle to output a diff that was invalid, due to the newlines. Applying patches generated in this case could not be applied when usinggit apply
and would apply, but with a warning identifying this issues when using the systempatch
utility.Which issues(s) does this PR fix?
Fixes #1916
Other notes for review How to Reproduce: Edit a
BUILD.bazel
file in this repository, and then runbazel run //:gazelle -- -mode=diff -patch=temp.patch
. Next, rungit apply -p0 temp.patch
. Without these changes, patch application will fail, due to the issue described above.