Skip to content

Commit 33202d6

Browse files
authored
Extension fails to detect PR branch when using gh co <PR> (#6755)
Fixes #6378
1 parent 4c8e038 commit 33202d6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/github/folderRepositoryManager.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,17 +2240,16 @@ export class FolderRepositoryManager extends Disposable {
22402240
if (!remoteUrl) {
22412241
return null;
22422242
}
2243-
let headGitHubRepo = this.gitHubRepositories.find(repo => repo.remote.url.toLowerCase() === remoteUrl.toLowerCase());
2244-
let protocol: Protocol | undefined;
2243+
const protocol: Protocol = new Protocol(remoteUrl);
2244+
let headGitHubRepo = this.findRepo((input) => compareIgnoreCase(input.remote.owner, protocol.owner) === 0 && compareIgnoreCase(input.remote.repositoryName, protocol.repositoryName) === 0);
22452245
if (!headGitHubRepo && this.gitHubRepositories.length > 0) {
2246-
protocol = new Protocol(remoteUrl);
22472246
const remote = parseRemote(protocol.repositoryName, remoteUrl, protocol);
22482247
if (remote) {
22492248
headGitHubRepo = await this.createGitHubRepository(remote, this.credentialStore, true, true);
22502249
}
22512250
}
22522251
const matchingPR = await this.doGetMatchingPullRequestMetadataFromGitHub(headGitHubRepo, upstreamBranchName);
2253-
if (matchingPR && (branch.upstream === undefined) && protocol && headGitHubRepo && branch.name) {
2252+
if (matchingPR && (branch.upstream === undefined) && headGitHubRepo && branch.name) {
22542253
const newRemote = await PullRequestGitHelper.createRemote(this.repository, headGitHubRepo?.remote, protocol);
22552254
const trackedBranchName = `refs/remotes/${newRemote}/${matchingPR.model.head?.name}`;
22562255
await this.repository.fetch({ remote: newRemote, ref: matchingPR.model.head?.name });

0 commit comments

Comments
 (0)