Skip to content

Commit d222c35

Browse files
authored
Fix gh co not working when remote already exists (#6805)
Fixes #6378
1 parent bab2afc commit d222c35

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/github/folderRepositoryManager.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2269,10 +2269,23 @@ export class FolderRepositoryManager extends Disposable {
22692269
return null;
22702270
}
22712271

2272-
const headGitHubRepo = this.gitHubRepositories.find(
2272+
let headGitHubRepo = this.gitHubRepositories.find(
22732273
repo => repo.remote.remoteName === remoteName,
22742274
);
22752275

2276+
if (!headGitHubRepo && this.gitHubRepositories.length > 0) {
2277+
const gitRemote = this.repository.state.remotes.find(remote => remote.name === remoteName);
2278+
const remoteUrl = gitRemote?.fetchUrl ?? gitRemote?.pushUrl;
2279+
if (!remoteUrl) {
2280+
return null;
2281+
}
2282+
const protocol = new Protocol(remoteUrl ?? '');
2283+
const remote = parseRemote(remoteName, remoteUrl, protocol);
2284+
if (remote) {
2285+
headGitHubRepo = await this.createGitHubRepository(remote, this.credentialStore, true, true);
2286+
}
2287+
}
2288+
22762289
return this.doGetMatchingPullRequestMetadataFromGitHub(headGitHubRepo, upstreamBranchName);
22772290
}
22782291

0 commit comments

Comments
 (0)