/** * `.gitignore`-aware directory walking for `logosdb_index_file` (issue #101). * * Composes ignore rules the way Git does: * - the root `.gitignore` of the enclosing working tree, * - every nested `.gitignore` discovered during the walk (per-directory scope), * - `.git/info/exclude`, * - the global excludes file (`$XDG_CONFIG_HOME/git/ignore`, falling back to * `~/.config/git/ignore`). * * Pattern semantics are delegated to the `ignore` npm package (Git-compatible: * leading `/`, trailing `/`, `**`, negations with `!`, etc.). * * This module never reaches outside the resolved Git working tree. */ import { type Ignore } from 'ignore'; export interface IgnoreFrame { /** Absolute directory the patterns are scoped to (i.e. the dir holding the `.gitignore`). */ dir: string; ig: Ignore; } export interface GitignoreContext { /** Absolute path to the enclosing Git working tree. */ gitRoot: string; /** Stack of always-active frames (git root + global + info/exclude). */ rootStack: IgnoreFrame[]; } /** Walk parents looking for a `.git` dir/file. Stops at any `stopAt` boundary * (use these to keep discovery inside `process.cwd()` / `LOGOSDB_INDEX_ROOT`). */ export declare function findGitRoot(startDir: string, stopAt?: readonly string[]): string | null; /** Build the always-active ignore stack for a given Git root. * - Global excludes contribute a frame at `gitRoot` (Git treats them as * repo-wide rules; testing them with a path relative to gitRoot is fine). * - Repo `.gitignore` and `.git/info/exclude` likewise scope at gitRoot. */ export declare function buildGitignoreContext(gitRoot: string): GitignoreContext; /** Push a `.gitignore` from `dir` (if any) onto the stack. Returns the same * stack reference when nothing was added, so callers can use identity to * decide whether to allocate a child copy. */ export declare function maybePushLocalGitignore(stack: IgnoreFrame[], dir: string): IgnoreFrame[]; /** Test a path (absolute) against every frame in the stack. * Convention: each frame's `ig` receives the path **relative to that frame**, * with a trailing `/` when it is a directory (Git semantics for `pattern/`). * Cross-frame negations are not honoured (mirrors how globby / `ignore`'s * composed usage already approximates Git for nested files). */ export declare function isIgnoredByStack(stack: readonly IgnoreFrame[], absPath: string, isDir: boolean): boolean; /** Should `logosdb_index_file` apply gitignore filtering by default? * Returns `true` if `LOGOSDB_RESPECT_GITIGNORE` is unset or truthy. */ export declare function respectGitignoreDefault(): boolean; //# sourceMappingURL=gitignore-walker.d.ts.map