소스 검색

Adds getBestRepositoryOrFirst helper

main
Eric Amodio 2 년 전
부모
커밋
a904be16ea
1개의 변경된 파일26개의 추가작업 그리고 1개의 파일을 삭제
  1. +26
    -1
      src/git/gitProviderService.ts

+ 26
- 1
src/git/gitProviderService.ts 파일 보기

@ -1846,7 +1846,9 @@ export class GitProviderService implements Disposable {
getBestRepository(uri?: TextEditor | Uri, editor?: TextEditor): Repository | undefined;
@log<GitProviderService['getBestRepository']>({ exit: r => `returned ${r?.path}` })
getBestRepository(editorOrUri?: TextEditor | Uri, editor?: TextEditor): Repository | undefined {
if (this.repositoryCount === 0) return undefined;
const count = this.repositoryCount;
if (count === 0) return undefined;
if (count === 1) return this.highlander;
if (editorOrUri != null && editorOrUri instanceof Uri) {
const repo = this.getRepository(editorOrUri);
@ -1859,6 +1861,29 @@ export class GitProviderService implements Disposable {
return (editor != null ? this.getRepository(editor.document.uri) : undefined) ?? this.highlander;
}
getBestRepositoryOrFirst(): Repository | undefined;
getBestRepositoryOrFirst(uri?: Uri): Repository | undefined;
getBestRepositoryOrFirst(editor?: TextEditor): Repository | undefined;
getBestRepositoryOrFirst(uri?: TextEditor | Uri, editor?: TextEditor): Repository | undefined;
@log<GitProviderService['getBestRepositoryOrFirst']>({ exit: r => `returned ${r?.path}` })
getBestRepositoryOrFirst(editorOrUri?: TextEditor | Uri, editor?: TextEditor): Repository | undefined {
const count = this.repositoryCount;
if (count === 0) return undefined;
if (count === 1) return first(this._repositories.values());
if (editorOrUri != null && editorOrUri instanceof Uri) {
const repo = this.getRepository(editorOrUri);
if (repo != null) return repo;
editorOrUri = undefined;
}
editor = editorOrUri ?? editor ?? window.activeTextEditor;
return (
(editor != null ? this.getRepository(editor.document.uri) : undefined) ?? first(this._repositories.values())
);
}
@log<GitProviderService['getOrOpenRepository']>({ exit: r => `returned ${r?.path}` })
async getOrOpenRepository(uri: Uri, detectNested?: boolean): Promise<Repository | undefined> {
const scope = getLogScope();

불러오는 중...
취소
저장