feat: allow changing or removing the git remote#149
Conversation
Adds Change/Remove controls next to the configured remote in Version Control settings, backed by new git_set_remote_url and git_remove_remote Tauri commands. Resolves #147 — users who added the wrong remote URL can now fix it without losing local history. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedThis PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds end-to-end Git remote management: backend helpers to set/remove the ChangesGit Remote Management
Sequence DiagramsequenceDiagram
participant User
participant UI as Settings UI
participant Context as Git Context
participant Service as Git Service
participant Tauri as Tauri Command
participant Git as Git Backend
User->>UI: Open edit / change remote
UI->>Context: setRemoteUrl(newUrl) or removeRemote()
Context->>Service: setRemoteUrl(newUrl) / removeRemote()
Service->>Tauri: invoke("git_set_remote_url",{url:newUrl}) / invoke("git_remove_remote")
Tauri->>Git: run `git remote set-url origin <newUrl>` / `git remote remove origin`
Git-->>Tauri: success or stderr (may contain "No such remote")
Tauri-->>Service: GitResult
Service-->>Context: GitResult
Context->>Context: refreshStatus() on success
Context-->>UI: updated status or error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src-tauri/src/git.rs`:
- Around line 470-476: The removal routine currently returns an error when
stderr contains "No such remote"; update the branch in git.rs that checks stderr
(the block creating GitResult with error Some("No 'origin' remote configured"))
to treat this case as a success (set success: true and error: None) so removing
an already-missing 'origin' is idempotent and the frontend can converge to "not
connected" (you can keep or set message to a neutral value like None or a short
informational string). Ensure this change is applied in the function handling
the remote removal output where output.stderr is parsed.
- Around line 407-419: Trim and normalize the incoming url once in
set_remote_url (e.g., let normalized = url.trim()) then use that normalized
value for both validation and the git command invocation; call
is_valid_remote_url(&normalized) instead of is_valid_remote_url(url) and pass
normalized to git_cmd().args([... , "origin", &normalized]) so whitespace-padded
URLs aren't written to git.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c9c5289c-5f49-4361-bb07-8af5890b0df4
📒 Files selected for processing (5)
src-tauri/src/git.rssrc-tauri/src/lib.rssrc/components/settings/GeneralSettingsSection.tsxsrc/context/GitContext.tsxsrc/services/git.ts
Replaces the changes/commits-to-push/commits-to-pull rows with a single "An error occurred" row when status.error is set, so we don't display counts that may be incorrect alongside the error message. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Use a plain text button for Change, matching the Install link in integrations, instead of a ghost-variant Button. - Hide stats whenever lastError is set (not just status.error), so action errors like a failed push also collapse the stale counts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The footer was rendering both 'Files changed' and 'An error occurred' side-by-side. Gate the changes indicator on !lastError so the count isn't shown alongside an error message. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…talize - remove_remote: treat 'No such remote' as success so removing an already-missing origin converges to 'not connected' on the frontend. - set_remote_url: trim+normalize the incoming URL once and use the normalized value for both validation and the git invocation, so whitespace-padded URLs aren't written to git config. - Settings error block: switch capitalize → first-letter:capitalize so only the first character is uppercased (preserves casing in URLs, hashes, branch names). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
git_set_remote_url(git remote set-url origin <url>) andgit_remove_remote(git remote remove origin) — both preserve local historyBehavior
Test plan
git remote -v)foo) surfaces the validation errororigin/<branch>)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
UI / Bug Fixes