Skip to content

Commit 45d22f3

Browse files
committed
Merge Commit 'f2c52f7': fix(cli): allow non-GitHub SCP-styled URLs for extension installation (google-gemini#13800)
2 parents 035939f + f2c52f7 commit 45d22f3

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/cli/src/config/extensions/github.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ describe('github.ts', () => {
136136
expect(tryParseGithubUrl(url)).toEqual({ owner, repo });
137137
});
138138

139-
it('should return null for non-GitHub URLs', () => {
140-
expect(tryParseGithubUrl('https://gitlab.com/owner/repo')).toBeNull();
139+
it.each([
140+
'https://gitlab.com/owner/repo',
141+
'https://my-git-host.com/owner/group/repo',
142+
'[email protected]:some-group/some-project/some-repo.git',
143+
])('should return null for non-GitHub URLs', (url) => {
144+
expect(tryParseGithubUrl(url)).toBeNull();
141145
});
142146

143147
it('should throw for invalid formats', () => {

packages/cli/src/config/extensions/github.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ export interface GithubRepoInfo {
8484
}
8585

8686
export function tryParseGithubUrl(source: string): GithubRepoInfo | null {
87-
// First step in normalizing a github ssh URI to the https form.
88-
if (source.startsWith('[email protected]:')) {
89-
source = source.replace('[email protected]:', '');
87+
// Handle SCP-style SSH URLs.
88+
if (source.startsWith('git@')) {
89+
if (source.startsWith('[email protected]:')) {
90+
// It's a GitHub SSH URL, so normalize it for the URL parser.
91+
source = source.replace('[email protected]:', '');
92+
} else {
93+
// It's another provider's SSH URL (e.g., gitlab), so not a GitHub repo.
94+
return null;
95+
}
9096
}
9197
// Default to a github repo path, so `source` can be just an org/repo
9298
const parsedUrl = URL.parse(source, 'https://github.com');

0 commit comments

Comments
 (0)