Skip to content

Commit d8c5208

Browse files
committed
Adds isRepositoryPathOrUri method
1 parent 8cb7e5a commit d8c5208

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/git/gitProviderService.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { getScheme, isAbsolute, maybeUri, normalizePath } from '../system/path';
3939
import type { Deferred } from '../system/promise';
4040
import { asSettled, defer, getDeferredPromiseIfPending, getSettledValue } from '../system/promise';
4141
import { VisitedPathsTrie } from '../system/trie';
42+
import { uriEquals } from '../system/uri';
4243
import type {
4344
CachedGitTypes,
4445
GitBranchesSubProvider,
@@ -1961,6 +1962,17 @@ export class GitProviderService implements Disposable {
19611962
return false;
19621963
}
19631964

1965+
isRepositoryPathOrUri(uri: Uri): boolean;
1966+
isRepositoryPathOrUri(path: string): boolean;
1967+
isRepositoryPathOrUri(pathOrUri: string | Uri): boolean;
1968+
@log({ exit: true })
1969+
isRepositoryPathOrUri(pathOrUri: string | Uri): boolean {
1970+
if (typeof pathOrUri === 'string') {
1971+
return this.getRepository(pathOrUri)?.path === pathOrUri;
1972+
}
1973+
return uriEquals(pathOrUri, this.getRepository(pathOrUri)?.uri);
1974+
}
1975+
19641976
@log({ exit: true })
19651977
isRepositoryForEditor(repository: Repository, editor?: TextEditor): boolean {
19661978
editor = editor ?? window.activeTextEditor;

0 commit comments

Comments
 (0)