@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
189 lines • 8.4 kB
TypeScript
import type { FlagView } from '../../../spec/flag_view.ts';
import { type CommitDisplay, type CommitFacts, type Decorations } from './format.ts';
import { type Delta, type Side } from './rows.ts';
import { type Repo } from './repo.ts';
import { type Pickaxe } from './pickaxe.ts';
import { type TreeEntry } from './tree.ts';
export declare const COMBINED_MODE = "mode ";
/** One interpretation of Git diff options, shared by all tree readers. */
export interface DiffFlags {
nameOnly: boolean;
nameStatus: boolean;
stat: boolean;
numstat: boolean;
shortstat: boolean;
summary: boolean;
patch: boolean;
noPatch: boolean;
renames: number | null;
merge: string;
raw: boolean;
abbrev: boolean;
functionContext: boolean;
forceText: boolean;
context: number;
quotePathFully: boolean;
pathspecs: readonly string[];
pickaxe?: Pickaxe | null;
}
export declare function parseDiffFlags(fl: FlagView, defaultPatch?: boolean, defaultMerge?: string, porcelain?: boolean, defaultRenames?: boolean, quotePathFully?: boolean): DiffFlags;
interface Change {
path: string;
oldPath: string;
old: TreeEntry | null;
new: TreeEntry | null;
status: string;
score: number;
}
export declare function compare(repo: Repo, before: ReadonlyMap<string, TreeEntry>, after: ReadonlyMap<string, TreeEntry>, threshold: number | null): Promise<Change[]>;
/**
* Every requested format for one two-tree comparison, in git's order:
* `--name-only` and `--name-status` stand alone; otherwise raw rows come first,
* then numstat, stat and summary, then a blank line and the patch.
*/
export declare function renderChanges(repo: Repo, rows: Change[], flags: DiffFlags): Promise<string>;
/**
* A tree's entries a diff compares, limited to a pathspec.
*
* @param repo repository to read
* @param tree the tree id, null for the empty tree
* @param recursive whether to descend into subtrees
* @param pathspecs repository-relative patterns, all paths when empty
*/
export declare function entries(repo: Repo, tree: string | null, recursive: boolean, pathspecs?: readonly string[]): Promise<Map<string, TreeEntry>>;
/**
* The entries a pathspec names, all of them for none.
*
* Applied before pairing, so a rename is found only where both paths match
* (pinned against git 2.54).
*
* @param found path to entry
* @param pathspecs repository-relative patterns
*/
export declare function limited(found: Map<string, TreeEntry>, pathspecs: readonly string[]): Map<string, TreeEntry>;
/**
* The counts and summary lines `git commit` prints under its title.
*
* `--shortstat --summary` of the change, with renames found at git's default
* score whatever `diff.renames` says, which is how git's commit summary reads
* (pinned against git 2.50).
*
* @param repo repository to read blobs from
* @param before the parent tree
* @param after the new tree
* @param fully `core.quotePath`
*/
export declare function commitSummary(repo: Repo, before: ReadonlyMap<string, TreeEntry>, after: ReadonlyMap<string, TreeEntry>, fully?: boolean): Promise<string>;
/**
* The pairs of one comparison a pickaxe keeps: the ones it matches, or every
* pair under `--pickaxe-all` once one matches, and none when none does.
*
* The search runs on the pairs as renames left them, so a rename that keeps the
* count matches nothing however many times the string occurs (git 2.47.3).
*
* @param repo repository holding the blobs
* @param rows one comparison's pairs
* @param pickaxe the search, null for none
*/
export declare function picked(repo: Repo, rows: Change[], pickaxe: Pickaxe | null | undefined): Promise<Change[]>;
/**
* The comparisons a commit's diff makes, one per parent the merge mode
* compares, each limited to the pathspec.
*
* A root commit compares with the empty tree when `root` says so, and a merge
* under `--diff-merges=off` makes none. Mirrors Python's `commit_sides`.
*
* @param repo repository to read
* @param commit the commit to diff
* @param flags the diff flags
* @param recursive whether to descend into subtrees
* @param root whether a root commit diffs against the empty tree
*/
export declare function commitSides(repo: Repo, commit: CommitFacts, flags: DiffFlags, recursive?: boolean, root?: boolean): Promise<Side[]>;
/**
* Whether a log the pickaxe filters prints a commit.
*
* A commit with one parent or none is printed when the pickaxe keeps a pair of
* its diff. A merge follows the merge diff: never by default, when its first
* parent's diff keeps one under first-parent, when any parent's does under
* `-m`, and always under `-c` and `--cc`, whatever the pickaxe says (git
* 2.47.3).
*
* @param repo repository to read
* @param commit the commit
* @param flags the diff flags, carrying the pickaxe
*/
export declare function shows(repo: Repo, commit: CommitFacts, flags: DiffFlags): Promise<boolean>;
/**
* Every commit's comparisons as rows, and which comparisons are whose.
*
* Made one commit at a time, so only the changed paths of a long log are
* held. Mirrors Python's `commit_deltas`.
*
* @param repo repository to read
* @param commits the commits whose diffs print
* @param flags the diff flags
* @param recursive whether to descend into subtrees
* @param root whether a root commit diffs against the empty tree
*/
export declare function commitDeltas(repo: Repo, commits: readonly CommitFacts[], flags: DiffFlags, recursive?: boolean, root?: boolean): Promise<[Delta[], Map<string, [number, number]>]>;
/**
* Each commit's comparisons, holding only the rows the session sees. Mirrors
* Python's `commit_shown`.
*
* @param shown the rows the command boundary kept
* @param spans which comparisons are whose, as `[start, stop)`
*/
export declare function commitShown(shown: readonly Delta[], spans: ReadonlyMap<string, readonly [number, number]>): Map<string, Side[]>;
/**
* A commit's diff blocks, one per comparison `commitSides` made.
*
* A comparison that does not differ is null, so its header is not printed
* either (pinned against git 2.54).
*
* @param repo repository to read
* @param commit the commit to diff
* @param flags the diff flags
* @param sides its comparisons, as the session sees them
*/
export declare function commitOutput(repo: Repo, commit: CommitFacts, flags: DiffFlags, sides: readonly Side[]): Promise<(string | null)[]>;
export declare function renamesEnabled(repo: Repo): Promise<boolean>;
/**
* Whether a commit's diff is a combined one (`-c`, `--cc`), which only a merge
* gets.
*
* @param commit the commit whose diff follows
* @param flags the diff flags
*/
export declare function isCombined(commit: CommitFacts, flags: DiffFlags): boolean;
/**
* The line git prints between a commit's text and its diff, null for none.
*
* `---` when both a diffstat and a patch follow, otherwise an empty line,
* and none under oneline. A combined diff (`-c`, `--cc`) always gets the
* empty line, oneline included. Pinned against git 2.50.1.
*
* @param commit the commit whose diff follows
* @param kind the pretty format's kind
* @param flags the diff flags
*/
export declare function separatorLine(commit: CommitFacts, kind: string, flags: DiffFlags): string | null;
export declare function joinOutput(commit: CommitFacts, head: string, bodies: readonly (string | null)[], kind: string, width: number, flags: DiffFlags, emptySummary?: boolean): string;
/**
* A commit's log entry and its diff against its parents, as `log` and `show`
* print it. A commit that changes nothing the pathspec names prints nothing at
* all.
*
* @param repo repository to read
* @param commit the commit to show
* @param display the invocation's presentation flags
* @param diff the diff options
* @param sides its comparisons, as the session sees them
* @param decor ref labels when the format asked
* @param emptySummary put a blank line under a header whose diff is empty, as
* `show` does for a summary or a combined diff
* @param parents the parents the header prints, the commit's own when null
*/
export declare function commitEntry(repo: Repo, commit: CommitFacts, display: CommitDisplay, diff: DiffFlags, sides: readonly Side[], decor: Decorations | null, emptySummary?: boolean, parents?: readonly string[] | null): Promise<string>;
export {};
//# sourceMappingURL=diff_output.d.ts.map