Browse Source

Cleans up overloads

main
Eric Amodio 3 years ago
parent
commit
3820349af8
3 changed files with 11 additions and 36 deletions
  1. +6
    -19
      src/env/node/git/localGitProvider.ts
  2. +1
    -13
      src/git/gitProvider.ts
  3. +4
    -4
      src/git/gitProviderService.ts

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

@ -3463,34 +3463,21 @@ export class LocalGitProvider implements GitProvider, Disposable {
} }
} }
async resolveReference(
repoPath: string,
ref: string,
fileName?: string,
options?: { timeout?: number },
): Promise<string>;
async resolveReference(repoPath: string, ref: string, uri?: Uri, options?: { timeout?: number }): Promise<string>;
@log() @log()
async resolveReference(
repoPath: string,
ref: string,
fileNameOrUri?: string | Uri,
options?: { timeout?: number },
) {
if (ref == null || ref.length === 0 || ref === GitRevision.deletedOrMissing || GitRevision.isUncommitted(ref)) {
async resolveReference(repoPath: string, ref: string, pathOrUri?: string | Uri, options?: { timeout?: number }) {
if (!ref || ref === GitRevision.deletedOrMissing || GitRevision.isUncommitted(ref)) {
return ref; return ref;
} }
if (fileNameOrUri == null) {
if (pathOrUri == null) {
if (GitRevision.isSha(ref) || !GitRevision.isShaLike(ref) || ref.endsWith('^3')) return ref; if (GitRevision.isSha(ref) || !GitRevision.isShaLike(ref) || ref.endsWith('^3')) return ref;
return (await Git.rev_parse__verify(repoPath, ref)) ?? ref; return (await Git.rev_parse__verify(repoPath, ref)) ?? ref;
} }
const fileName =
typeof fileNameOrUri === 'string' ? fileNameOrUri : normalizePath(relative(repoPath, fileNameOrUri.fsPath));
const path = typeof pathOrUri === 'string' ? pathOrUri : normalizePath(relative(repoPath, pathOrUri.fsPath));
const blob = await Git.rev_parse__verify(repoPath, ref, fileName);
const blob = await Git.rev_parse__verify(repoPath, ref, path);
if (blob == null) return GitRevision.deletedOrMissing; if (blob == null) return GitRevision.deletedOrMissing;
let promise: Promise<string | void | undefined> = Git.log__find_object( let promise: Promise<string | void | undefined> = Git.log__find_object(
@ -3498,7 +3485,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
blob, blob,
ref, ref,
this.container.config.advanced.commitOrdering, this.container.config.advanced.commitOrdering,
fileName,
path,
); );
if (options?.timeout != null) { if (options?.timeout != null) {
promise = Promise.race([promise, Functions.wait(options.timeout)]); promise = Promise.race([promise, Functions.wait(options.timeout)]);

+ 1
- 13
src/git/gitProvider.ts View File

@ -366,19 +366,7 @@ export interface GitProvider {
resolveReference( resolveReference(
repoPath: string, repoPath: string,
ref: string, ref: string,
fileName?: string,
options?: { timeout?: number | undefined },
): Promise<string>;
resolveReference(
repoPath: string,
ref: string,
uri?: Uri,
options?: { timeout?: number | undefined },
): Promise<string>;
resolveReference(
repoPath: string,
ref: string,
fileNameOrUri?: string | Uri,
pathOrUri?: string | Uri,
options?: { timeout?: number | undefined }, options?: { timeout?: number | undefined },
): Promise<string>; ): Promise<string>;
validateBranchOrTagName(repoPath: string, ref: string): Promise<boolean>; validateBranchOrTagName(repoPath: string, ref: string): Promise<boolean>;

+ 4
- 4
src/git/gitProviderService.ts View File

@ -1784,7 +1784,7 @@ export class GitProviderService implements Disposable {
async resolveReference( async resolveReference(
repoPath: string, repoPath: string,
ref: string, ref: string,
fileName?: string,
path?: string,
options?: { timeout?: number }, options?: { timeout?: number },
): Promise<string>; ): Promise<string>;
async resolveReference(repoPath: string, ref: string, uri?: Uri, options?: { timeout?: number }): Promise<string>; async resolveReference(repoPath: string, ref: string, uri?: Uri, options?: { timeout?: number }): Promise<string>;
@ -1792,15 +1792,15 @@ export class GitProviderService implements Disposable {
async resolveReference( async resolveReference(
repoPath: string | Uri, repoPath: string | Uri,
ref: string, ref: string,
fileNameOrUri?: string | Uri,
pathOrUri?: string | Uri,
options?: { timeout?: number }, options?: { timeout?: number },
) { ) {
if (ref == null || ref.length === 0 || ref === GitRevision.deletedOrMissing || GitRevision.isUncommitted(ref)) {
if (!ref || ref === GitRevision.deletedOrMissing || GitRevision.isUncommitted(ref)) {
return ref; return ref;
} }
const { provider, path } = this.getProvider(repoPath); const { provider, path } = this.getProvider(repoPath);
return provider.resolveReference(path, ref, fileNameOrUri, options);
return provider.resolveReference(path, ref, pathOrUri, options);
} }
@log() @log()

Loading…
Cancel
Save