Skip to content

Commit 10c1eba

Browse files
committed
Handle forks
1 parent 79434c6 commit 10c1eba

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/github/folderRepositoryManager.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,10 +1461,30 @@ export class FolderRepositoryManager extends Disposable {
14611461
}
14621462

14631463
async getMaxIssue(repository: Repository): Promise<number> {
1464-
const ghRepo = this._githubRepositories.find(repo =>
1465-
repository.state.remotes.some(r => r.name === repo.remote.remoteName)
1466-
);
1467-
return (await ghRepo?.getMaxIssue()) ?? 0;
1464+
const remoteNames = new Set(repository.state.remotes.map(remote => remote.name));
1465+
const ghRepo = this._githubRepositories.find(repo => remoteNames.has(repo.remote.remoteName));
1466+
if (!ghRepo) {
1467+
return 0;
1468+
}
1469+
1470+
const reposToCheck: GitHubRepository[] = [ghRepo];
1471+
const metadata = await ghRepo.getMetadata();
1472+
if (metadata.fork) {
1473+
for (const repo of this._githubRepositories) {
1474+
if (repo !== ghRepo && repo.remote.repositoryName === ghRepo.remote.repositoryName) {
1475+
reposToCheck.push(repo);
1476+
}
1477+
}
1478+
}
1479+
1480+
const maxIssues = await Promise.all(reposToCheck.map(repo => repo.getMaxIssue()));
1481+
let max = 0;
1482+
for (const value of maxIssues) {
1483+
if (value !== undefined) {
1484+
max = Math.max(max, value);
1485+
}
1486+
}
1487+
return max;
14681488
}
14691489

14701490
async getIssueTemplates(): Promise<vscode.Uri[]> {

0 commit comments

Comments
 (0)