Skip to content

feat: Parse Go-style diffs#640

Closed
thejcannon wants to merge 4 commits intojdx:mainfrom
thejcannon:jcannon/go-style-diff
Closed

feat: Parse Go-style diffs#640
thejcannon wants to merge 4 commits intojdx:mainfrom
thejcannon:jcannon/go-style-diff

Conversation

@thejcannon
Copy link
Copy Markdown
Contributor

The Go family of tools seem to prefer putting a .orig suffix on the --- lines of diffs, so handle those.

Note we should still handle if a file truly has a .orig. suffix.

@thejcannon
Copy link
Copy Markdown
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
@jdx
Copy link
Copy Markdown
Owner

jdx commented Feb 25, 2026

Superseded by a new PR with main merged in.

@jdx jdx closed this Feb 25, 2026
@jdx jdx mentioned this pull request Feb 25, 2026
3 tasks
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>
@thejcannon thejcannon deleted the jcannon/go-style-diff branch February 25, 2026 11:47
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.

2 participants