Skip to content

fix(host-service): tolerate [blob:none] suffix in git remote -v#4064

Open
AviPeltz wants to merge 1 commit into
mainfrom
v2-superset-folder-addition-and-remote-url-issue
Open

fix(host-service): tolerate [blob:none] suffix in git remote -v#4064
AviPeltz wants to merge 1 commit into
mainfrom
v2-superset-folder-addition-and-remote-url-issue

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented May 4, 2026

Summary

  • git remote -v appends a partial-clone marker ([blob:none], [treeless], …) after (fetch) whenever remote.<name>.promisor is set. The parser anchored on (fetch)$, so the line was silently dropped from getAllRemoteUrls and resolveLocalRepo fell back to the alphabetically-first remote.
  • For users who cloned with --filter=blob:none (very common for monorepos), the v2 add-folder flow detected the wrong remote URL and either rejected the folder or matched against an unrelated cloud project — e.g. origin: superset-sh/superset was dropped, leaving andreasasprou/superset to win as alphabetically first.
  • Fix: drop the $ end-of-line anchor and require (fetch) to be followed by whitespace or end-of-line. Strict superset of the prior matches; no input correctly parsed before is now mishandled.

Test plan

  • bun test packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts — 24 pass
  • New regression test fails on the pre-fix regex (returns "aaa" instead of "origin") and passes after
  • bun run lint clean
  • Manually re-add a --filter=blob:none clone in the v2 desktop UI and confirm origin is detected

Summary by cubic

Fixes remote URL parsing to handle partial-clone markers like [blob:none] in git remote -v, so we correctly detect origin in the v2 add-folder flow. Prevents falling back to the alphabetically-first remote and picking the wrong project.

  • Bug Fixes
    • Relaxed regex to match (fetch) followed by whitespace or end-of-line, tolerating markers like [blob:none] and [treeless].
    • Added a regression test to ensure origin is kept when partial-clone markers are present.

Written for commit defc69a. Summary will update on new commits.

Summary by CodeRabbit

Bug Fixes

  • Fixed parsing of git remotes that include partial-clone markers (e.g., when using sparse checkout). Previously, such remotes were skipped, preventing accurate GitHub repository detection. This fix ensures the correct remote is always identified, improving reliability when working with repositories using advanced git configurations.

`git remote -v` appends a partial-clone marker (`[blob:none]`,
`[treeless]`, etc.) after `(fetch)` whenever `remote.<name>.promisor`
is set. The parser anchored on `(fetch)$`, so the line was silently
dropped and `resolveLocalRepo` fell back to the alphabetically-first
remote. For users who cloned with `--filter=blob:none`, the v2
add-folder flow detected the wrong remote and either rejected the
folder or matched against the wrong cloud project.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

Updated the regex in getAllRemoteUrls to accept (fetch) with optional trailing content, preventing skipped remotes when git appends partial-clone markers. Added test case verifying origin is correctly selected and parsed when configured as a partial clone.

Changes

Git Remote Partial-Clone Handling

Layer / File(s) Summary
Core Regex Fix
packages/host-service/src/trpc/router/project/utils/git-remote.ts
Updated getAllRemoteUrls regex to match (fetch) followed by optional whitespace/end-of-line instead of exact suffix, preserving remote name → URL mapping when partial-clone markers are appended.
Test Coverage
packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts
Added resolveLocalRepo test case verifying origin remote is selected and correctly parsed even when marked as partial clone with promisor=true and partialclonefilter=blob:none.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A partial clone shall not hide,
The origin remote—our guide!
Regex fixed with graceful flair,
Now all remotes receive fair care,
GitHub detection, crystal clear! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing the regex to tolerate [blob:none] suffixes in git remote -v output.
Description check ✅ Passed The description covers the problem, impact, fix, and test plan comprehensively. All template sections are either filled out appropriately or have reasonable context provided through the cubic-generated summary.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v2-superset-folder-addition-and-remote-url-issue

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 4, 2026

Greptile Summary

Fixes a silent remote-drop in getAllRemoteUrls when git remote -v appends a partial-clone marker ([blob:none], [treeless], …) after (fetch) — caused by the end-of-line anchor $ in the parsing regex. The one-character fix ($(?:\s|$)) is accompanied by a well-structured integration regression test that reproduces the exact failure scenario.

Confidence Score: 5/5

Safe to merge — minimal targeted regex fix with a focused regression test and no behavioural change for previously-valid input.

The change is a single-character regex relaxation that is strictly a superset of the prior matches. The fix is well-reasoned, the comment is clear, and the new integration test reproduces the exact failure path. No existing tests are affected, and no new code paths are introduced.

No files require special attention.

Important Files Changed

Filename Overview
packages/host-service/src/trpc/router/project/utils/git-remote.ts Regex anchor $ dropped in favour of `(?:\s
packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts New integration regression test configures a real repo with remote.origin.promisor / remote.origin.partialclonefilter to reproduce the [blob:none] suffix and assert origin wins over the alphabetically-earlier aaa remote.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["git remote -v output line"] --> B{"line matches\n/^(\\S+)\\s+(\\S+)\\s+\\(fetch\\)(?:\\s|$)/"}
    B -- "Yes (normal clone)\ne.g. origin  git@github.com:Org/Repo.git  (fetch)" --> C["remotes.set(name, url)"]
    B -- "Yes (partial clone)\ne.g. origin  git@github.com:Org/Repo.git  (fetch) [blob:none]" --> C
    B -- "No (push line)\ne.g. origin  git@github.com:Org/Repo.git  (push)" --> D["skip line"]
    C --> E["getGitHubRemotes → filter GitHub remotes"]
    E --> F{"has 'origin'?"}
    F -- "Yes" --> G["return origin"]
    F -- "No" --> H["return first GitHub remote"]
Loading

Reviews (1): Last reviewed commit: "fix(host-service): tolerate `[blob:none]..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts (1)

110-128: ⚡ Quick win

Strengthen this regression test by asserting the partial-clone marker is present.

Right now the test proves origin preference, but it doesn’t prove the repo is in the exact [blob:none] output shape that previously broke parsing. Add a quick assertion on git.remote(["-v"]) before resolveLocalRepo so this test can’t silently collapse into a duplicate of the existing multi-remote case.

Suggested test hardening
 test("returns origin when it is configured as a partial clone (`[blob:none]` suffix)", async () => {
@@
 	await git.raw(["config", "remote.origin.promisor", "true"]);
 	await git.raw(["config", "remote.origin.partialclonefilter", "blob:none"]);
+
+	const remoteV = await git.remote(["-v"]);
+	expect(remoteV).toMatch(/\borigin\b.*\(fetch\).*?\[blob:none\]/);
 
 	const resolved = await resolveLocalRepo(repo);
🤖 Prompt for 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.

In `@packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts`
around lines 110 - 128, The test needs to assert the presence of the
partial-clone marker so it cannot regress into the multi-remote scenario: after
configuring the repo (the calls to initRepoAt, git.addRemote and git.raw setting
remote.origin.promisor and remote.origin.partialclonefilter) call
git.remote(["-v"]) and assert the returned string/lines include the exact
"[blob:none]" marker for the origin remote before invoking resolveLocalRepo;
ensure you reference the same git instance used in the test and assert that the
origin line contains both the origin URL and the "[blob:none]" suffix so the
test is exercising the exact failing input shape for resolveLocalRepo.
🤖 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.

Nitpick comments:
In `@packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts`:
- Around line 110-128: The test needs to assert the presence of the
partial-clone marker so it cannot regress into the multi-remote scenario: after
configuring the repo (the calls to initRepoAt, git.addRemote and git.raw setting
remote.origin.promisor and remote.origin.partialclonefilter) call
git.remote(["-v"]) and assert the returned string/lines include the exact
"[blob:none]" marker for the origin remote before invoking resolveLocalRepo;
ensure you reference the same git instance used in the test and assert that the
origin line contains both the origin URL and the "[blob:none]" suffix so the
test is exercising the exact failing input shape for resolveLocalRepo.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0a1e20e3-e819-4cd3-9f61-5a26e24cc6f6

📥 Commits

Reviewing files that changed from the base of the PR and between 15221c9 and defc69a.

📒 Files selected for processing (2)
  • packages/host-service/src/trpc/router/project/utils/git-remote.ts
  • packages/host-service/src/trpc/router/project/utils/resolve-repo.test.ts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant