[READ-ONLY] Mirror of https://github.com/SantaClaas/gigit. git client
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135/** * The shapes that cross the IPC boundary. * * Written by hand rather than generated: the surface is small, and a generator * would be another dependency to keep current. The Rust side has a test that * asserts the wire format matches these names, so a drift here fails there. * * @see src-tauri/tests/streaming.rs */
/** The canonical path to a repository's `.git` directory. */export type RepositoryId = string;
export type RefKind = "localBranch" | "remoteBranch" | "tag" | "other";
/** A reference, flattened for rendering. */export type RefEntry = { /** The full name, e.g. `refs/heads/main`. */ name: string; /** The name as a human would write it, e.g. `main`. */ shorthand: string; kind: RefKind; /** `null` for a symbolic ref such as `refs/remotes/origin/HEAD`. */ target: string | null;};
/** * Where HEAD points. Three cases rather than a nullable name, because an * unborn HEAD in a fresh repository and a detached HEAD are both states the UI * has to draw, not errors. */export type Head = | { state: "branch"; name: string; shorthand: string; id: string } | { state: "detached"; id: string } | { state: "unborn"; name: string; shorthand: string };
export type RepositorySummary = { gitDir: string; /** `null` for a bare repository. */ workdir: string | null; isBare: boolean; head: Head;};
export type OpenedRepository = { id: RepositoryId; summary: RepositorySummary;};
/** What a commit looks like on its row. */export type DotKind = "normal" | "merge" | "root";
/** How a line relates to the commit on the row it crosses. */export type EdgeKind = /** Comes down from a child and ends at this commit's dot. */ | "toCommit" /** Leaves this commit's dot heading down towards a parent. */ | "fromCommit" /** Another branch passing by, untouched by this commit. */ | "through";
/** * One line segment crossing a single row. Columns are measured at the row's * edges, so a `through` segment has both the same and draws vertically. */export type Edge = { fromColumn: number; toColumn: number; /** An index into the lane palette, not a colour. */ lane: number; kind: EdgeKind;};
export type RefBadge = { shorthand: string; kind: RefKind; isHead: boolean;};
/** Everything needed to draw one row of the graph. */export type GraphRow = { id: string; /** Position from the top, starting at zero. */ row: number; column: number; /** An index into the lane palette, not a colour. */ lane: number; dot: DotKind; edges: Edge[]; /** How many columns this row spans. */ width: number; summary: string; author: string; /** Committer time, seconds since the epoch. */ time: number; refs: RefBadge[];};
/** A repository that was open at some point. */export type RecentRepository = { id: RepositoryId; /** The working tree, or the git directory for a bare repository. */ path: string; /** The last path segment — what people call a repository. */ name: string; /** Seconds since the epoch. */ lastOpened: number; /** * Whether the path is still there. Recomputed on every read, so a repository * that has been moved or deleted can be shown as missing rather than * silently dropped. */ exists: boolean;};
/** What arrives on a graph stream's channel. */export type GraphEvent = | { event: "rows"; data: { start: number; rows: GraphRow[] } } | { event: "exhausted"; data: { total: number; degraded: boolean } } | { event: "failed"; data: { message: string } };
/** * A command failure. `kind` is stable and safe to branch on; `message` is for * people and may change wording. */export type GigitError = { kind: "git" | "unknownRepository" | "workerStopped" | "spawnThread"; message: string;};
/** Whether a rejected command gave us a structured error. */export function isGigitError(value: unknown): value is GigitError { return typeof value === "object" && value !== null && "kind" in value && "message" in value;}