UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

130 lines • 6.15 kB
import type { CommitFacts } from './format.ts'; import { type Repo } from './repo.ts'; import type { GitObject } from './types.ts'; export declare const COMMIT = "commit"; export declare const TREE = "tree"; export declare const TAG = "tag"; export declare const OBJECT = "object"; /** * Resolve a revision to a commit id, ancestry suffixes included. * * isomorphic-git resolves refs, full ids and unambiguous short ids, and peels a * tag; it knows nothing about `~` and `^`, which are applied here on top of * whatever its own parser returns. * * A `^{}` or `^{commit}` peel asks for exactly what this returns and is * honoured; a peel naming any other type is a revision this caller cannot use, * so it is refused rather than quietly stripped. * * @param repo repository to resolve against * @param revision revision as the user spelled it */ export declare function resolveCommit(repo: Repo, revision: string): Promise<string>; /** * Every ref git's rev-parse rules find for a name, in rule order: more than one * is a name git calls ambiguous, and the first is the one it reads. * * @param table every ref, as loadRefs reads them * @param name the name as typed */ export declare function refsNamed(table: { has(name: string): boolean; }, name: string): string[]; /** * Put git's `refname is ambiguous` warning on the repository's list when two * refs answer to a name, as git does each time it reads one. * * @param repo the opened repository * @param name the name as typed */ export declare function noteAmbiguity(repo: Repo, name: string): Promise<void>; /** * What an object stands for once every tag wrapper is off. * * An annotated tag can point at another one, so this is a walk rather than a * single hop. Anything that is no tag is already what it stands for and comes * back untouched. * * Every reading that wants a particular kind of object goes through this: a * bare id names the tag itself, so a caller asking for a tree-ish or for the * tree behind `<rev>:<path>` has one to take off, and git takes it off in both * places. * * @param repo the opened repository * @param found the object to unwrap * @param revision the whole revision, for error attribution */ export declare function unwrapped(repo: Repo, found: GitObject, revision: string): Promise<GitObject>; /** * The tag object a name or id denotes, null when it names no tag. * * Read before the stem is resolved, and only for `^{tag}`: every other peel type * sits at or below the commit, so unwrapping an annotated tag on the way is * git's own rule and costs nothing, while `^{tag}` is the one spelling that has * to stop above it. Resolving the stem the ordinary way cannot serve it, because * the commit-ish reading peels the tag before anything else sees it. * * Both spellings a tag answers to are tried, the ref and a raw id, and anything * that is not a tag object reads as no tag: a lightweight tag names a commit * directly, which is why git refuses `^{tag}` on one. */ export declare function tagObject(repo: Repo, stem: string): Promise<GitObject | null>; /** * Both ends of a range operand, or null when it names one revision. * * A lone `..` is a path to git, and mirage limits nothing by path, so it is no * range here and fails as the revision it is not. An end that does not resolve * fails naming the whole operand, as git's message does. * * @param repo repository to resolve against * @param revision the operand as the user spelled it * @returns the left end, the right end and whether the range is symmetric */ export declare function rangeCommits(repo: Repo, revision: string): Promise<[CommitFacts, CommitFacts, boolean] | null>; /** * The common ancestors of two commits that nothing shared descends from. * * git-merge-base(1)'s best common ancestors: a common ancestor is better than * any of its own ancestors, and the bases are the common ancestors nothing is * better than. The other side is a hypothetical merge of `other` and `others`. * A newest-first climb spreads each side's reach down from its tips and stops * where both sides meet: everything beneath a meeting is common and worse, so a * second walk marks it for the climb to drop. A separate ancestry pass removes * redundant candidates without relying on commit timestamps. History shared by * every candidate cannot remove any of them. Bases come out newest first, equal * dates in the order the climb met them (pinned against `git merge-base --all` * 2.50.1). * * @param repo repository holding the commits * @param one one side * @param other the other side * @param others further tips of the hypothetical merged side */ export declare function mergeBases(repo: Repo, one: CommitFacts, other: CommitFacts, others?: readonly CommitFacts[]): Promise<CommitFacts[]>; /** * The commits a walk starts from and the commits whose history it hides. * * `A..B` walks B and hides A, `A...B` walks both and hides their merge bases, * and `^A` hides A. An end that does not resolve fails naming the whole range, * and a negation that does not resolve is git's "bad revision", as is a negated * range (pinned against git 2.50). * * @param repo repository to resolve against * @param revisions the revision operands as spelled * @returns the commits to walk from and the commits to hide */ export declare function splitRevisions(repo: Repo, revisions: readonly string[]): Promise<[CommitFacts[], CommitFacts[]]>; /** * The object a revision names, whatever type it turns out to be. * * The whole grammar a caller that wants an object rather than a commit has to * read: `HEAD:a.txt` is the blob at a path, `HEAD^{tree}` is a commit's tree, * `v1^{}` is what a tag points at, and a bare id of any type is itself. A * commit-ish is tried first because that is what the operand is normally spelled * with, and it is the only reading that understands ancestry. * * @param repo repository to resolve against * @param revision revision as the user spelled it */ export declare function resolveObject(repo: Repo, revision: string): Promise<GitObject>; //# sourceMappingURL=revparse.d.ts.map