/** * Git integration utilities for incremental validation. * * @file Provides git operations for detecting changed files and managing validation caching * * @category Utils */ /** * Information about a file change in git. * * @category Utils */ export interface GitFileChange { /** Path to the changed file */ path: string; /** Type of change */ status: "added" | "modified" | "deleted" | "renamed" | "copied"; /** Previous path if renamed */ previousPath?: string; } /** * Git repository information and status. * * @category Utils */ export interface GitStatus { /** Current branch name */ branch: string; /** Current commit hash */ commit: string; /** Whether repository has uncommitted changes */ isDirty: boolean; /** Root directory of the git repository */ rootDir: string; } /** * Git integration utility class. * * Provides methods for detecting file changes, managing git state, and integrating with validation * workflows. * * @category Utils * * @example * Basic usage ```typescript const git = new GitUtils(); * * if (git.isGitRepository()) { const changes = git.getChangedFiles('HEAD~1'); console.log(`Found ${changes.length} changed files`); } ``` * * @example * Pre-commit validation ```typescript const git = new GitUtils(); const stagedFiles = git.getStagedFiles(); const markdownFiles = stagedFiles.filter(f => f.path.endsWith('.md')); ``` */ export declare class GitUtils { private rootDir; private cwd; constructor(cwd?: string); /** * Check if current directory is within a git repository. * * @returns True if in a git repository */ isGitRepository(): boolean; /** * Get git repository root directory. * * @returns Absolute path to git root directory * * @throws Error if not in a git repository */ getRepositoryRoot(): string; /** * Get current git status information. * * @returns Git status information */ getStatus(): GitStatus; /** * Get current branch name. * * @returns Current branch name */ getCurrentBranch(): string; /** * Get current commit hash. * * @returns Current commit hash (full) */ getCurrentCommit(): string; /** * Check if repository has uncommitted changes. * * @returns True if there are uncommitted changes */ hasUncommittedChanges(): boolean; /** * Get files changed between two git references. * * @example * ```typescript // Files changed since last commit const changes = git.getChangedFiles('HEAD~1'); * * // Files changed in current branch vs main const branchChanges = git.getChangedFiles('main', 'HEAD'); ```; * * @param base - Base reference (commit, branch, tag) * @param head - Head reference (defaults to current HEAD) * * @returns Array of changed files */ getChangedFiles(base: string, head?: string): GitFileChange[]; /** * Get currently staged files. * * @returns Array of staged files */ getStagedFiles(): GitFileChange[]; /** * Get files changed in working directory (unstaged). * * @returns Array of unstaged changes */ getUnstagedFiles(): GitFileChange[]; /** * Get list of all tracked files. * * @param pattern - Optional file pattern to filter * * @returns Array of tracked file paths */ getTrackedFiles(pattern?: string): string[]; /** * Check if a specific commit exists. * * @param ref - Git reference to check * * @returns True if reference exists */ refExists(ref: string): boolean; /** * Get the merge base between two references. * * @param ref1 - First reference * @param ref2 - Second reference * * @returns Merge base commit hash */ getMergeBase(ref1: string, ref2: string): string; /** * Get files that have been modified since a specific commit. Includes both staged and unstaged * changes. * * @param since - Commit to compare against * * @returns Array of all modified files */ getAllModifiedFiles(since?: string): GitFileChange[]; /** * Execute a git command and return output. * * @private */ private execGit; /** * Parse git diff output into file change objects. * * @private */ private parseFileChanges; } //# sourceMappingURL=git-utils.d.ts.map