UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

103 lines • 4.98 kB
import { GitError } from './errors.ts'; import { QuoteStyle, type FieldValue, type RefContext, type RefField, type RefFormat, type RefItem, type RefSortKey } from './types.ts'; /** * A format's text between fields: `%%` is a percent sign and `%` with two hex * digits the byte they spell; any other `%` is itself. */ export declare function literalText(text: string): string; /** * Read a `--format` string once for every ref it renders. * * @throws FormatUsageError a `%(` that never closes * @throws GitError a field git refuses, or `%(raw)` under a quoting style * that cannot carry its bytes */ export declare function parseFormat(template: string, quote?: QuoteStyle): RefFormat; /** * `branch`'s and `tag`'s `--format`, which refuse a `%(` that never closes in * two lines rather than with the usage. */ export declare function listingFormat(template: string): RefFormat; /** Every field a listing reads: its format's and its sort keys'. */ export declare function usedFields(fmt: RefFormat | null, keys: readonly RefSortKey[]): readonly RefField[]; /** * The `--sort` keys, the last given first, as git orders them. Each is an * optional `-` (descending), then an optional `version:` or `v:`, then a * field. */ export declare function parseSortKeys(spellings: readonly string[]): RefSortKey[]; /** One field's text quoted for the language a quoting option names. */ export declare function quoteText(text: string, style: QuoteStyle): string; /** * Version order with `versionsort.suffix`. A name holding one of the suffixes * where the two first differ sorts before one holding none, and two holding * different ones sort in the order the suffixes were configured; an empty * suffix in the list places the names holding none. Anything else is * `strverscmp`. Fitted to git 2.47.3 on 40,950 pairs of names. */ export declare function versioncmp(a: string, b: string, suffixes?: readonly string[]): number; /** Each field's value for each ref, read once however often a sort or a row asks. */ export declare class ValueTable { readonly fields: readonly RefField[]; readonly ctx: RefContext; private readonly values; constructor(fields: readonly RefField[], ctx: RefContext); /** * One field's value for one ref. A ref's first read reads every field the * listing uses, so one refused for the ref stops the listing whichever field * was asked for, as git's does. */ value(item: RefItem, f: RefField): FieldValue; private read; } /** How many terminal columns a name takes. */ export declare function displayWidth(text: string): number; /** * The refs in the order the keys give, the first key deciding first; a tie on * every key goes by name, upward whatever the keys' direction. A detached HEAD * leads when `detachedFirst` says so. * * The sort's first comparison of a date with a style (`committerdate:short`), * under whichever key, goes by the refs' instants, and every later one by the * dates as shown, as git's sort does (measured on 504 random ref sets and * eight styles against git 2.47.3 and 2.50.1, and on 1,800 random lists of up * to four keys against 2.50.1). * * @throws GitError a key's field refused for some ref */ export declare function sortRefs(items: readonly RefItem[], keys: readonly RefSortKey[], table: ValueTable, ctx: RefContext, icase: boolean, detachedFirst?: boolean): RefItem[]; /** * One ref through a format: literal text as it is, each field (or each * outermost block) quoted on its own. * * @throws GitError blocks that do not nest, or a field refused for this ref */ export declare function renderRow(fmt: RefFormat, item: RefItem, table: ValueTable): string; /** How a listing writes its rows. */ export interface ListingOptions { /** `--count`, 0 for every ref. */ readonly count?: number; /** `--omit-empty`: no line for an empty row. */ readonly omitEmpty?: boolean; /** `--ignore-case`. */ readonly icase?: boolean; /** A detached HEAD leads. */ readonly detachedFirst?: boolean; /** * Whether the listing may write rows as it renders, which a line naming its * sort, or a commit filter that walks history first, rules out. */ readonly stream?: boolean; } /** * A listing through `--format`, one row per ref. A listing in name order * (`--no-sort`, or the one sort a line gets by default, case-sensitive) writes * each row as it renders, in the order the refs came, so a field refused on a * later ref stops it with the rows before already out; a sorted one renders * every row first and prints none when one is refused. `--count` takes refs, * an omitted empty row among them. * * @returns the rows printed, and the refusal the listing stopped at */ export declare function formatRefs(fmt: RefFormat, items: readonly RefItem[], ctx: RefContext, keys: readonly RefSortKey[] | null, options?: ListingOptions): [string, GitError | null]; //# sourceMappingURL=ref_format.d.ts.map