import { WorkspaceFolder } from 'vscode-languageserver-protocol'; import { URI } from 'vscode-uri'; import { FileResolver } from '../fs'; import { FsClient } from '../fs/fs'; type RepoFileUri = URI; type RepositoryUri = URI; export type RepositoryFile = { uri: RepoFileUri; repositoryUri: RepositoryUri; isIgnored: boolean; workspaceFolder: WorkspaceFolder; }; export type GetFileOptions = { excludeGitFolder?: boolean; excludeIgnored?: boolean; }; export type GitFiles = { ignoreFiles: Map; excludeFile: URI | undefined; trackedFiles: Set; }; /** * Repository represents a git repository. * It is responsible for managing the files in the repository * and the `GitIgnoreManager` to manage the gitignore files. * * It's also used for common git parsing operations, eg * `Repository.isGitIgnoreFile`, `Repository.isGitConfigFile`, etc. * * This class is stateful. * * This is an internal class of the `RepositoryService`. * @see `RepositoryService` * @see `GitIgnoreManager` */ export declare class Repository { #private; readonly workspaceFolder: WorkspaceFolder; /** * The URI of the repository root directory. * Ex: file:///gitlab/work/git/my-repo */ readonly uri: URI; /** * The URI of the repository git config file. * Ex: file:///gitlab/work/git/my-repo/.git/config */ readonly configFileUri: URI; constructor({ fileResolver, configFileUri, workspaceFolder, uri, fsClient, }: { fileResolver: FileResolver; workspaceFolder: WorkspaceFolder; uri: RepositoryUri; configFileUri: URI; fsClient: FsClient; }); /** * Check if the file is ignored by git. * This will match the file against gitignore patterns in the directory structure * and all its parent directories. * * This also checks the .gitignore/exclude file in the root of the git repository. * * If the file is tracked by git, it is not ignored. */ isFileIgnored(filePath: URI): boolean; setFile(fileUri: URI): void; getFile(fileUri: URI, options?: GetFileOptions): RepositoryFile | undefined; removeFile(fileUri: URI): void; getCurrentTreeFiles(options?: GetFileOptions): RepositoryFile[]; getCurrentTrackedFiles(): string[]; /** * Setup the git repository by creating a new `GitIgnoreManager` and adding the gitignore files. * * This will also update the tracked files in the repository. */ setupGitForRepository(files: URI[]): Promise; /** * Refresh the tracked files in the repository. * This is debounced to prevent excessive calls to the git command. */ refreshTrackedFiles(): Promise | undefined; dispose(): void; static getRepoRootFromGitConfig(gitConfigUri: URI): URI; static getRepoGitConfigFile(repoUri: URI): URI; static getGitConfigFiles(files: URI[]): URI[]; static isGitIgnoreFile(file: URI): boolean; static isGitConfigFile(file: URI): boolean; static isInGitFolder(fileUri: URI): boolean; static isGitExcludeFile(file: URI): boolean; } export {};