fix: tolerate literal percent in bitbucket remotes (#3685)

This commit is contained in:
Neil 2026-05-30 12:20:33 -07:00 committed by GitHub
parent 4bc237cc18
commit 361b833fcd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 2 deletions

View File

@ -36,6 +36,23 @@ describe('Bitbucket repository refs', () => {
expect(parseBitbucketRepoRef('https://github.com/team/project.git')).toBeNull()
})
it('keeps malformed percent sequences as literal repo path text', async () => {
expect(parseBitbucketRepoRef('git@bitbucket.org:team/project%zz.git')).toEqual({
workspace: 'team',
repoSlug: 'project%zz'
})
gitExecFileAsyncMock.mockResolvedValue({
stdout: 'git@bitbucket.org:team/project%zz.git\n',
stderr: ''
})
await expect(getBitbucketRepoRef('/repo')).resolves.toEqual({
workspace: 'team',
repoSlug: 'project%zz'
})
})
it('resolves origin through the WSL-aware git runner and caches the result', async () => {
gitExecFileAsyncMock.mockResolvedValue({
stdout: 'git@bitbucket.org:team/project.git\n',

View File

@ -12,6 +12,14 @@ export function _resetBitbucketRepoRefCache(): void {
repoRefCache.clear()
}
function decodeSegment(value: string): string {
try {
return decodeURIComponent(value)
} catch {
return value
}
}
function parseBitbucketPath(pathname: string): BitbucketRepoRef | null {
const withoutSuffix = pathname.replace(/\.git$/i, '')
const parts = withoutSuffix
@ -27,8 +35,8 @@ function parseBitbucketPath(pathname: string): BitbucketRepoRef | null {
return null
}
return {
workspace: decodeURIComponent(workspace),
repoSlug: decodeURIComponent(repoSlug)
workspace: decodeSegment(workspace),
repoSlug: decodeSegment(repoSlug)
}
}