feat: Parse Go-style diffs#640
Closed
thejcannon wants to merge 4 commits intojdx:mainfrom
Closed
Conversation
Contributor
Author
|
Hmm I might try and do this in the command itself |
jdx
pushed a commit
that referenced
this pull request
Feb 4, 2026
none of the `check*` methods are compatible with gofumpt `check_diff` should work once #640 is merged
Owner
|
Superseded by a new PR with main merged in. |
jdx
added a commit
that referenced
this pull request
Feb 25, 2026
## Summary - Go tools (like `gofmt -d`) output diffs with `.orig` suffix on `---` lines (e.g., `--- file.go.orig` instead of `--- file.go`) - Adds `strip_orig_suffix()` to handle this by stripping `.orig` from `---` lines when the corresponding `+++` line doesn't have it - Correctly preserves `.orig` when the file itself has a `.orig` extension Supersedes #640 (rebased onto current main). ## Test plan - [x] New bats test: `check_diff handles diffs with .orig suffix on --- line` - [x] New bats test: `check_diff works if the file has .orig suffix` - [x] All existing `apply_check_diff.bats` tests pass Co-authored-by: Joshua Cannon <josh.cannon@airbnb.com> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Scoped change to diff parsing/apply that normalizes `--- *.orig` headers; main risk is incorrectly rewriting paths in edge-case diffs, mitigated by added tests. > > **Overview** > Adds support for Go-style unified diffs (e.g., `gofmt -d`) where only the `---` header uses a `.orig` suffix by introducing `strip_orig_suffix()` and running it before both file extraction (`filter_files_from_check_diff`) and `git apply` (`apply_diff_output`). > > Extends `apply_check_diff.bats` with coverage for `.orig`-suffixed `---` lines and ensures files that actually end with `.orig` continue to work, plus small test cleanup/renames. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit f86f004. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Joshua Cannon <josh.cannon@airbnb.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Go family of tools seem to prefer putting a
.origsuffix on the---lines of diffs, so handle those.Note we should still handle if a file truly has a
.orig. suffix.