fix(source-control): SCP-style remotes with a leading slash keep their repository path #44007
main fromrefs/pull/44007/head·merged by juliusmarminge View on GitHubProblem#
When an SCP-style remote has a slash after the colon (git@github.com:/T3Tools/T3Code.git, github.com:/T3Tools/T3Code.git), repositoryPathFromRemoteUrl returns null instead of T3Tools/T3Code. Git and the sibling parsers (parseGitRemoteRepository, userlessScpRemoteHost, parseGitRemoteHost) accept that slash.
Change#
The regex in packages/source-control-core/src/server/SourceControlProvider.ts allows \/? after : in both SCP branches and drops : from the user part ([^@/:\s]+@), so backup:git@forge:/Owner/Repo.git still reads as Git reads it and helper URLs like hg::user@host:Owner/Repo.git return null, as userlessScpRemoteHost and parseGitRemoteHost do. New it.each rows: three leading-slash cases, those two, and a file:/// guard.
Scope#
Bug fix for wrong data: repository identity loses owner/name casing. AgentSessionScanner and GitManager's owner/name parse also get null (by code reading, not run). No issue; a one-line regex bug needs none.
Refs #31917 (same regex line, IPv6 hosts only).
Verification#
Setup: Linux, Node 26.13.1, real t3 serve from source, fresh data dir and repos per commit, no accounts or network.
Steps: Init repos with remotes git@github.com:/T3Tools/T3Code.git and git@github.com:T3Tools/T3Code.git → t3 project add each → GET /api/projects → print each repositoryIdentity (jq sorts rows, so order varies).
Before (bddcfb717c57):
{
"remote": "git@github.com:T3Tools/T3Code.git",
"displayName": "T3Tools/T3Code",
"owner": "T3Tools",
"name": "T3Code"
}
{
"remote": "git@github.com:/T3Tools/T3Code.git",
"displayName": "t3tools/t3code",
"owner": "t3tools",
"name": "t3code"
}
After (0aae673cf1b4):
{
"remote": "git@github.com:/T3Tools/T3Code.git",
"displayName": "T3Tools/T3Code",
"owner": "T3Tools",
"name": "T3Code"
}
{
"remote": "git@github.com:T3Tools/T3Code.git",
"displayName": "T3Tools/T3Code",
"owner": "T3Tools",
"name": "T3Code"
}
The same steps on newest green main (ec2777c370f1) show the bug; a clean local merge shows the fix and passes the focused tests. On the base source the leading-slash and hg:: rows fail; all rows pass on head. vp run check:changed passed. An AI agent ran these checks.
Not shown
- No UI capture (web project label not driven; server-only proof).
- Windows/macOS not run (pure string parsing).
GitManagerandAgentSessionScannernot run on the real server.
Test output
Base (bddcfb717c57 source with the new table, fails):
FAIL |root| packages/source-control-core/src/server/SourceControlProvider.test.ts > reads the repository path of git@github.com:/T3Tools/t3code.git
FAIL |root| packages/source-control-core/src/server/SourceControlProvider.test.ts > reads the repository path of github.com:/T3Tools/t3code.git
AssertionError: expected null to equal 'T3Tools/t3code'
FAIL |root| packages/source-control-core/src/server/SourceControlProvider.test.ts > reads the repository path of gitlab.com:/T3Tools/platform/t3code
AssertionError: expected null to equal 'T3Tools/platform/t3code'
FAIL |root| packages/source-control-core/src/server/SourceControlProvider.test.ts > reads the repository path of hg::user@host:Owner/Repo.git
AssertionError: expected 'Owner/Repo' to equal null
Tests 4 failed | 10 passed (14)
Head (0aae673cf1b4, passes):
Tests 14 passed (14)
Generated with Gemini 4 Neon in T3 Code Nightly
Evidence#
Create three empty Git repositories with leading-slash, no-slash, and helper origins. On each commit, start the real Linux server with a fresh database and T3CODE_DEV_SEED=0, run
t3 project addfor all three, fetch/api/projects, and callagentSessions.scanusing synthetic session metadata.Owner/Repo.T3Tools/T3Code; helper yields null.Images render actual server/CLI response transcripts, not UI screenshots. The no-slash control remains correct on both commits.
Driver · Transcript renderer · Before JSON · After JSON
Response captures, with fixture paths redacted: Before projects, After projects, Before discovery, After discovery.