OXYGENHUB

Coverage / src/oxy.ts 74.4%

444 of 597 lines run, 79 of 89 functions, 112 of 128 branches · run #26 on main · run missed

10×
// The oxy process wrapper: one function per command the extension uses,
20×
// all through `oxy --plain --json` (spec §4). This module never imports
30×
// the vscode API so it can be tested with plain Node.
41×
51×
import { execFile } from "node:child_process";
61×
import { SigningInfo, parseIdentityShow } from "./commitbox";
71×
import { existsSync } from "node:fs";
81×
import { homedir } from "node:os";
91×
import { join } from "node:path";
101×
111×
export interface RunResult {
121×
  code: number;
131×
  stdout: Buffer;
141×
  stderr: string;
151×
}
161×
171×
export class OxyError extends Error {
181×
  constructor(
196×
    public readonly args: string[],
206×
    public readonly code: number,
216×
    public readonly stderr: string,
226×
  ) {
236×
    super(stderr.trim() || `oxy ${args.join(" ")} exited with status ${code}`);
246×
    this.name = "OxyError";
256×
  }
261×
}
271×
281×
/** Where to find `oxy`: the configured path, else `oxy` on PATH, else ~/.local/bin/oxy. */
291×
export function findBinary(configured: string | undefined): string {
300×
  if (configured && configured.trim()) {
310×
    return configured.trim();
320×
  }
330×
  const local = join(homedir(), ".local", "bin", "oxy");
340×
  return existsSync(local) ? local : "oxy";
350×
}
361×
371×
export type Logger = (line: string) => void;
381×
391×
export class Oxy {
401×
  constructor(
411×
    public readonly binary: string,
421×
    private readonly logger: Logger = () => {},
431×
  ) {}
441×
451×
  /** Run oxy in `cwd`; resolves with the exit status, never rejects on a non-zero status. */
461×
  run(cwd: string, args: string[]): Promise<RunResult> {
47133×
    const started = Date.now();
48133×
    const full = ["--plain", ...args];
49133×
    return new Promise((resolve, reject) => {
50133×
      execFile(
51133×
        this.binary,
52133×
        full,
53133×
        { cwd, maxBuffer: 256 * 1024 * 1024, encoding: "buffer", env: { ...process.env, NO_COLOR: "1" } },
54133×
        (error, stdout, stderr) => {
55133×
          const err = stderr.toString("utf8");
56133×
          const code = error && typeof (error as NodeJS.ErrnoException).code === "number" ? ((error as NodeJS.ErrnoException).code as unknown as number) : error ? -1 : 0;
57133×
          this.logger(`oxy ${args.join(" ")} (${cwd}) → ${code} in ${Date.now() - started} ms${err.trim() ? `: ${err.trim()}` : ""}`);
58133×
          if (error && (error as NodeJS.ErrnoException).code === "ENOENT") {
590×
            reject(new OxyError(full, -1, `oxy not found at ${this.binary}`));
600×
            return;
610×
          }
62133×
          resolve({ code, stdout: stdout as Buffer, stderr: err });
63133×
        },
64133×
      );
65133×
    });
66133×
  }
671×
681×
  /** Run and require success (exit 0, or one of `okCodes`). */
691×
  async check(cwd: string, args: string[], okCodes: number[] = [0]): Promise<RunResult> {
70130×
    const r = await this.run(cwd, args);
71130×
    if (!okCodes.includes(r.code)) {
726×
      throw new OxyError(args, r.code, r.stderr);
736×
    }
74130×
    return r;
75130×
  }
761×
771×
  async json<T>(cwd: string, args: string[], okCodes: number[] = [0]): Promise<T> {
7851×
    const r = await this.check(cwd, [...args, "--json"], okCodes);
7949×
    const text = r.stdout.toString("utf8").trim();
8049×
    try {
8149×
      return JSON.parse(text) as T;
8251×
    } catch (e) {
830×
      throw new OxyError(args, r.code, `oxy ${args.join(" ")} did not print JSON: ${text.slice(0, 200)}`);
840×
    }
8551×
  }
861×
871×
  // ---------------------------------------------------------------- commands
881×
891×
  async version(): Promise<VersionInfo> {
902×
    return this.json<VersionInfo>(process.cwd(), ["version"]);
912×
  }
921×
931×
  /** The repository containing `cwd`, or null when there is none. */
941×
  async root(cwd: string): Promise<RootInfo | null> {
952×
    const r = await this.run(cwd, ["root", "--json"]);
962×
    if (r.code !== 0) {
971×
      return null;
981×
    }
991×
    const v = JSON.parse(r.stdout.toString("utf8"));
1002×
    return v === null ? null : (v as RootInfo);
1012×
  }
1021×
1031×
  status(root: string): Promise<StatusInfo> {
10410×
    return this.json<StatusInfo>(root, ["status"], [0, 2]);
10510×
  }
1061×
1071×
  async prompt(root: string, format?: string): Promise<string> {
1081×
    const args = ["prompt", "--glyphs"];
1091×
    if (format) {
1100×
      args.push("--format", format);
1110×
    }
1121×
    const r = await this.run(root, args);
1131×
    return r.code === 0 ? r.stdout.toString("utf8").trim() : "";
1141×
  }
1151×
1161×
  /** File content at a state; `change` may be a hash prefix, id prefix, bookmark, or tag. */
1171×
  async cat(root: string, path: string, change?: string): Promise<Buffer> {
1188×
    const args = ["cat", path];
1198×
    if (change) {
1201×
      args.push("-r", change);
1211×
    }
1228×
    return (await this.check(root, args)).stdout;
1238×
  }
1241×
1251×
  log(root: string, limit?: number, path?: string): Promise<LogInfo> {
12610×
    const args = ["log"];
12710×
    if (limit !== undefined) {
12810×
      args.push("-n", String(limit));
12910×
    }
13010×
    if (path) {
1311×
      args.push("--path", path);
1321×
    }
13310×
    return this.json<LogInfo>(root, args);
13410×
  }
1351×
1361×
  commit(root: string, message: string, paths: string[] = []): Promise<void> {
13718×
    return this.check(root, ["commit", "-m", message, ...paths]).then(() => undefined);
13818×
  }
1391×
1401×
  /** The local bookmarks; with `all`, remotes' bookmarks with no local one too, named `REMOTE/NAME`. */
1411×
  bookmarks(root: string, all = false): Promise<BookmarkInfo[]> {
1426×
    return this.json<BookmarkInfo[]>(root, ["bookmark", "list", ...(all ? ["--all"] : [])]);
1436×
  }
1441×
1451×
  /** Restore paths to the working copy's base. */
1461×
  discard(root: string, paths: string[]): Promise<void> {
1471×
    return this.check(root, ["discard", ...paths]).then(() => undefined);
1481×
  }
1491×
1501×
  discardHunks(root: string, hunks: number[]): Promise<void> {
1510×
    return this.check(root, ["discard", "--hunks", hunks.join(",")]).then(() => undefined);
1520×
  }
1531×
1541×
  hunks(root: string): Promise<HunkInfo[]> {
1551×
    return this.json<HunkInfo[]>(root, ["hunks"]);
1561×
  }
1571×
1581×
  commitHunks(root: string, message: string, hunks: number[]): Promise<void> {
1591×
    return this.check(root, ["commit", "-m", message, "--hunks", hunks.join(",")]).then(() => undefined);
1601×
  }
1611×
1621×
  /** Fold the working copy into the head it sits on; with `paths`, only those (the rest stays uncommitted). */
1631×
  amend(root: string, message?: string, paths: string[] = []): Promise<void> {
1642×
    const args = ["amend"];
1652×
    if (message) {
1661×
      args.push("-m", message);
1671×
    }
1682×
    return this.check(root, [...args, ...paths]).then(() => undefined);
1692×
  }
1701×
1711×
  undo(root: string): Promise<string> {
1722×
    return this.check(root, ["undo"]).then((r) => r.stdout.toString("utf8").trim());
1732×
  }
1741×
1751×
  opLog(root: string): Promise<OperationInfo[]> {
1761×
    return this.json<OperationInfo[]>(root, ["op", "log"]);
1771×
  }
1781×
1791×
  // ---------------------------------------------------------------- bookmarks
1801×
1811×
  bookmarkCreate(root: string, name: string, changes: string[] = []): Promise<void> {
1824×
    return this.check(root, ["bookmark", "create", name, ...changes]).then(() => undefined);
1834×
  }
1841×
1851×
  bookmarkSwitch(root: string, name: string, discard = false): Promise<void> {
1868×
    const args = ["bookmark", "switch", name];
1878×
    if (discard) {
1880×
      args.push("--discard");
1890×
    }
1908×
    return this.check(root, args).then(() => undefined);
1918×
  }
1921×
1931×
  bookmarkDelete(root: string, name: string): Promise<void> {
1941×
    return this.check(root, ["bookmark", "delete", name]).then(() => undefined);
1951×
  }
1961×
1971×
  /** Union a bookmark's heads into the current one: a local bookmark, or a remote's (`origin/develop`) as last fetched. */
1981×
  merge(root: string, name: string): Promise<string> {
1994×
    return this.check(root, ["merge", name]).then((r) => r.stdout.toString("utf8").trim());
2004×
  }
2011×
2021×
  // ---------------------------------------------------------------- remotes and sync
2031×
2041×
  remotes(root: string): Promise<RemoteInfo[]> {
2051×
    return this.json<RemoteInfo[]>(root, ["remote", "list"]);
2061×
  }
2071×
2081×
  fetch(root: string, remote?: string): Promise<FetchInfo> {
2092×
    return this.json<FetchInfo>(root, ["fetch", ...(remote ? [remote] : [])]);
2102×
  }
2111×
2121×
  pull(root: string, remote?: string): Promise<PullInfo> {
2131×
    return this.json<PullInfo>(root, ["pull", ...(remote ? [remote] : [])]);
2141×
  }
2151×
2161×
  push(root: string, remote?: string, bookmark?: string, force = false): Promise<PushResult[]> {
2173×
    const args = ["push", ...(remote ? [remote] : [])];
2183×
    if (bookmark) {
2191×
      args.push("-b", bookmark);
2201×
    }
2213×
    if (force) {
2220×
      args.push("--force");
2230×
    }
2243×
    return this.json<PushResult[]>(root, args, [0, 1]);
2253×
  }
2261×
2271×
  /** Clone `url` into `dest`; `depth` makes it shallow (0: the latest state only, from the remote's checkpoint). */
2281×
  clone(cwd: string, url: string, dest: string, depth?: number): Promise<void> {
2292×
    return this.check(cwd, ["clone", ...(depth !== undefined ? ["--depth", String(depth)] : []), url, dest]).then(() => undefined);
2302×
  }
2311×
2321×
  // ---------------------------------------------------------------- history and blame
2331×
2341×
  blame(root: string, path: string): Promise<BlameLine[]> {
2351×
    return this.json<BlameLine[]>(root, ["blame", path]);
2361×
  }
2371×
2381×
  show(root: string, change: string): Promise<ShowInfo> {
2392×
    return this.json<ShowInfo>(root, ["show", change]);
2402×
  }
2411×
2421×
  /** The rendered diff of a change (or the working copy), as `oxy diff` prints it. */
2431×
  diffText(root: string, change?: string): Promise<string> {
2441×
    return this.check(root, ["diff", ...(change ? [change] : [])]).then((r) => r.stdout.toString("utf8"));
2451×
  }
2461×
2471×
  describe(root: string, change: string, message: string): Promise<void> {
2480×
    return this.check(root, ["describe", change, "-m", message]).then(() => undefined);
2490×
  }
2501×
2511×
  abandon(root: string, change: string): Promise<string> {
2520×
    return this.check(root, ["abandon", change]).then((r) => r.stdout.toString("utf8").trim());
2530×
  }
2541×
2551×
  /** The configured identity and how commits are signed; `null` without one. */
2561×
  identity(root: string): Promise<SigningInfo | null> {
2572×
    return this.check(root, ["identity", "show"]).then((r) => parseIdentityShow(r.stdout.toString("utf8")));
2582×
  }
2591×
2601×
  /** Split a head: the edits to `paths` become a separate first change. Returns oxy's summary line. */
2611×
  split(root: string, change: string, paths: string[]): Promise<string> {
2621×
    return this.check(root, ["split", change, ...paths]).then((r) => r.stdout.toString("utf8").trim());
2631×
  }
2641×
2651×
  /** Fold `change` into its dependency `into`, which keeps its ChangeId. */
2661×
  squash(root: string, change: string, into: string): Promise<string> {
2671×
    return this.check(root, ["squash", change, "--into", into]).then((r) => r.stdout.toString("utf8").trim());
2681×
  }
2691×
2701×
  /** Re-express `change` against the state of `onto` (changes, a bookmark or a tag). */
2711×
  rebase(root: string, change: string, onto: string[]): Promise<string> {
2721×
    return this.check(root, ["rebase", change, "--onto", ...onto]).then((r) => r.stdout.toString("utf8").trim());
2731×
  }
2741×
2751×
  checkout(root: string, changes: string[], discard = false): Promise<void> {
2760×
    return this.check(root, ["checkout", ...changes, ...(discard ? ["--discard"] : [])]).then(() => undefined);
2770×
  }
2781×
2791×
  tagCreate(root: string, name: string, changes: string[] = [], message = ""): Promise<void> {
2803×
    return this.check(root, ["tag", "create", name, ...changes, "-m", message]).then(() => undefined);
2813×
  }
2821×
2831×
  /**
2841×
   * Withdraw a tag (`oxy tag delete`): a signed withdrawal kept beside the
2851×
   * tag's creation, which push sends on; the name is never used again.
2861×
   * Returns oxy's summary line.
2871×
   */
2881×
  tagWithdraw(root: string, name: string, reason: string): Promise<string> {
2891×
    return this.check(root, ["tag", "delete", name, "-r", reason]).then((r) => r.stdout.toString("utf8").trim().split("\n")[0].replace(/^\* /, ""));
2901×
  }
2911×
2921×
  // ---------------------------------------------------------------- settling conflicts
2931×
2941×
  /**
2951×
   * Settle the replace conflicts (binary files, subrepo pins) at `paths`
2961×
   * with what the working copy holds there (oxygen#140); the next commit
2971×
   * records the resolution. Returns the status after it.
2981×
   */
2991×
  resolvePaths(root: string, paths: string[]): Promise<StatusInfo> {
3002×
    return this.json<StatusInfo>(root, ["resolve", ...paths], [0, 2]);
3012×
  }
3021×
3031×
  /**
3041×
   * Settle adjacent insertions (two changes adding lines at the same place)
3051×
   * by keeping every side, earliest change first, or latest with `reverse`
3061×
   * (oxygen#121). No paths: every conflicted text file. What was kept and
3071×
   * what keeps its markers, and why.
3081×
   */
3091×
  resolveBoth(root: string, paths: string[] = [], reverse = false): Promise<KeptBoth> {
3101×
    return this.check(root, ["resolve", "--both", ...(reverse ? ["--reverse"] : []), ...paths], [0, 2]).then((r) => parseKeptBoth(r.stdout.toString("utf8")));
3111×
  }
3121×
3131×
  // ---------------------------------------------------------------- transparency log
3141×
3151×
  /**
3161×
   * Audit a hub's whole transparency log (`oxy tlog verify`): its checkpoint
3171×
   * against the log key and the last one seen, and every entry against the
3181×
   * root; then this repository's entries. `hub` defaults to the remote.
3191×
   */
3201×
  tlogVerify(root: string, hub?: string): Promise<TlogInfo> {
3211×
    return this.json<TlogInfo>(root, ["tlog", "verify", ...(hub ? [hub] : [])]);
3221×
  }
3231×
3241×
  // ---------------------------------------------------------------- subrepos, bisect, trust, tags, workspaces
3251×
3261×
  submodules(root: string): Promise<SubrepoInfo[]> {
3271×
    return this.json<SubrepoInfo[]>(root, ["submodule", "status"]);
3281×
  }
3291×
3301×
  submoduleUpdate(root: string, init: boolean, paths: string[] = []): Promise<string> {
3310×
    return this.check(root, ["submodule", "update", ...(init ? ["--init"] : []), ...paths], [0, 1]).then((r) => r.stdout.toString("utf8"));
3320×
  }
3331×
3341×
  bisectStatus(root: string): Promise<BisectStatus | null> {
3352×
    return this.json<BisectStatus | null>(root, ["bisect", "status"]);
3362×
  }
3371×
3381×
  bisectStart(root: string): Promise<void> {
3391×
    return this.check(root, ["bisect", "start"]).then(() => undefined);
3401×
  }
3411×
3421×
  bisectMark(root: string, verdict: "good" | "bad" | "skip", changes: string[] = []): Promise<string> {
3430×
    return this.check(root, ["bisect", verdict, ...changes]).then((r) => r.stdout.toString("utf8").trim());
3440×
  }
3451×
3461×
  bisectRun(root: string, command: string[]): Promise<string> {
3470×
    return this.check(root, ["bisect", "run", ...command], [0, 1]).then((r) => r.stdout.toString("utf8").trim());
3480×
  }
3491×
3501×
  bisectReset(root: string): Promise<void> {
3511×
    return this.check(root, ["bisect", "reset"]).then(() => undefined);
3521×
  }
3531×
3541×
  policyShow(root: string): Promise<PolicyInfo | null> {
3551×
    return this.json<PolicyInfo | null>(root, ["policy", "show"]);
3561×
  }
3571×
3581×
  verify(root: string, change?: string): Promise<VerifyInfo[]> {
3591×
    return this.json<VerifyInfo[]>(root, ["verify", ...(change ? [change] : [])], [0, 1]);
3601×
  }
3611×
3621×
  tags(root: string): Promise<TagInfo[]> {
3632×
    return this.json<TagInfo[]>(root, ["tag", "list"]);
3642×
  }
3651×
3661×
  workspaces(root: string): Promise<WorkspaceInfo[]> {
3671×
    return this.json<WorkspaceInfo[]>(root, ["workspace", "list"]);
3681×
  }
3691×
3701×
  workspaceAdd(root: string, path: string, changes: string[] = []): Promise<void> {
3710×
    return this.check(root, ["workspace", "add", path, ...changes]).then(() => undefined);
3720×
  }
3731×
}
3741×
3751×
export interface SubrepoInfo {
3761×
  path: string;
3771×
  pin: PinInfo;
3781×
  actual: PinInfo | null;
3791×
  at_pin: boolean;
3801×
  dirty: boolean;
3811×
  url: string | null;
3821×
}
3831×
3841×
export type PinInfo = { kind: "oxy"; repo: string; heads: string[]; bookmark: string } | { kind: "git"; sha: string; branch: string };
3851×
3861×
export type BisectStatus =
3871×
  | { state: "need-marks"; good: number; bad: number }
3881×
  | { state: "testing"; heads: string[]; remaining: number; steps_left: number }
3891×
  | { state: "found"; culprit: string }
3901×
  | { state: "inconclusive"; candidates: string[] };
3911×
3921×
export interface PolicyInfo {
3931×
  hash: string;
3941×
  serial: number;
3951×
  expires_ms: number;
3961×
  expired: boolean;
3971×
  root_threshold: number;
3981×
  roots: { key: string; name: string; email: string }[];
3991×
  rules: { pattern: string; keys: { key: string; name: string; email: string }[]; threshold: number; require: string; allow_conflicts: boolean }[];
4001×
  revoked: { key: string; name: string; email: string }[];
4011×
}
4021×
4031×
export interface VerifyInfo {
4041×
  hash: string;
4051×
  change_id: string;
4061×
  status: string;
4071×
  key: string | null;
4081×
  name: string | null;
4091×
  revoked: boolean;
4101×
  reason: string | null;
4111×
}
4121×
4131×
/** What `oxy resolve --both` did: the conflicts kept on every side, and those left with markers. */
4141×
export interface KeptBoth {
4151×
  kept: { path: string; conflicts: number[] }[];
4161×
  left: { path: string; conflict: number; why: string }[];
4171×
}
4181×
4191×
/** Read `oxy resolve --both`'s report lines (`kept both  PATH: conflict 1, 2`, `markers    PATH: conflict 3: why`). */
4201×
export function parseKeptBoth(text: string): KeptBoth {
4213×
  const out: KeptBoth = { kept: [], left: [] };
4223×
  for (const line of text.split(/\r?\n/)) {
42312×
    const kept = /^kept both\s+(.+): conflicts? ([\d, ]+)$/.exec(line);
42412×
    if (kept) {
4252×
      out.kept.push({ path: kept[1], conflicts: kept[2].split(",").map((n) => Number(n.trim())).filter((n) => n > 0) });
4262×
      continue;
4272×
    }
42810×
    const left = /^markers\s+(.+): conflict (\d+): (.+)$/.exec(line);
42912×
    if (left) {
4302×
      out.left.push({ path: left[1], conflict: Number(left[2]), why: left[3] });
4312×
    }
43212×
  }
4333×
  return out;
43411×
}
43511×
43611×
/** `oxy tlog verify --json`: the checkpoint verified, who cosigned it, and the entries listed. */
43711×
export interface TlogInfo {
43811×
  hub: string;
43911×
  origin: string;
44011×
  /** Entries in the log the checkpoint covers. */
44111×
  size: number;
44211×
  root: string;
44311×
  witnesses: { name: string; time_ms: number }[];
44411×
  entries: { index: number; kind: string; repo: string; object: string; signers: string[]; received_ms: number }[];
44511×
}
44611×
44711×
/**
44811×
 * A remote's bookmark that `bookmark list --all` adds because there is no
44911×
 * local bookmark of that name: named `REMOTE/NAME`, never current, with no
45011×
 * ahead or behind counts. `oxy merge` takes the name as it is.
45111×
 */
45211×
export function isRemoteBookmark(b: BookmarkInfo): boolean {
45311×
  return !!b.remote && b.name.startsWith(`${b.remote}/`) && !b.current && b.ahead === null && b.behind === null;
4542×
}
4552×
4562×
/** What Merge Bookmark offers: the other local bookmarks first, then remotes' bookmarks. */
4572×
export function mergeChoices(bookmarks: BookmarkInfo[]): { name: string; remote: string | null; heads: number }[] {
4582×
  const local = bookmarks.filter((b) => !b.current && !isRemoteBookmark(b)).map((b) => ({ name: b.name, remote: null, heads: b.heads.length }));
4592×
  const remote = bookmarks.filter(isRemoteBookmark).map((b) => ({ name: b.name, remote: b.remote ?? null, heads: b.heads.length }));
4602×
  return [...local, ...remote];
4612×
}
4621×
4630×
export interface TagInfo {
4640×
  name: string;
4650×
  state: string;
4660×
  heads: string[];
4670×
  message: string;
4680×
  signer: string | null;
4690×
}
4701×
4710×
export interface WorkspaceInfo {
4720×
  id: string;
4730×
  path: string;
4740×
  current: boolean;
4750×
  working_copy: string | null;
4760×
}
4771×
4780×
export interface BlameLine {
4790×
  line: number;
4800×
  change_id: string;
4810×
  hash: string;
4820×
  index: number;
4830×
  author: string;
4840×
  when_ms: number;
4850×
}
4861×
4870×
export interface ShowInfo extends LogEntry {
4880×
  files: { path: string; kind: string; from: string | null }[];
4890×
}
4901×
4910×
export interface RemoteInfo {
4920×
  name: string;
4930×
  url: string;
4940×
  /** The CA file `remote.NAME.ca` names (a self-signed hub), if any. */
4950×
  ca?: string | null;
4960×
  bookmarks: { name: string; heads: string[] }[];
4970×
}
4981×
4990×
export interface FetchInfo {
5000×
  remote: string;
5010×
  refs: { name: string; heads: string[]; new: number }[];
5020×
  new_tags: number;
5030×
  unverified: boolean;
5040×
}
5051×
5060×
export interface PullInfo {
5070×
  remote: string;
5080×
  heads: string[];
5090×
  changed: boolean;
5100×
  checked_out: boolean;
5110×
  conflicted: boolean;
5120×
}
5131×
5140×
export interface PushResult {
5150×
  name: string;
5160×
  ok: boolean;
5170×
  reason: string;
5180×
}
5191×
5200×
export interface HunkInfo {
5210×
  index: number;
5220×
  path: string;
5230×
  text: string;
5240×
}
5251×
5260×
export interface OperationInfo {
5270×
  id: string;
5280×
  when_ms: number;
5290×
  command: string;
5300×
  snapshot: boolean;
5310×
  current: boolean;
5320×
}
5331×
5340×
// ---------------------------------------------------------------- types
5351×
5360×
export interface VersionInfo {
5370×
  version: string;
5380×
  protocol: number;
5390×
  format: number;
5400×
}
5411×
5420×
export interface RootInfo {
5430×
  root: string;
5440×
  workspace: string;
5450×
  bookmark: string;
5460×
}
5471×
5480×
export type PathStatus = "Added" | "Modified" | "Removed" | "Renamed" | "ModeChanged" | "ConflictEdited" | "Resolved";
5491×
5500×
export interface StatusInfo {
5510×
  bookmark: string;
5520×
  working_copy: string;
5530×
  heads: number;
5540×
  clean: boolean;
5550×
  conflicted: boolean;
5560×
  paths: { path: string; status: PathStatus }[];
5570×
  conflicts: ConflictInfo[];
5580×
}
5591×
5600×
export interface ConflictInfo {
5610×
  kind: string;
5620×
  path?: string;
5630×
  node?: string;
5640×
  nodes?: string[];
5650×
  changes?: string[];
5660×
  resolved?: boolean | "markers";
5670×
}
5681×
5690×
export interface LogEntry {
5700×
  hash: string;
5710×
  change_id: string;
5720×
  author: string;
5730×
  author_key: string;
5740×
  when_ms: number;
5750×
  message: string;
5760×
  kind: string;
5770×
  deps: string[];
5780×
  head: boolean;
5790×
  working_copy: boolean;
5800×
  signature: { status: string; key?: string; name?: string; revoked?: boolean; reason?: string } | null;
5810×
}
5821×
5830×
export interface LogInfo {
5840×
  bookmark: string;
5850×
  total: number;
5860×
  changes: LogEntry[];
5870×
}
5881×
5890×
export interface BookmarkInfo {
5900×
  name: string;
5910×
  heads: string[];
5920×
  current: boolean;
5930×
  ahead: number | null;
5940×
  behind: number | null;
5950×
  /** The remote it tracks, or for a remote's bookmark (`--all`) the remote it is on. */
5960×
  remote?: string | null;
5970×
}