feat(git): add hunk revert - #31
Conversation
- Add IPC and Git service support for reversing unstaged hunks - Add confirmation UI and coverage for preserving staged and other changes
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e43561b1e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return this.runGitOperation(request.repoPath, [ | ||
| "apply", | ||
| "--reverse", | ||
| "--whitespace=nowarn", | ||
| "-" |
There was a problem hiding this comment.
Preserve file-mode edits when discarding a content hunk
When a file has both an unstaged mode change (such as chmod +x) and content edits, the selected hunk patch still contains the file-level old mode/new mode headers collected by groupDiffRowsByHunk. Passing that patch directly to git apply --reverse therefore reverts the executable-bit change along with the selected content hunk, silently discarding an unrelated working-tree edit. Remove file-mode metadata from the patch used for this operation so that only the chosen hunk is reversed.
Useful? React with 👍 / 👎.
- Update hunk action labels, progress text, dialogs, and errors - Adjust history tests for the revised terminology
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d36f3b8d8f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| disabled: disabled || diffChanged, | ||
| onApply: onApplyHunk | ||
| onApply: onApplyHunk, | ||
| onDiscard: selectedSide === "unstaged" ? (patch) => onApplyHunk(patch, true) : undefined |
There was a problem hiding this comment.
Avoid offering hunk reversion for submodule gitlinks
When an initialized submodule is checked out at a different commit, its unstaged diff is a text hunk and this unconditionally exposes Revert Hunk. I checked git apply -h (--reverse: “apply the patch in reverse”) and reproduced the resulting 160000 gitlink patch behavior: git apply --reverse exits 0 with an unable to rmdir warning while leaving the submodule HEAD unchanged, so discardHunk reports success and the same change reappears after refresh. Gate this action when selectedFile?.submodule is present, or implement submodule checkout semantics instead of applying the gitlink patch.
Useful? React with 👍 / 👎.
Summary
Testing