UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

48 lines • 2.32 kB
import { PosixRegex } from '../../../../rs/regex.ts'; import type { Repo } from './repo.ts'; import type { TreeEntry } from './tree.ts'; /** * A `-S` or `-G` search, which git runs on every file pair a diff compares, once * renames are paired. */ export interface Pickaxe { /** `-S`'s string, or its pattern under `--pickaxe-regex`; null for `-G`. */ readonly needle: string | PosixRegex | null; /** `-G`'s pattern; null for `-S`. */ readonly changed: PosixRegex | null; /** `-i`, which folds a `-S` string's ASCII letters. */ readonly ignoreCase: boolean; /** `--text`: `-G` reads a binary side's lines too. */ readonly forceText: boolean; /** `--pickaxe-all`: one matching pair keeps every pair its comparison found. */ readonly every: boolean; /** The line's abort, which a long pattern search stops at. */ readonly signal?: AbortSignal; } /** * How many times a pattern matches a blob, git's `contains` under * `--pickaxe-regex` and glibc's REG_NEWLINE: a match stays in its line, each * search resumes where the last match ended (a step further after an empty * one), and `^` never holds where it resumes. mirage-rs counts the whole blob * in one request. */ export declare function contains(text: string, pattern: PosixRegex, signal?: AbortSignal): Promise<number>; /** * Whether one file pair passes the pickaxe. * * `-S` is deliberately not a grep: a pair that merely moves a line holding the * string leaves its count alone, so it does not match, and the commit that * *introduced* the string does, which is what makes `-S <name> --reverse` * answer "where did this come from". A missing side holds nothing, so whatever * a new file adds counts as introduced, and each side reads the way `blobData` * reads it, so a gitlink is its `Subproject commit` line, as git's pickaxe sees * it. `-i` counts without regard to ASCII case; a `--pickaxe-regex` pattern * carries its own case folding. * * @param repo repository holding the blobs * @param pickaxe the search * @param old the old side, null when the path is new * @param now the new side, null when the path is gone */ export declare function matches(repo: Repo, pickaxe: Pickaxe, old: TreeEntry | null, now: TreeEntry | null): Promise<boolean>; //# sourceMappingURL=pickaxe.d.ts.map