fix(host-service): read remote URLs from git config, not git remote -v#4065
Conversation
`git remote -v` appends partial-clone markers like `[blob:none]` after `(fetch)` whenever `remote.<name>.promisor` is set, so a parser anchored on `(fetch)$` silently dropped those lines and `resolveLocalRepo` fell back to the alphabetically-first remote. For users who cloned with `--filter=blob:none` (common for monorepos), the v2 add-folder flow detected the wrong remote — e.g. `origin: superset-sh/superset` was dropped, leaving `andreasasprou/superset` to win. Read remotes from `git config --get-regexp '^remote\..*\.url$'` instead. The format is rigid and machine-stable (`<key> <value>` per line, no human-readable suffixes), so this kills the entire format-fragility class — partial-clone markers and any future `git remote -v` cosmetic drift across git versions are no longer load-bearing. Includes a regression test for the partial-clone case with an alphabetically-earlier sibling remote.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughgetAllRemoteUrls now reads remote URLs from git config keys ( ChangesRemote URL Parsing & Partial Clone Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Greptile SummaryThis PR replaces the Confidence Score: 5/5Safe to merge — targeted bug fix with full test coverage and no regressions introduced. No P0 or P1 findings. The new parsing approach is strictly more correct than the previous one: it uses a machine-stable format, handles partial-clone markers naturally, and the No files require special attention.
|
| Filename | Overview |
|---|---|
| packages/host-service/src/trpc/router/project/utils/git-remote.ts | Replaces git remote -v parsing with git config --get-regexp for machine-stable remote URL extraction; logic is correct and edge cases (empty output, exit-code 1, dotted remote names) are all handled. |
| packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts | Adds a well-scoped regression test for the partial-clone scenario with an alphabetically-earlier competing remote; test structure matches the existing suite style. |
Sequence Diagram
sequenceDiagram
participant C as Caller (resolveLocalRepo)
participant G as getAllRemoteUrls
participant S as SimpleGit
C->>G: getAllRemoteUrls(git)
G->>S: git.raw([config, --get-regexp, ^remote\..*\.url$])
alt No remotes / exit code 1
S-->>G: throws, caught, returns empty string
G-->>C: empty Map
else Has remotes
S-->>G: remote.origin.url https://github.com/Acme/App.git
loop each output line
G->>G: split on first space to get key and url
G->>G: key.match to extract remoteName
G->>G: remotes.set(remoteName, url)
end
G-->>C: Map of remoteName to URL
end
Reviews (1): Last reviewed commit: "fix(host-service): read remote URLs from..." | Re-trigger Greptile
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Three fixes since v0.2.6: - relay tunnel: carry binary WS frames as base64 so PTY output renders through cross-host workspaces (no more `[terminal] invalid server payload`) (#4066) - host-service: read remote URLs from git config instead of `git remote -v` (#4065) - cli: auto-refresh OAuth access token using the refresh token (#4069) Push cli-v0.2.7 after this lands to fire the release pipeline.
Summary
git remote -vappends partial-clone markers ([blob:none],[treeless], …) after(fetch)wheneverremote.<name>.promisoris set. The parser anchored on(fetch)$silently dropped those lines, andresolveLocalRepofell back to the alphabetically-first remote — e.g.origin: superset-sh/supersetwas dropped, leavingandreasasprou/supersetto win for users who cloned with--filter=blob:none.git config --get-regexp '^remote\..*\.url$'instead. The format is rigid and machine-stable (<key> <value>per line, no human-readable suffix), which kills the entire class ofgit remote -vformat-drift bugs at the source rather than patching the regex.[blob:none](fix(host-service): tolerate[blob:none]suffix ingit remote -v#4064). That works for the reported bug but leaves the parser dependent ongit remote -v's human-readable format — any future cosmetic addition resurfaces the same class. This PR supersedes that approach.Test plan
bun test packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts— 24 pass (includes new regression test for--filter=blob:none+ alphabetically-earlier sibling remote)bun testhost-service full suite — 489 pass / 0 failbun run typecheckhost-service — cleanbun run lint— cleanaaa(alphabetical first) +origin—resolveLocalRepocorrectly returnsorigin → superset-sh/superset--filter=blob:noneclone in the v2 desktop UI and confirmoriginis detectedSummary by cubic
Read Git remote URLs from
git configinstead ofgit remote -vto make detection stable and fix wrong remote selection in partial clones. EnsuresresolveLocalRepopicksoriginwhen present.git config --get-regexp '^remote\..*\.url$'instead of parsinggit remote -v.[blob:none]sooriginis not skipped; adds a regression test and minor cleanup ingetAllRemoteUrls.Written for commit f012f70. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests