From 1c80e549922d0e0c0ae89f32edcf486d246c4cc5 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 6 Feb 2023 18:39:08 -0500 Subject: [PATCH] Moves getOldestUnpushedRefForFile location --- src/env/node/git/localGitProvider.ts | 34 +++++++++++++++++----------------- src/git/gitProvider.ts | 2 +- src/git/gitProviderService.ts | 6 ++++++ src/plus/github/githubGitProvider.ts | 12 ++++++------ 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index d399d87..cffed23 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -2134,23 +2134,6 @@ export class LocalGitProvider implements GitProvider, Disposable { } @log() - async getOldestUnpushedRefForFile(repoPath: string, uri: Uri): Promise { - const [relativePath, root] = splitPath(uri, repoPath); - - const data = await this.git.log__file(root, relativePath, '@{push}..', { - argsOrFormat: ['-z', '--format=%H'], - fileMode: 'none', - ordering: configuration.get('advanced.commitOrdering'), - renames: true, - }); - if (!data) return undefined; - - // -2 to skip the ending null - const index = data.lastIndexOf('\0', data.length - 2); - return index === -1 ? undefined : data.slice(index + 1, data.length - 2); - } - - @log() async getContributors( repoPath: string, options?: { all?: boolean; ref?: string; stats?: boolean }, @@ -3411,6 +3394,23 @@ export class LocalGitProvider implements GitProvider, Disposable { } @log() + async getOldestUnpushedRefForFile(repoPath: string, uri: Uri): Promise { + const [relativePath, root] = splitPath(uri, repoPath); + + const data = await this.git.log__file(root, relativePath, '@{push}..', { + argsOrFormat: ['-z', '--format=%H'], + fileMode: 'none', + ordering: configuration.get('advanced.commitOrdering'), + renames: true, + }); + if (!data) return undefined; + + // -2 to skip the ending null + const index = data.lastIndexOf('\0', data.length - 2); + return index === -1 ? undefined : data.slice(index + 1, data.length - 2); + } + + @log() async getPreviousComparisonUris( repoPath: string, uri: Uri, diff --git a/src/git/gitProvider.ts b/src/git/gitProvider.ts index 17e3ab3..7e7332a 100644 --- a/src/git/gitProvider.ts +++ b/src/git/gitProvider.ts @@ -236,7 +236,6 @@ export interface GitProvider extends Disposable { ref?: string; }, ): Promise; - getOldestUnpushedRefForFile(repoPath: string, uri: Uri): Promise; getContributors( repoPath: string, options?: { all?: boolean | undefined; ref?: string | undefined; stats?: boolean | undefined }, @@ -335,6 +334,7 @@ export interface GitProvider extends Disposable { ref: string | undefined, skip?: number, ): Promise; + getOldestUnpushedRefForFile(repoPath: string, uri: Uri): Promise; getPreviousComparisonUris( repoPath: string, uri: Uri, diff --git a/src/git/gitProviderService.ts b/src/git/gitProviderService.ts index e325040..f525413 100644 --- a/src/git/gitProviderService.ts +++ b/src/git/gitProviderService.ts @@ -1611,6 +1611,12 @@ export class GitProviderService implements Disposable { } @log() + async getOldestUnpushedRefForFile(repoPath: string | Uri, uri: Uri): Promise { + const { provider, path } = this.getProvider(repoPath); + return provider.getOldestUnpushedRefForFile(path, uri); + } + + @log() getPreviousComparisonUris( repoPath: string | Uri, uri: Uri, diff --git a/src/plus/github/githubGitProvider.ts b/src/plus/github/githubGitProvider.ts index fb96727..dfe6c01 100644 --- a/src/plus/github/githubGitProvider.ts +++ b/src/plus/github/githubGitProvider.ts @@ -1371,12 +1371,6 @@ export class GitHubGitProvider implements GitProvider, Disposable { } @log() - async getOldestUnpushedRefForFile(_repoPath: string, _uri: Uri): Promise { - // TODO@eamodio until we have access to the RemoteHub change store there isn't anything we can do here - return undefined; - } - - @log() async getContributors( repoPath: string, _options?: { all?: boolean; ref?: string; stats?: boolean }, @@ -2152,6 +2146,12 @@ export class GitHubGitProvider implements GitProvider, Disposable { } @log() + async getOldestUnpushedRefForFile(_repoPath: string, _uri: Uri): Promise { + // TODO@eamodio until we have access to the RemoteHub change store there isn't anything we can do here + return undefined; + } + + @log() async getPreviousComparisonUris( repoPath: string, uri: Uri,