Conversation
Summary of ChangesHello @jdx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the diff parsing capabilities to correctly interpret and apply diffs generated by Go tools like Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for Go-style diffs by stripping the .orig suffix from --- lines. The implementation is sound, but I've identified a potential issue with the use of replace, which could cause problems with filenames containing .orig not as a suffix. I've suggested a more robust alternative using rsplit_once. The addition of new tests to cover this functionality, including edge cases, is excellent. The refactoring in the test suite to remove unnecessary git commands also improves test simplicity and speed.
| if line.starts_with("--- ") && line.contains(".orig") { | ||
| if let Some(next) = lines.peek() { | ||
| if next.starts_with("+++ ") && !next.contains(".orig") { | ||
| result.push(line.replace(".orig", "")); |
There was a problem hiding this comment.
Using replace is too broad and could lead to incorrect behavior if a file or directory name contains .orig as part of its name, not as a suffix. For example, a path a/my.orig.file.go.orig would become a/my.file.go, which is incorrect. Using rsplit_once to split on the last occurrence of .orig is more robust and correctly handles this case, as well as filenames with timestamps.
if let Some((before, after)) = line.rsplit_once(".orig") {
result.push(format!("{}{}", before, after));
} else {
// This branch is technically unreachable due to the `line.contains(".orig")` check,
// but is kept for robustness.
result.push(line.to_string());
}
Greptile SummaryThis PR adds support for parsing Go-style diffs where tools like Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Last reviewed commit: 08a2df8 |
| if line.starts_with("--- ") && line.contains(".orig") { | ||
| if let Some(next) = lines.peek() { | ||
| if next.starts_with("+++ ") && !next.contains(".orig") { | ||
| result.push(line.replace(".orig", "")); |
There was a problem hiding this comment.
replace replaces all occurrences of .orig, which will incorrectly strip .orig from directory names or multiple occurrences. For --- path.orig/file.go.orig, this produces --- path/file.go instead of --- path.orig/file.go
| result.push(line.replace(".orig", "")); | |
| result.push(line.strip_suffix(".orig").unwrap_or(line).to_string()); |
Additional Comments (1)
|
Address review feedback: - Use strip_suffix instead of replace to only remove trailing .orig, avoiding incorrect stripping from directory names or multiple occurrences - Handle tab-separated timestamps in --- lines - Fix prefix detection in diff.rs to use stripped diff_content instead of original stdout Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryAdds support for parsing Go-style unified diffs where tools like
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: d0b591c |
Use strip_prefix and collapse nested if statements per clippy's manual_strip and collapsible_if lints. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryAdds support for Go-style unified diffs where Key Changes:
Minor Issue:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[check_diff command output] --> B{Contains .orig suffix?}
B -->|Yes| C[strip_orig_suffix]
B -->|No| D[Use as-is]
C --> E[Normalized diff]
D --> E
E --> F[filter_files_from_check_diff]
E --> G[apply_diff_output]
F --> H[Extract file paths]
G --> I{Has a/b prefixes?}
I -->|Yes| J[git apply -p1]
I -->|No| K[git apply -p0]
J --> L{Success?}
K --> L
L -->|Yes| M[Changes applied]
L -->|No| N[Fall back to fixer]
C1[--- file.go.orig] --> C2{+++ has .orig?}
C2 -->|No| C3[Strip .orig from ---]
C2 -->|Yes| C4[Keep as-is]
C3 --> C5[--- file.go]
style C fill:#e1f5ff
style C1 fill:#fff4e1
style C5 fill:#e8f5e9
Last reviewed commit: f86f004 |
| } | ||
| result.push(line.to_string()); | ||
| } | ||
| result.join("\n") + "\n" |
There was a problem hiding this comment.
unconditionally adds trailing newline even if input lacks one; git apply is typically tolerant, but consider preserving exact input structure
| result.join("\n") + "\n" | |
| if diff.ends_with('\n') { | |
| result.join("\n") + "\n" | |
| } else { | |
| result.join("\n") | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [hk](https://github.com/jdx/hk) | minor | `1.36.0` → `1.38.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jdx/hk (hk)</summary> ### [`v1.38.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1380---2026-03-06) [Compare Source](jdx/hk@v1.37.0...v1.38.0) ##### 🚀 Features - **(hook)** add `fail_on_fix` option by [@​jdx](https://github.com/jdx) in [#​725](jdx/hk#725) ##### 🐛 Bug Fixes - **(builtins)** remove redundant check/check\_diff from builtins by [@​nkakouros](https://github.com/nkakouros) in [#​726](jdx/hk#726) ##### 📦️ Dependency Updates - update anthropics/claude-code-action digest to [`26ec041`](jdx/hk@26ec041) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​720](jdx/hk#720) - update jdx/mise-action digest to [`e79ddf6`](jdx/hk@e79ddf6) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​721](jdx/hk#721) - update actions-rust-lang/setup-rust-toolchain digest to [`a0b538f`](jdx/hk@a0b538f) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​719](jdx/hk#719) - update rust crate tokio to v1.50.0 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​722](jdx/hk#722) ### [`v1.37.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1370---2026-03-03) [Compare Source](jdx/hk@v1.36.0...v1.37.0) ##### 🚀 Features - **(hook)** add env support to hooks by [@​jdx](https://github.com/jdx) in [#​709](jdx/hk#709) - parse Go-style diffs by [@​jdx](https://github.com/jdx) in [#​704](jdx/hk#704) ##### 🐛 Bug Fixes - **(builtins)** strip extra trailing newlines in end-of-file-fixer by [@​jdx](https://github.com/jdx) in [#​708](jdx/hk#708) - **(docs)** correctly document what --all is about by [@​nkakouros](https://github.com/nkakouros) in [#​715](jdx/hk#715) - **(git)** exclude untracked files from unstaged\_files set by [@​nkakouros](https://github.com/nkakouros) in [#​716](jdx/hk#716) - **(hkrc)** config format and load order by [@​ivy](https://github.com/ivy) in [#​710](jdx/hk#710) - **(release)** write release notes to file instead of capturing stdout by [@​jdx](https://github.com/jdx) in [#​688](jdx/hk#688) - **(release)** make release notes editorialization non-blocking by [@​jdx](https://github.com/jdx) in [#​690](jdx/hk#690) - **(step)** gate check\_diff forced check\_first on Fix mode only by [@​nkakouros](https://github.com/nkakouros) in [#​717](jdx/hk#717) ##### 📚 Documentation - **(shanty)** add audio player with sea shanty recording by [@​jdx](https://github.com/jdx) in [67a25ad](jdx/hk@67a25ad) - document config file search paths by [@​ivy](https://github.com/ivy) in [#​701](jdx/hk#701) - require AI disclosure on GitHub comments by [@​jdx](https://github.com/jdx) in [#​703](jdx/hk#703) ##### 🔍 Other Changes - replace gen-release-notes script with communique by [@​jdx](https://github.com/jdx) in [#​700](jdx/hk#700) - add autofix.ci workflow by [@​jdx](https://github.com/jdx) in [#​705](jdx/hk#705) ##### 📦️ Dependency Updates - lock file maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​686](jdx/hk#686) - update taiki-e/upload-rust-binary-action digest to [`f391289`](jdx/hk@f391289) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​692](jdx/hk#692) - update anthropics/claude-code-action digest to [`c22f7c3`](jdx/hk@c22f7c3) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​691](jdx/hk#691) - update rust crate libc to v0.2.181 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​694](jdx/hk#694) - update rust crate clap to v4.5.58 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​693](jdx/hk#693) - lock file maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​695](jdx/hk#695) - update anthropics/claude-code-action digest to [`edd85d6`](jdx/hk@edd85d6) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​698](jdx/hk#698) - update rust crate clap to v4.5.60 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​699](jdx/hk#699) - lock file maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​702](jdx/hk#702) - lock file maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​711](jdx/hk#711) ##### New Contributors - [@​ivy](https://github.com/ivy) made their first contribution in [#​710](jdx/hk#710) - [@​nkakouros](https://github.com/nkakouros) made their first contribution in [#​715](jdx/hk#715) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My40OS4wIiwidXBkYXRlZEluVmVyIjoiNDMuNTcuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
Summary
gofmt -d) output diffs with.origsuffix on---lines (e.g.,--- file.go.originstead of--- file.go)strip_orig_suffix()to handle this by stripping.origfrom---lines when the corresponding+++line doesn't have it.origwhen the file itself has a.origextensionSupersedes #640 (rebased onto current main).
Test plan
check_diff handles diffs with .orig suffix on --- linecheck_diff works if the file has .orig suffixapply_check_diff.batstests passCo-authored-by: Joshua Cannon josh.cannon@airbnb.com
Note
Low Risk
Scoped change to diff parsing/apply that normalizes
--- *.origheaders; 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.origsuffix by introducingstrip_orig_suffix()and running it before both file extraction (filter_files_from_check_diff) andgit apply(apply_diff_output).Extends
apply_check_diff.batswith coverage for.orig-suffixed---lines and ensures files that actually end with.origcontinue to work, plus small test cleanup/renames.Written by Cursor Bugbot for commit f86f004. This will update automatically on new commits. Configure here.