Skip to content

fix(shared): recognize userless SSH remotes with repeated path slashes - #45336

Open
saphid wants to merge 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-2e7965e2f2
Open

saphid wants to merge 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-2e7965e2f2

Conversation

@saphid

@saphid saphid commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Problem

Git accepts userless SCP-style remotes with repeated slashes in the path, such as buildbox:/srv//git/repo.git or buildbox:/srv/git/repo.git//, and connects to them over SSH. T3 Code reports no host for these remotes and does not treat them as SSH. userlessScpRemoteHost required exactly one slash between path segments and allowed at most one trailing slash. As a result, isSshRemoteUrl returned false, so RepositoryIdentityResolver skipped its SSH alias lookup, and parseGitRemoteHost fell back to URL parsing and returned null.

Deterministic repro on origin/main (d1a1ede52b02a7e346c3a6b212f013e20d176c9a): run the self-contained repro.sh <checkout> script from the evidence gist. It builds a scratch bare repo in a temp dir and sets its own Git identity with GIT_CONFIG_GLOBAL=/dev/null. It then sets origin to buildbox:<scratch>/srv//git/repo.git and to buildbox:<scratch>/srv/git/repo.git//, and runs GIT_SSH_VARIANT=ssh GIT_SSH=<stub> git ls-remote origin for each. The stub runs only its last argument through sh -c. Finally it probes the configured origins with node -e from apps/server, so nothing is written into the checkout.

  • Observed: Git calls git-upload-pack with each path unchanged and lists refs. For both origins, userlessScpRemoteHost returns null, isSshRemoteUrl returns false and parseGitRemoteHost returns null. The controls buildbox:/srv/git/repo.git and git@buildbox:/srv//git/repo.git resolve to buildbox.
  • Expected: buildbox, true and buildbox for both origins.

Change

The userless SCP pattern now allows a run of slashes between nonempty path segments (\/ → \/+) and a run of trailing slashes (\/?$ → \/*$). The host rule, the single-letter Windows drive guard, the :: remote-helper guard and the optional leading slash are unchanged. isSshRemoteUrl and parseGitRemoteHost both call this function, so source-control provider recognition and server repository identity detection are fixed together.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • packages/shared/src/sourceControl.test.ts: added the interior and trailing repeated-slash remotes to the positive isSshRemoteUrl cases and to a new userlessScpRemoteHost case. With base source, the 4 new cases fail (expected false to be true, expected null to be 'buildbox'). On head, all 22 tests pass, including the existing negative controls (hg::owner/repo, C:repo.git, C:/repos/repo, /srv/git/repo.git, file:///…, https://…).
  • parseGitRemoteHost consumer tests pass: source-control-github definition.test.ts (14) and source-control-gitlab gitLabDiscovery.test.ts (9).
  • commit-checked.sh ran vp run check:changed on the tree committed as 894a44f29f3 and exited 0 (format, lint, knip, typecheck for 38 packages, affected tests). The gist includes its summary.
  • Before/after transcript, including the real git ls-remote runs, probe output on the same configured origins, and the repro script: https://gist.github.com/saphid/b2c5d49222b694d5b5a409d29b39084b

Not shown: a connection to a real SSH host (the local stub stands in for ssh), and an end-to-end run of RepositoryIdentityResolver's alias lookup in the running app.

Authored by Claude Opus 5.5 (Model Hub); reviewed by GPT-6.2 Sol (Codex).

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 29, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Nov 29, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 95d4f41

Macroscope's review found this PR approvable — Recognizes userless SSH remotes containing repeated internal or trailing path slashes. The change is limited to URL classification and reuses existing SSH handling without changing product defaults.

Notes:

  • All code in this push has already been reviewed. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bb17157 and 95d4f41.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The userless SCP-style SSH remote pattern now accepts repeated slashes between path segments and at the end of a URL. Tests cover SSH detection and buildbox host extraction for these URLs.

Changes: SCP Remote Slash Handling

Layer / File(s) Summary
Matcher and test coverage
packages/shared/src/sourceControl.ts, packages/shared/src/sourceControl.test.ts
The userless SCP-style remote pattern accepts repeated separators and trailing slashes. Tests verify SSH detection and buildbox host extraction.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#29457: Adds userlessScpRemoteHost and uses it for remote host parsing and SSH detection, which this change updates.

Suggested reviewers: only21mil

Merge Risk: Minimal · previous review bb171

This change lets Git remotes like buildbox:/srv//git/repo.git be recognized as SSH remotes and have their host parsed. It is narrowly scoped and tested, and no concrete merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the userless SSH remote matcher now accepts repeated path slashes. It is a conventional commit with a specific scope, and it matches the code change and the PR objecti…
Description check Passed The description covers the template sections. Problem gives the bug, the expected behavior and a deterministic repro. Change explains the regex edits and why both consumers are fixed together. Scope e…
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.
Full details: Title check

Explanation

The title names the main change: the userless SSH remote matcher now accepts repeated path slashes. It is a conventional commit with a specific scope, and it matches the code change and the PR objectives.

Full details: Description check

Explanation

The description covers the template sections. Problem gives the bug, the expected behavior and a deterministic repro. Change explains the regex edits and why both consumers are fixed together. Scope explains why no issue is needed for a small fix. Verification lists focused tests, consumer tests, the check run, and a before/after transcript, and it states what was not checked. The template's agent-model line is present. The description also includes a claim that the PR was authored by a named model, which the template asks for, so it is not a defect.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a6516fb and bb17157.

Files selected for processing: 2

  • packages/shared/src/sourceControl.test.ts
  • packages/shared/src/sourceControl.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 29, 2026
@macroscopeapp
macroscopeapp Bot dismissed their stale review November 29, 2026 06:51

Dismissing prior approval to re-evaluate 95d4f41

This branch has not been deployed

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

Labels

size:XS 0-9 changed lines (additions + deletions). takeover:in-progress A takeover lead is working on this PR vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants