@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
67 lines • 4.37 kB
TypeScript
import type { NOOPAccessor } from '../../../../accessor/base.ts';
import { PathSpec } from '../../../../types.ts';
import type { CommandFnResult, Context } from '../../../config.ts';
import { type Repo } from './repo.ts';
import { type TreeEntry } from './tree.ts';
import type { HeadRef, ReadOnlyRefusal, Track } from './types.ts';
import type { Files } from '../../../../workspace/files.ts';
export declare const DETACHED_ADVICE = "You are in 'detached HEAD' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by switching back to a branch.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -c with the switch command. Example:\n\n git switch -c <new-branch-name>\n\nOr undo this operation with:\n\n git switch -\n\nTurn off this advice by setting config variable advice.detachedHead to false\n";
/**
* Make the working tree and index match the tree being switched to.
*
* Only paths the two trees disagree about are touched, so a file that is the
* same on both branches keeps whatever the working tree has, including an
* uncommitted edit, and keeps its index entry, which is what preserves a staged
* change both branches happen to agree about. Every path the trees do disagree
* about has already been refused by the caller if anything uncommitted stands on
* it, so the tree diff is the whole decision here.
*/
export declare function switchTo(repo: Repo, vfs: Files, before: ReadonlyMap<string, TreeEntry>, after: ReadonlyMap<string, TreeEntry>): Promise<string[]>;
/**
* Move HEAD, the index and the working tree to a commit, and say so.
*
* The one procedure `checkout` and `switch` share, since the two differ only in
* what they accept and how they word a miss. Refuses rather than overwriting
* when the move would destroy work that is not committed, whether that is an
* edit to a tracked file, an untracked file the target holds, or a conflict
* still being resolved. Those checks are the whole reason either verb is safe to
* offer: without them a branch switch silently throws away whatever was changed
* and not staged, and there is no reflog here to get it back from.
*
* The paths whose uncommitted change was carried across go to stdout with their
* status letters, then the upstream a branch tracks; a submodule directory the
* move could not remove is a warning on stderr above the line saying where HEAD
* went.
*
* @param vfs the session's files
* @param repo the opened repository
* @param known every ref the repository publishes
* @param head what HEAD pointed at before the move
* @param oid the commit to move to
* @param target the operand as the user spelled it, for the reflog
* @param ref the branch to attach HEAD to, null to detach it at the commit
* @param creating whether `ref` is a new branch to write first
* @param start the start point a new branch is created from, as typed;
* undefined when the line named none
* @param mode `branch.autoSetupMerge`, for a new branch's upstream
* @param advise whether a detached HEAD gets git's advice on the state it is in
* @param quiet `-q`: only the warnings are printed
*/
export declare function moveHead(vfs: Files, repo: Repo, known: ReadonlyMap<string, string>, head: HeadRef, oid: string, target: string, ref: string | null, creating: boolean, start: string | undefined, mode: Track, advise: boolean, quiet: boolean): Promise<CommandFnResult>;
/**
* Switch the working tree to another branch or commit, or put paths back.
*
* Refuses rather than overwriting when the switch would destroy work that is not
* committed; see `moveHead`, which does the moving for `switch` as well. Paths
* after `--`, or operands past a first one that reads as a commit, or a lone
* operand the index holds and no ref names, are put back instead; see
* `checkoutPaths`.
*/
export declare function checkout(_accessor: NOOPAccessor, paths: PathSpec[], texts: string[], ctx: Context): Promise<CommandFnResult>;
/**
* checkout's refusal by a read-only mount. git takes the new branch's ref
* lock first only for a bare `-b NAME`: a start point or `-q` sends it through
* the index first.
*/
export declare const checkoutReadOnly: ReadOnlyRefusal;
//# sourceMappingURL=checkout.d.ts.map