Skip to content

Commit 4843f67

Browse files
fix(git): keep the leading slash of an absolute scp-style repo path (#1217)
1 parent c125d03 commit 4843f67

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/__tests__/generic-git-provider.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ describe('parseGenericGitRepoInput', () => {
6666
'https://org.visualstudio.com/project/_git/repo',
6767
'git@ssh.dev.azure.com:v3/org/project/repo',
6868
'ssh://git@ssh.dev.azure.com:2222/v3/org/project/repo',
69+
// An absolute path on the SSH host is not the same repository as one relative to the login's home
70+
'git@git.example.com:/srv/git/repo.git',
6971
'https://git.example.com/group/repo',
7072
'https://git.example.com/group/repo.git',
7173
'https://git.example.com/group/repo.GIT',

‎src/providers/git/repo-url.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ function parseGenericGitRepoInputWithOptions(input: string, options: ParseOption
9292
);
9393
}
9494
const { owner, repo, fullPath } = parsePath(rawPath);
95-
return buildRepoInfo(owner, repo, `${user}@${host}:${fullPath}`);
95+
// A leading slash makes the path absolute on the host instead of relative to the login's home.
96+
const remotePath = rawPath.startsWith('/') ? `/${fullPath}` : fullPath;
97+
return buildRepoInfo(owner, repo, `${user}@${host}:${remotePath}`);
9698
}
9799

98100
throw invalidRepoUrl();

0 commit comments

Comments
 (0)