UNPKG

code-suggester

Version:
59 lines (58 loc) 2.78 kB
import { Changes, FileData } from '../types'; interface GitFileData { path: string; fileData: FileData; } /** * Get the absolute path of a relative path * @param {string} dir the wildcard directory containing git change, not necessarily the root git directory * @returns {string} the absolute path relative to the path that the user executed the bash command in */ export declare function resolvePath(dir: string): string; /** * Get the git root directory. * Errors if the directory provided is not a git directory. * @param {string} dir an absolute directory * @returns {string} the absolute path of the git directory root */ export declare function findRepoRoot(dir: string): string; /** * Get the GitHub mode, file content, and relative path asynchronously * Rejects if there is a git diff error, or if the file contents could not be loaded. * @param {string} gitRootDir the root of the local GitHub repository * @param {string} gitDiffPattern A single file diff. Renames and copies are broken up into separate diffs. See https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-git-diff-filesltpatterngt82308203 for more details * @returns {Promise<GitFileData>} the current mode, the relative path of the file in the Git Repository, and the file status. */ export declare function getGitFileData(gitRootDir: string, gitDiffPattern: string): Promise<GitFileData>; /** * Get all the diffs using `git diff` of a git directory. * Errors if the git directory provided is not a git directory. * @param {string} gitRootDir a git directory * @returns {string[]} a list of git diffs */ export declare function getAllDiffs(gitRootDir: string): string[]; /** * Get the git changes of the current project asynchronously. * Rejects if any of the files fails to load (if not deleted), * or if there is a git diff parse error * @param {string[]} diffs the git diff raw output (which only shows relative paths) * @param {string} gitDir the root of the local GitHub repository * @returns {Promise<Changes>} the changeset */ export declare function parseChanges(diffs: string[], gitDir: string): Promise<Changes>; /** * Load the change set asynchronously. * @param dir the directory containing git changes * @returns {Promise<Changes>} the change set */ export declare function getChanges(dir: string): Promise<Changes>; /** * Get the git changes of the current project asynchronously. * Rejects if any of the files fails to load (if not deleted), * or if there is a git diff parse error * @param {string[]} diffs the git diff raw output (which only shows relative paths) * @param {string} gitDir the root of the local GitHub repository * @returns {string} the diff */ export declare function getDiffString(dir: string): string; export {};