Committedtypeno test imports ittype Committed = { readonly commit: string | undefined; readonly paths: readonly Path[] };What a commit came to: the commit (none where nothing had changed) and the paths it took.
A Git working tree as a store: the files below one folder of it, held as the store in a folder holds them, with the folder of Git itself never a path of the store (it is not listed and cannot be named), links and folders never objects, and the commit an explicit operation of its own. A commit takes the paths asked for, or every changed path below the folder, and refuses to go on where something else in the repository has changed (the default), so that it never takes what a person has staged; it never runs a hook unless asked, and it is by the identity the program gives, never by the configuration of a computer.
import { gitWorktreeStore, parseIdentity } from "@intellectual-frontiers/anyfs-git";
const who = parseIdentity("collector", "collector@localhost");
// const opened = who.kind === "ok" && await gitWorktreeStore({ dir: "/srv/fleet", commit: { author: who.value } });
// opened.kind === "ok" && await opened.value.commit({ paths: [path] });Committedtypeno test imports ittype Committed = { readonly commit: string | undefined; readonly paths: readonly Path[] };What a commit came to: the commit (none where nothing had changed) and the paths it took.
CommitRequesttypeno test imports ittype CommitRequest = {
/** The paths to take; every changed path below the folder where none. */
readonly paths?: readonly Path[];
readonly dirty?: DirtyPolicy;
/** Run the hooks of the repository (they are off unless asked). */
readonly hooks?: boolean;
};What a commit is asked.
DirtyPolicytypeno test imports ittype DirtyPolicy = "refuse" | "allow";Whether a commit goes on when something it was not asked to take has changed: it is refused (the default) or the commit takes only what it was asked.
GIT_WORKTREE_CAPABILITIESconstno test imports itconst GIT_WORKTREE_CAPABILITIES: readonly ["read", "write", "list", "stat", "delete", "cas", "rename"]The capabilities of the store of a working tree.
GitWorktreetypeno test imports ittype GitWorktree = {
readonly store: GitWorktreeStore;
/** The top of the working tree. */
readonly dir: string;
… (431 characters)type GitWorktree = {
readonly store: GitWorktreeStore;
/** The top of the working tree. */
readonly dir: string;
/** Every changed path of the repository: staged, not staged and not tracked. */
status(): Promise<Result<readonly TreeChange[], WorktreeProblem>>;
/** Commits the paths asked for, or every changed path below the folder. */
commit(request?: CommitRequest): Promise<Result<Committed, WorktreeProblem>>;
};A store of a working tree, with what Git adds.
GitWorktreeOptionstypeno test imports ittype GitWorktreeOptions = {
/** The working tree (or any folder of it); an absolute path. */
readonly dir: string;
… (496 characters)type GitWorktreeOptions = {
/** The working tree (or any folder of it); an absolute path. */
readonly dir: string;
/** The folder of the working tree the store is of (the top where none). */
readonly prefix?: Prefix;
/** Who a commit is by, and what it says. */
readonly commit: CommitOptions;
/** Refuse a path another file system could not hold (the default). */
readonly portable?: boolean;
/** The program that runs Git (`git` where none). */
readonly program?: string;
};What the store of a working tree is made with.
GitWorktreeStoretypeno test imports ittype GitWorktreeStore = Store<(typeof GIT_WORKTREE_CAPABILITIES)[number]>;The type of the store of a working tree.
gitWorktreeStorefunctionfunction gitWorktreeStore(options: GitWorktreeOptions): Promise<Result<GitWorktree, string>>The working tree as a store, or why there is none.
TreeChangetypeno test imports ittype TreeChange = { readonly path: string; readonly status: string };A change of the working tree: the path in the repository and what Git says of it.
WorktreeProblemtypeno test imports ittype WorktreeProblem =
| { readonly kind: "dirty"; readonly paths: readonly string[] }
| { readonly kind: "outside"; readonly path: string }
| { readonly kind: "git"; readonly message: string };Why a commit was not made: a closed union.