Sfoglia il codice sorgente

Renames repo create to open

main
Eric Amodio 2 anni fa
parent
commit
9282c3a7fd
9 ha cambiato i file con 27 aggiunte e 33 eliminazioni
  1. +1
    -1
      src/commands/common.ts
  2. +1
    -1
      src/commands/externalDiff.ts
  3. +1
    -1
      src/commands/git/coauthors.ts
  4. +2
    -2
      src/commands/quickCommand.steps.ts
  5. +2
    -2
      src/commands/stashSave.ts
  6. +6
    -6
      src/env/node/git/localGitProvider.ts
  7. +2
    -8
      src/git/gitProvider.ts
  8. +8
    -8
      src/git/gitProviderService.ts
  9. +4
    -4
      src/git/gitUri.ts

+ 1
- 1
src/commands/common.ts Vedi File

@ -253,7 +253,7 @@ export async function getRepoPathOrActiveOrPrompt(uri: Uri | undefined, editor:
export async function getRepoPathOrPrompt(title: string, uri?: Uri) {
if (uri == null) return Container.instance.git.highlander?.path;
const repoPath = (await Container.instance.git.getOrCreateRepository(uri))?.path;
const repoPath = (await Container.instance.git.getOrOpenRepository(uri))?.path;
if (repoPath) return repoPath;
const pick = await RepositoryPicker.show(title);

+ 1
- 1
src/commands/externalDiff.ts Vedi File

@ -150,7 +150,7 @@ export class ExternalDiffCommand extends Command {
args.files.push({ uri: status.uri, staged: false });
}
} else {
repoPath = (await this.container.git.getOrCreateRepository(args.files[0].uri))?.path;
repoPath = (await this.container.git.getOrOpenRepository(args.files[0].uri))?.path;
if (!repoPath) return;
}

+ 1
- 1
src/commands/git/coauthors.ts Vedi File

@ -110,7 +110,7 @@ export class CoAuthorsGitCommand extends QuickCommand {
);
// Ensure that the active repo is known to the built-in git
context.activeRepo = await this.container.git.getOrCreateRepositoryForEditor();
context.activeRepo = await this.container.git.getOrOpenRepositoryForEditor();
if (
context.activeRepo != null &&
!scmRepositories.some(r => r.rootUri.fsPath === context.activeRepo!.path)

+ 2
- 2
src/commands/quickCommand.steps.ts Vedi File

@ -1131,7 +1131,7 @@ export async function* pickRepositoryStep<
state.repo = Container.instance.git.getRepository(state.repo);
if (state.repo != null) return state.repo;
}
const active = state.repo ?? (await Container.instance.git.getOrCreateRepositoryForEditor());
const active = state.repo ?? (await Container.instance.git.getOrOpenRepositoryForEditor());
const step = QuickCommand.createPickStep<RepositoryQuickPickItem>({
title: context.title,
@ -1194,7 +1194,7 @@ export async function* pickRepositoriesStep<
actives = state.repos;
}
} else {
const active = await Container.instance.git.getOrCreateRepositoryForEditor();
const active = await Container.instance.git.getOrOpenRepositoryForEditor();
actives = active != null ? [active] : [];
}

+ 2
- 2
src/commands/stashSave.ts Vedi File

@ -42,7 +42,7 @@ export class StashSaveCommand extends Command {
} else if (context.type === 'scm-states') {
args = { ...args };
args.uris = context.scmResourceStates.map(s => s.resourceUri);
args.repoPath = (await this.container.git.getOrCreateRepository(args.uris[0]))?.path;
args.repoPath = (await this.container.git.getOrOpenRepository(args.uris[0]))?.path;
const status = await this.container.git.getStatusForRepo(args.repoPath);
if (status?.computeWorkingTreeStatus().staged) {
@ -60,7 +60,7 @@ export class StashSaveCommand extends Command {
(a, b) => a.concat(b.resourceStates.map(s => s.resourceUri)),
[],
);
args.repoPath = (await this.container.git.getOrCreateRepository(args.uris[0]))?.path;
args.repoPath = (await this.container.git.getOrOpenRepository(args.uris[0]))?.path;
const status = await this.container.git.getStatusForRepo(args.repoPath);
if (status?.computeWorkingTreeStatus().staged) {

+ 6
- 6
src/env/node/git/localGitProvider.ts Vedi File

@ -338,7 +338,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
}
createRepository(
openRepository(
folder: WorkspaceFolder,
uri: Uri,
root: boolean,
@ -358,7 +358,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
);
}
createRepositoryInitWatcher(): RepositoryInitWatcher {
openRepositoryInitWatcher(): RepositoryInitWatcher {
const watcher = workspace.createFileSystemWatcher('**/.git', false, true, true);
return {
onDidCreate: watcher.onDidCreate,
@ -386,7 +386,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const uri = await this.findRepositoryUri(folder.uri, true);
if (uri != null) {
Logger.log(cc, `found root repository in '${uri.fsPath}'`);
repositories.push(this.createRepository(folder, uri, true));
repositories.push(this.openRepository(folder, uri, true));
}
if (depth <= 0) return repositories;
@ -443,7 +443,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
if (rp == null) continue;
Logger.log(cc, `found repository in '${rp.fsPath}'`);
repositories.push(this.createRepository(folder, rp, false));
repositories.push(this.openRepository(folder, rp, false));
}
return repositories;
@ -3363,7 +3363,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
// If we didn't find it, check it as close to the file as possible (will find nested repos)
tracked = Boolean(await Git.ls_files(newRepoPath, newRelativePath));
if (tracked) {
repository = await this.container.git.getOrCreateRepository(Uri.file(path), true);
repository = await this.container.git.getOrOpenRepository(Uri.file(path), true);
if (repository != null) {
return splitPath(path, repository.path);
}
@ -3388,7 +3388,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
const index = relativePath.indexOf('/');
if (index < 0 || index === relativePath.length - 1) return undefined;
const nested = await this.container.git.getOrCreateRepository(Uri.file(path), true);
const nested = await this.container.git.getOrOpenRepository(Uri.file(path), true);
if (nested != null && nested !== repository) {
[relativePath, repoPath] = splitPath(path, repository.path);
repository = undefined;

+ 2
- 8
src/git/gitProvider.ts Vedi File

@ -82,14 +82,8 @@ export interface GitProvider extends Disposable {
discoverRepositories(uri: Uri): Promise<Repository[]>;
updateContext?(): void;
createRepository(
folder: WorkspaceFolder,
uri: Uri,
root: boolean,
suspended?: boolean,
closed?: boolean,
): Repository;
createRepositoryInitWatcher?(): RepositoryInitWatcher;
openRepository(folder: WorkspaceFolder, uri: Uri, root: boolean, suspended?: boolean, closed?: boolean): Repository;
openRepositoryInitWatcher?(): RepositoryInitWatcher;
getOpenScmRepositories(): Promise<ScmRepository[]>;
getOrOpenScmRepository(repoPath: string): Promise<ScmRepository | undefined>;

+ 8
- 8
src/git/gitProviderService.ts Vedi File

@ -294,7 +294,7 @@ export class GitProviderService implements Disposable {
const disposables = [];
const watcher = provider.createRepositoryInitWatcher?.();
const watcher = provider.openRepositoryInitWatcher?.();
if (watcher != null) {
disposables.push(
watcher,
@ -331,7 +331,7 @@ export class GitProviderService implements Disposable {
if (repository != null) {
repository.closed = false;
} else {
void this.getOrCreateRepository(e.uri);
void this.getOrOpenRepository(e.uri);
}
}),
);
@ -1424,8 +1424,8 @@ export class GitProviderService implements Disposable {
private _pendingRepositories = new Map<string, Promise<Repository | undefined>>();
@log<GitProviderService['getRepository']>({ exit: r => `returned ${r?.path}` })
async getOrCreateRepository(uri: Uri, detectNested?: boolean): Promise<Repository | undefined> {
@log<GitProviderService['getOrOpenRepository']>({ exit: r => `returned ${r?.path}` })
async getOrOpenRepository(uri: Uri, detectNested?: boolean): Promise<Repository | undefined> {
const cc = Logger.getCorrelationContext();
const folderPath = dirname(uri.fsPath);
@ -1480,7 +1480,7 @@ export class GitProviderService implements Disposable {
}
Logger.log(cc, `Repository found in '${repoUri.toString(false)}'`);
repository = provider.createRepository(folder, repoUri, false);
repository = provider.openRepository(folder, repoUri, false);
this._repositories.add(repository);
this._pendingRepositories.delete(key);
@ -1499,15 +1499,15 @@ export class GitProviderService implements Disposable {
return promise;
}
@log<GitProviderService['getOrCreateRepositoryForEditor']>({
@log<GitProviderService['getOrOpenRepositoryForEditor']>({
args: { 0: e => (e != null ? `TextEditor(${Logger.toLoggable(e.document.uri)})` : undefined) },
})
async getOrCreateRepositoryForEditor(editor?: TextEditor): Promise<Repository | undefined> {
async getOrOpenRepositoryForEditor(editor?: TextEditor): Promise<Repository | undefined> {
editor = editor ?? window.activeTextEditor;
if (editor == null) return this.highlander;
return this.getOrCreateRepository(editor.document.uri);
return this.getOrOpenRepository(editor.document.uri);
}
getRepository(uri: Uri): Repository | undefined;

+ 4
- 4
src/git/gitUri.ts Vedi File

@ -262,7 +262,7 @@ export class GitUri extends (Uri as any as UriEx) {
} catch {}
if (data?.path) {
const repository = await Container.instance.git.getOrCreateRepository(Uri.file(data.path));
const repository = await Container.instance.git.getOrOpenRepository(Uri.file(data.path));
if (repository == null) {
debugger;
throw new Error(`Unable to find repository for uri=${uri.toString(false)}`);
@ -310,7 +310,7 @@ export class GitUri extends (Uri as any as UriEx) {
} catch {}
if (data?.fileName) {
const repository = await Container.instance.git.getOrCreateRepository(Uri.file(data.fileName));
const repository = await Container.instance.git.getOrOpenRepository(Uri.file(data.fileName));
if (repository == null) {
debugger;
throw new Error(`Unable to find repository for uri=${uri.toString(false)}`);
@ -321,7 +321,7 @@ export class GitUri extends (Uri as any as UriEx) {
repoPath = repoPath.substr(0, repoPath.length - data.fileName.length - 1);
} else {
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
repoPath = (await Container.instance.git.getOrCreateRepository(uri))?.path!;
repoPath = (await Container.instance.git.getOrOpenRepository(uri))?.path!;
if (!repoPath) {
debugger;
}
@ -336,7 +336,7 @@ export class GitUri extends (Uri as any as UriEx) {
}
}
const repository = await Container.instance.git.getOrCreateRepository(uri);
const repository = await Container.instance.git.getOrOpenRepository(uri);
return new GitUri(uri, repository?.path);
}

Caricamento…
Annulla
Salva