From 9420d6db66d02620386e6c6bb0d4b699970895a4 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 20 Jan 2022 15:01:28 -0500 Subject: [PATCH] Renames GitTree since its an entry --- src/env/node/git/localGitProvider.ts | 10 +++++----- src/git/fsProvider.ts | 10 +++++----- src/git/gitProvider.ts | 6 +++--- src/git/gitProviderService.ts | 16 ++++++++-------- src/git/models/tree.ts | 2 +- src/git/parsers/treeParser.ts | 6 +++--- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/env/node/git/localGitProvider.ts b/src/env/node/git/localGitProvider.ts index dd43573..fdeea01 100644 --- a/src/env/node/git/localGitProvider.ts +++ b/src/env/node/git/localGitProvider.ts @@ -64,7 +64,7 @@ import { GitStatus, GitStatusFile, GitTag, - GitTree, + GitTreeEntry, GitUser, PullRequest, PullRequestState, @@ -3282,16 +3282,16 @@ export class LocalGitProvider implements GitProvider, Disposable { } @log() - async getTreeFileForRevision(repoPath: string, fileName: string, ref: string): Promise { - if (repoPath == null || fileName == null || fileName.length === 0) return undefined; + async getTreeEntryForRevision(repoPath: string, path: string, ref: string): Promise { + if (repoPath == null || !path) return undefined; - const data = await Git.ls_tree(repoPath, ref, { fileName: fileName }); + const data = await Git.ls_tree(repoPath, ref, { fileName: path }); const trees = GitTreeParser.parse(data); return trees?.length ? trees[0] : undefined; } @log() - async getTreeForRevision(repoPath: string, ref: string): Promise { + async getTreeForRevision(repoPath: string, ref: string): Promise { if (repoPath == null) return []; const data = await Git.ls_tree(repoPath, ref); diff --git a/src/git/fsProvider.ts b/src/git/fsProvider.ts index f4e3173..1651bc7 100644 --- a/src/git/fsProvider.ts +++ b/src/git/fsProvider.ts @@ -16,7 +16,7 @@ import { Container } from '../container'; import { GitUri } from '../git/gitUri'; import { debug, Iterables, TernarySearchTree } from '../system'; import { normalizePath, relative } from '../system/path'; -import { GitRevision, GitTree } from './models'; +import { GitRevision, GitTreeEntry } from './models'; const emptyArray = new Uint8Array(0); @@ -31,7 +31,7 @@ export function toGitLensFSUri(ref: string, repoPath: string): Uri { export class GitFileSystemProvider implements FileSystemProvider, Disposable { private readonly _disposable: Disposable; - private readonly _searchTreeMap = new Map>>(); + private readonly _searchTreeMap = new Map>>(); constructor(private readonly container: Container) { this._disposable = Disposable.from( @@ -69,7 +69,7 @@ export class GitFileSystemProvider implements FileSystemProvider, Disposable { if (tree === undefined) throw FileSystemError.FileNotFound(uri); const items = [ - ...Iterables.map(tree, t => [ + ...Iterables.map(tree, t => [ path != null && path.length !== 0 ? normalizePath(relative(path, t.path)) : t.path, typeToFileType(t.type), ]), @@ -125,7 +125,7 @@ export class GitFileSystemProvider implements FileSystemProvider, Disposable { }; } - treeItem = await this.container.git.getTreeFileForRevision(repoPath, path, ref); + treeItem = await this.container.git.getTreeEntryForRevision(repoPath, path, ref); } if (treeItem === undefined) { @@ -153,7 +153,7 @@ export class GitFileSystemProvider implements FileSystemProvider, Disposable { } private async createSearchTree(ref: string, repoPath: string) { - const searchTree = TernarySearchTree.forPaths(); + const searchTree = TernarySearchTree.forPaths(); const trees = await this.container.git.getTreeForRevision(repoPath, ref); // Add a fake root folder so that searches will work diff --git a/src/git/gitProvider.ts b/src/git/gitProvider.ts index 9014f3f..40f73a8 100644 --- a/src/git/gitProvider.ts +++ b/src/git/gitProvider.ts @@ -24,7 +24,7 @@ import { GitStatus, GitStatusFile, GitTag, - GitTree, + GitTreeEntry, GitUser, Repository, RepositoryChangeEvent, @@ -337,8 +337,8 @@ export interface GitProvider { repoPath: string | undefined, options?: { filter?: ((t: GitTag) => boolean) | undefined; sort?: boolean | TagSortOptions | undefined }, ): Promise>; - getTreeFileForRevision(repoPath: string, fileName: string, ref: string): Promise; - getTreeForRevision(repoPath: string, ref: string): Promise; + getTreeEntryForRevision(repoPath: string, path: string, ref: string): Promise; + getTreeForRevision(repoPath: string, ref: string): Promise; getVersionedFileBuffer(repoPath: string, fileName: string, ref: string): Promise; getVersionedUri(repoPath: string, fileName: string, ref: string | undefined): Promise; getWorkingUri(repoPath: string, uri: Uri): Promise; diff --git a/src/git/gitProviderService.ts b/src/git/gitProviderService.ts index 22f4da6..c0e2a8b 100644 --- a/src/git/gitProviderService.ts +++ b/src/git/gitProviderService.ts @@ -63,7 +63,7 @@ import { GitStatus, GitStatusFile, GitTag, - GitTree, + GitTreeEntry, GitUser, PullRequest, PullRequestDateFormatting, @@ -1655,19 +1655,19 @@ export class GitProviderService implements Disposable { } @log() - async getTreeFileForRevision( + async getTreeEntryForRevision( repoPath: string | Uri | undefined, - fileName: string, + path: string, ref: string, - ): Promise { - if (repoPath == null || fileName == null || fileName.length === 0) return undefined; + ): Promise { + if (repoPath == null || !path) return undefined; - const { provider, path } = this.getProvider(repoPath); - return provider.getTreeFileForRevision(path, fileName, ref); + const { provider, path: rp } = this.getProvider(repoPath); + return provider.getTreeEntryForRevision(rp, path, ref); } @log() - async getTreeForRevision(repoPath: string | Uri | undefined, ref: string): Promise { + async getTreeForRevision(repoPath: string | Uri | undefined, ref: string): Promise { if (repoPath == null) return []; const { provider, path } = this.getProvider(repoPath); diff --git a/src/git/models/tree.ts b/src/git/models/tree.ts index 6504b0f..c68c2fc 100644 --- a/src/git/models/tree.ts +++ b/src/git/models/tree.ts @@ -1,6 +1,6 @@ 'use strict'; -export interface GitTree { +export interface GitTreeEntry { commitSha: string; path: string; size: number; diff --git a/src/git/parsers/treeParser.ts b/src/git/parsers/treeParser.ts index 20492c7..4a5a137 100644 --- a/src/git/parsers/treeParser.ts +++ b/src/git/parsers/treeParser.ts @@ -1,16 +1,16 @@ 'use strict'; import { debug } from '../../system'; -import { GitTree } from '../models'; +import { GitTreeEntry } from '../models'; const emptyStr = ''; const treeRegex = /(?:.+?)\s+(.+?)\s+(.+?)\s+(.+?)\s+(.+)/gm; export class GitTreeParser { @debug({ args: false, singleLine: true }) - static parse(data: string | undefined): GitTree[] | undefined { + static parse(data: string | undefined): GitTreeEntry[] | undefined { if (!data) return undefined; - const trees: GitTree[] = []; + const trees: GitTreeEntry[] = []; let type; let sha;