import { EnzymeExtension } from '../types.js'; /** * Git repository status */ export interface GitStatus { /** Current branch name */ branch: string; /** Is working directory clean */ clean: boolean; /** Staged files */ staged: string[]; /** Modified files */ modified: string[]; /** Untracked files */ untracked: string[]; /** Deleted files */ deleted: string[]; /** Conflicted files */ conflicted: string[]; /** Ahead/behind remote */ ahead: number; behind: number; /** Remote tracking branch */ remote?: string; } /** * Branch information */ export interface BranchInfo { /** Current branch name */ current: string; /** All local branches */ local: string[]; /** All remote branches */ remote: string[]; /** Remote tracking info */ tracking?: { remote: string; branch: string; ahead: number; behind: number; }; /** Is detached HEAD */ detached: boolean; } /** * Git commit information */ export interface GitCommit { /** Commit hash */ hash: string; /** Short hash */ shortHash: string; /** Commit message */ message: string; /** Author name */ author: string; /** Author email */ email: string; /** Commit date */ date: Date; /** Relative time (e.g., "2 hours ago") */ relativeTime: string; /** Changed files count */ filesChanged?: number; /** Insertions count */ insertions?: number; /** Deletions count */ deletions?: number; } /** * Changed file information */ export interface ChangedFile { /** File path */ path: string; /** Change status (M, A, D, R, C, U) */ status: 'M' | 'A' | 'D' | 'R' | 'C' | 'U'; /** Status description */ statusText: string; /** Is staged */ staged: boolean; /** Insertions count */ insertions?: number; /** Deletions count */ deletions?: number; } /** * File diff information */ export interface FileDiff { /** File path */ path: string; /** Diff content */ diff: string; /** Old file path (for renames) */ oldPath?: string; /** Change type */ type: 'add' | 'modify' | 'delete' | 'rename' | 'copy'; /** Hunks (sections of changes) */ hunks: DiffHunk[]; /** Total additions */ additions: number; /** Total deletions */ deletions: number; } /** * Diff hunk (section of changes) */ export interface DiffHunk { /** Old file start line */ oldStart: number; /** Old file line count */ oldLines: number; /** New file start line */ newStart: number; /** New file line count */ newLines: number; /** Hunk header */ header: string; /** Lines in this hunk */ lines: DiffLine[]; } /** * Diff line */ export interface DiffLine { /** Line type (add, delete, context) */ type: '+' | '-' | ' '; /** Line content */ content: string; /** Old line number */ oldLineNumber?: number; /** New line number */ newLineNumber?: number; } /** * Commit options */ export interface CommitOptions { /** Commit message */ message: string; /** Commit description (body) */ description?: string; /** Commit type for conventional commits */ type?: 'feat' | 'fix' | 'docs' | 'style' | 'refactor' | 'perf' | 'test' | 'build' | 'ci' | 'chore'; /** Commit scope */ scope?: string; /** Breaking change indicator */ breaking?: boolean; /** Co-authors */ coAuthors?: string[]; /** Allow empty commit */ allowEmpty?: boolean; /** Skip hooks */ noVerify?: boolean; /** GPG sign */ sign?: boolean; } /** * Git hook type */ export type GitHookType = 'pre-commit' | 'post-commit' | 'pre-push' | 'post-merge' | 'pre-rebase' | 'post-checkout'; /** * Git hook handler */ export type GitHookHandler = (context: GitHookContext) => Promise | boolean | void; /** * Git hook context */ export interface GitHookContext { /** Hook type */ hook: GitHookType; /** Current git status */ status?: GitStatus; /** Changed files (for pre-commit) */ files?: ChangedFile[]; /** Abort the operation */ abort: (reason: string) => void; } /** * Branch protection rule */ export interface BranchProtectionRule { /** Branch pattern (glob) */ pattern: string; /** Allow direct commits */ allowCommits?: boolean; /** Require pull request */ requirePR?: boolean; /** Custom validation */ validate?: (branch: string) => boolean | Promise; /** Error message */ message?: string; } /** * Comprehensive Git Integration Extension * * @example * ```typescript * import { gitExtension } from '@/lib/extensions/built-in/git'; * * // In your app * const enzyme = createEnzyme().$extends(gitExtension); * * // Use git methods * const status = await enzyme.$getGitStatus(); * const commits = await enzyme.$getRecentCommits(20); * await enzyme.$stageFile('src/app.ts'); * await enzyme.$createCommit({ * type: 'feat', * scope: 'ui', * message: 'add dark mode support', * breaking: false, * }); * * // Register hooks * enzyme.$registerGitHook('pre-commit', async (context) => { * // Run linting, tests, etc. * console.log('Pre-commit hook:', context.files?.length, 'files'); * return true; // Allow commit * }); * * // Add branch protection * enzyme.$addBranchProtection({ * pattern: 'release/*', * allowCommits: false, * message: 'Release branches are protected', * }); * ``` */ export declare const gitExtension: EnzymeExtension;