Conversation
📝 WalkthroughWalkthroughAdded upstream-aware push/retry helpers and expanded upstream-missing error detection; updated fetch/push/sync/createPR flows to retry with --set-upstream when appropriate. Also added one upstream-deleted test string and small non-functional comment/payload adjustments in renderer/hooks. Changes
Sequence DiagramsequenceDiagram
participant App as Desktop App
participant GitOps as Git Operations
participant Remote as Origin/Remote
participant Handler as Error Handler
App->>GitOps: request push/createPR/sync/fetch
activate GitOps
GitOps->>Remote: attempt git push/fetch/pull
alt Remote indicates upstream-missing
GitOps->>Handler: detect upstream-missing (shouldRetryPushWithUpstream)
Handler-->>GitOps: true
GitOps->>GitOps: validate HEAD & prepare pushWithSetUpstream
GitOps->>Remote: git push --set-upstream HEAD:refs/heads/<branch>
Remote-->>GitOps: success
else Other error
Remote-->>GitOps: error
GitOps-->>App: propagate error
end
deactivate GitOps
GitOps-->>App: result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@apps/desktop/src/lib/trpc/routers/changes/git-operations.ts`:
- Around line 25-34: The inner catch after the fallback git.fetch(["origin"])
currently swallows all errors; update it to capture the thrown error, derive its
message (error instanceof Error ? error.message : String(error)), and then if
isUpstreamMissingError(message) keep suppressing, otherwise log the failure with
a prefixed context (e.g. "[git/fetch] failed fallback fetch for branch <branch>:
<error>") and either rethrow or surface the error; locate the code around
git.fetch calls and isUpstreamMissingError to implement this behavior and use
the project's logger (or console) consistently.
- Around line 49-52: Replace the thrown plain Error when detecting a detached
HEAD (the trimmedBranch check) with a TRPCError having code BAD_REQUEST;
specifically, import TRPCError from "@trpc/server" (or existing trpc import),
and change the thrown exception in the trimmedBranch/trimmedBranch === "HEAD"
block to: throw new TRPCError({ code: "BAD_REQUEST", message: "Cannot push from
detached HEAD. Please checkout a branch and try again." }); so the router
(git-operations.ts) returns a structured tRPC error instead of a raw Error.
- Use TRPCError with BAD_REQUEST for detached HEAD push errors - Only suppress upstream missing errors in fallback fetch, rethrow others with logging
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
Testing
Summary by CodeRabbit
Bug Fixes
New Features
Tests
Chores