Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/github/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,11 +1128,16 @@ export function isFileInRepo(repository: Repository, file: vscode.Uri): boolean
}

export function getRepositoryForFile(gitAPI: GitApiImpl, file: vscode.Uri): Repository | undefined {
for (const repository of gitAPI.repositories) {
const foundRepos: Repository[] = [];
for (const repository of gitAPI.repositories.reverse()) {
if (isFileInRepo(repository, file)) {
return repository;
foundRepos.push(repository);
}
}
if (foundRepos.length > 0) {
foundRepos.sort((a, b) => b.rootUri.path.length - a.rootUri.path.length);
return foundRepos[0];
}
return undefined;
}

Expand Down