@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
75 lines • 3.55 kB
TypeScript
import { type FieldValue, type RefContext, type RefField, type RefItem } from './types.ts';
/** The fewest hex digits an abbreviated id keeps, whatever width is asked. */
export declare const MINIMUM_ABBREV = 4;
/**
* A decimal integer as a C `int` reads it: leading white space and a sign
* allowed, nothing after the digits, nothing past 32 bits.
*/
export declare function cInt(text: string): number | null;
/**
* A count as a C `unsigned` reads it, a minus refused: past 31 bits it comes
* back negative, as the `int` it is stored in reads.
*/
export declare function cUint(text: string): number | null;
/**
* Read one field as a format's `%(...)` or a sort key spells it.
*
* @throws GitError a name git does not have, or an argument it refuses
* @throws UnsupportedFieldError a field git has that this build does not render
*/
export declare function parseField(text: string): RefField;
/** Whether a field reads the ref's object, not only its name. */
export declare function needsObject(f: RefField): boolean;
/**
* The shortest name that still reads back as `name`. Each way of spelling a
* short name, most specific first, gives a candidate; one is taken when no
* other way (`strict`), or no way rev-parse tries before it (loose), turns it
* into another ref that exists.
*/
export declare function shortenRef(name: string, known: ReadonlySet<string>, strict?: boolean): string;
/**
* `name` less `count` components from the front; a negative count keeps that
* many from the back instead.
*/
export declare function lstripRef(name: string, count: number): string;
/**
* `name` less `count` components from the back; a negative count keeps that
* many from the front instead.
*/
export declare function rstripRef(name: string, count: number): string;
/**
* The instant and offset an identity line records: the seconds since the
* epoch and the offset in minutes east of UTC, null when the line has no date
* after its email. The date follows the email's `>` and a space: seconds, then
* an optional `+hhmm` offset.
*/
export declare function identDate(ident: string): [number, number] | null;
/**
* Split a message as the message fields read it: where the subject starts,
* the subject, where the body starts and where the signature starts. The
* subject is the first paragraph after any empty lines, its lines joined with
* spaces (a carriage return before each newline dropped); the body starts at
* the next line that is not empty. A signature cuts both short where its line
* starts.
*/
export declare function messageParts(message: string): [number, string, number, number];
/**
* A subject as a file name: letters, digits, `.` and `_` kept, each run of
* anything else one `-` between them, a run of dots one dot, and trailing dots
* and dashes dropped.
*/
export declare function sanitizeSubject(subject: string): string;
/**
* The ids a listing abbreviates, each at the narrowest width any of its fields
* asks, for one pass that widens them to be unique.
*/
export declare function abbreviationRequests(fields: readonly RefField[], items: readonly RefItem[], ctx: RefContext): Map<string, number>;
/**
* What one field prints for one ref, and what it sorts by.
*
* @throws GitError a date style git does not have, met on a date
*/
export declare function fieldValue(f: RefField, item: RefItem, ctx: RefContext): FieldValue;
/** Whether a listing reads the mailmap. */
export declare function mailmapped(fields: readonly RefField[]): boolean;
//# sourceMappingURL=ref_fields.d.ts.map