Coverage / src/oxy.ts 62.0%
310 of 500 lines run, 65 of 75 functions, 82 of 96 branches · run #22 on main · run missed
| 1 | 0× | // The oxy process wrapper: one function per command the extension uses, |
| 2 | 0× | // all through `oxy --plain --json` (spec §4). This module never imports |
| 3 | 0× | // the vscode API so it can be tested with plain Node. |
| 4 | 1× | |
| 5 | 1× | import { execFile } from "node:child_process"; |
| 6 | 1× | import { SigningInfo, parseIdentityShow } from "./commitbox"; |
| 7 | 1× | import { existsSync } from "node:fs"; |
| 8 | 1× | import { homedir } from "node:os"; |
| 9 | 1× | import { join } from "node:path"; |
| 10 | 1× | |
| 11 | 1× | export interface RunResult { |
| 12 | 1× | code: number; |
| 13 | 1× | stdout: Buffer; |
| 14 | 1× | stderr: string; |
| 15 | 1× | } |
| 16 | 1× | |
| 17 | 1× | export class OxyError extends Error { |
| 18 | 1× | constructor( |
| 19 | 3× | public readonly args: string[], |
| 20 | 3× | public readonly code: number, |
| 21 | 3× | public readonly stderr: string, |
| 22 | 3× | ) { |
| 23 | 3× | super(stderr.trim() || `oxy ${args.join(" ")} exited with status ${code}`); |
| 24 | 3× | this.name = "OxyError"; |
| 25 | 3× | } |
| 26 | 0× | } |
| 27 | 0× | |
| 28 | 0× | /** Where to find `oxy`: the configured path, else `oxy` on PATH, else ~/.local/bin/oxy. */ |
| 29 | 0× | export function findBinary(configured: string | undefined): string { |
| 30 | 0× | if (configured && configured.trim()) { |
| 31 | 0× | return configured.trim(); |
| 32 | 0× | } |
| 33 | 0× | const local = join(homedir(), ".local", "bin", "oxy"); |
| 34 | 0× | return existsSync(local) ? local : "oxy"; |
| 35 | 0× | } |
| 36 | 1× | |
| 37 | 1× | export type Logger = (line: string) => void; |
| 38 | 1× | |
| 39 | 1× | export class Oxy { |
| 40 | 1× | constructor( |
| 41 | 1× | public readonly binary: string, |
| 42 | 1× | private readonly logger: Logger = () => {}, |
| 43 | 1× | ) {} |
| 44 | 1× | |
| 45 | 1× | /** Run oxy in `cwd`; resolves with the exit status, never rejects on a non-zero status. */ |
| 46 | 1× | run(cwd: string, args: string[]): Promise<RunResult> { |
| 47 | 82× | const started = Date.now(); |
| 48 | 82× | const full = ["--plain", ...args]; |
| 49 | 82× | return new Promise((resolve, reject) => { |
| 50 | 82× | execFile( |
| 51 | 82× | this.binary, |
| 52 | 82× | full, |
| 53 | 82× | { cwd, maxBuffer: 256 * 1024 * 1024, encoding: "buffer", env: { ...process.env, NO_COLOR: "1" } }, |
| 54 | 82× | (error, stdout, stderr) => { |
| 55 | 82× | const err = stderr.toString("utf8"); |
| 56 | 82× | const code = error && typeof (error as NodeJS.ErrnoException).code === "number" ? ((error as NodeJS.ErrnoException).code as unknown as number) : error ? -1 : 0; |
| 57 | 82× | this.logger(`oxy ${args.join(" ")} (${cwd}) → ${code} in ${Date.now() - started} ms${err.trim() ? `: ${err.trim()}` : ""}`); |
| 58 | 82× | if (error && (error as NodeJS.ErrnoException).code === "ENOENT") { |
| 59 | 0× | reject(new OxyError(full, -1, `oxy not found at ${this.binary}`)); |
| 60 | 0× | return; |
| 61 | 0× | } |
| 62 | 82× | resolve({ code, stdout: stdout as Buffer, stderr: err }); |
| 63 | 82× | }, |
| 64 | 82× | ); |
| 65 | 82× | }); |
| 66 | 82× | } |
| 67 | 1× | |
| 68 | 1× | /** Run and require success (exit 0, or one of `okCodes`). */ |
| 69 | 1× | async check(cwd: string, args: string[], okCodes: number[] = [0]): Promise<RunResult> { |
| 70 | 79× | const r = await this.run(cwd, args); |
| 71 | 79× | if (!okCodes.includes(r.code)) { |
| 72 | 3× | throw new OxyError(args, r.code, r.stderr); |
| 73 | 3× | } |
| 74 | 79× | return r; |
| 75 | 79× | } |
| 76 | 1× | |
| 77 | 1× | async json<T>(cwd: string, args: string[], okCodes: number[] = [0]): Promise<T> { |
| 78 | 39× | const r = await this.check(cwd, [...args, "--json"], okCodes); |
| 79 | 39× | const text = r.stdout.toString("utf8").trim(); |
| 80 | 39× | try { |
| 81 | 39× | return JSON.parse(text) as T; |
| 82 | 39× | } catch (e) { |
| 83 | 0× | throw new OxyError(args, r.code, `oxy ${args.join(" ")} did not print JSON: ${text.slice(0, 200)}`); |
| 84 | 0× | } |
| 85 | 39× | } |
| 86 | 1× | |
| 87 | 1× | // ---------------------------------------------------------------- commands |
| 88 | 1× | |
| 89 | 1× | async version(): Promise<VersionInfo> { |
| 90 | 1× | return this.json<VersionInfo>(process.cwd(), ["version"]); |
| 91 | 1× | } |
| 92 | 1× | |
| 93 | 1× | /** The repository containing `cwd`, or null when there is none. */ |
| 94 | 1× | async root(cwd: string): Promise<RootInfo | null> { |
| 95 | 2× | const r = await this.run(cwd, ["root", "--json"]); |
| 96 | 2× | if (r.code !== 0) { |
| 97 | 1× | return null; |
| 98 | 1× | } |
| 99 | 1× | const v = JSON.parse(r.stdout.toString("utf8")); |
| 100 | 2× | return v === null ? null : (v as RootInfo); |
| 101 | 2× | } |
| 102 | 1× | |
| 103 | 1× | status(root: string): Promise<StatusInfo> { |
| 104 | 6× | return this.json<StatusInfo>(root, ["status"], [0, 2]); |
| 105 | 6× | } |
| 106 | 1× | |
| 107 | 1× | async prompt(root: string, format?: string): Promise<string> { |
| 108 | 1× | const args = ["prompt", "--glyphs"]; |
| 109 | 1× | if (format) { |
| 110 | 0× | args.push("--format", format); |
| 111 | 0× | } |
| 112 | 1× | const r = await this.run(root, args); |
| 113 | 1× | return r.code === 0 ? r.stdout.toString("utf8").trim() : ""; |
| 114 | 1× | } |
| 115 | 1× | |
| 116 | 1× | /** File content at a state; `change` may be a hash prefix, id prefix, bookmark, or tag. */ |
| 117 | 1× | async cat(root: string, path: string, change?: string): Promise<Buffer> { |
| 118 | 5× | const args = ["cat", path]; |
| 119 | 5× | if (change) { |
| 120 | 0× | args.push("-r", change); |
| 121 | 0× | } |
| 122 | 5× | return (await this.check(root, args)).stdout; |
| 123 | 5× | } |
| 124 | 1× | |
| 125 | 1× | log(root: string, limit?: number, path?: string): Promise<LogInfo> { |
| 126 | 10× | const args = ["log"]; |
| 127 | 10× | if (limit !== undefined) { |
| 128 | 10× | args.push("-n", String(limit)); |
| 129 | 10× | } |
| 130 | 10× | if (path) { |
| 131 | 1× | args.push("--path", path); |
| 132 | 1× | } |
| 133 | 10× | return this.json<LogInfo>(root, args); |
| 134 | 10× | } |
| 135 | 1× | |
| 136 | 1× | commit(root: string, message: string, paths: string[] = []): Promise<void> { |
| 137 | 7× | return this.check(root, ["commit", "-m", message, ...paths]).then(() => undefined); |
| 138 | 7× | } |
| 139 | 1× | |
| 140 | 1× | bookmarks(root: string): Promise<BookmarkInfo[]> { |
| 141 | 4× | return this.json<BookmarkInfo[]>(root, ["bookmark", "list"]); |
| 142 | 4× | } |
| 143 | 1× | |
| 144 | 1× | /** Restore paths to the working copy's base. */ |
| 145 | 1× | discard(root: string, paths: string[]): Promise<void> { |
| 146 | 1× | return this.check(root, ["discard", ...paths]).then(() => undefined); |
| 147 | 1× | } |
| 148 | 1× | |
| 149 | 1× | discardHunks(root: string, hunks: number[]): Promise<void> { |
| 150 | 0× | return this.check(root, ["discard", "--hunks", hunks.join(",")]).then(() => undefined); |
| 151 | 0× | } |
| 152 | 1× | |
| 153 | 1× | hunks(root: string): Promise<HunkInfo[]> { |
| 154 | 1× | return this.json<HunkInfo[]>(root, ["hunks"]); |
| 155 | 1× | } |
| 156 | 1× | |
| 157 | 1× | commitHunks(root: string, message: string, hunks: number[]): Promise<void> { |
| 158 | 1× | return this.check(root, ["commit", "-m", message, "--hunks", hunks.join(",")]).then(() => undefined); |
| 159 | 1× | } |
| 160 | 1× | |
| 161 | 1× | amend(root: string, message?: string): Promise<void> { |
| 162 | 1× | const args = ["amend"]; |
| 163 | 1× | if (message) { |
| 164 | 1× | args.push("-m", message); |
| 165 | 1× | } |
| 166 | 1× | return this.check(root, args).then(() => undefined); |
| 167 | 1× | } |
| 168 | 1× | |
| 169 | 1× | undo(root: string): Promise<string> { |
| 170 | 2× | return this.check(root, ["undo"]).then((r) => r.stdout.toString("utf8").trim()); |
| 171 | 2× | } |
| 172 | 1× | |
| 173 | 1× | opLog(root: string): Promise<OperationInfo[]> { |
| 174 | 1× | return this.json<OperationInfo[]>(root, ["op", "log"]); |
| 175 | 1× | } |
| 176 | 1× | |
| 177 | 1× | // ---------------------------------------------------------------- bookmarks |
| 178 | 1× | |
| 179 | 1× | bookmarkCreate(root: string, name: string, changes: string[] = []): Promise<void> { |
| 180 | 1× | return this.check(root, ["bookmark", "create", name, ...changes]).then(() => undefined); |
| 181 | 1× | } |
| 182 | 1× | |
| 183 | 1× | bookmarkSwitch(root: string, name: string, discard = false): Promise<void> { |
| 184 | 3× | const args = ["bookmark", "switch", name]; |
| 185 | 3× | if (discard) { |
| 186 | 0× | args.push("--discard"); |
| 187 | 0× | } |
| 188 | 3× | return this.check(root, args).then(() => undefined); |
| 189 | 3× | } |
| 190 | 1× | |
| 191 | 1× | bookmarkDelete(root: string, name: string): Promise<void> { |
| 192 | 1× | return this.check(root, ["bookmark", "delete", name]).then(() => undefined); |
| 193 | 1× | } |
| 194 | 1× | |
| 195 | 1× | merge(root: string, name: string): Promise<string> { |
| 196 | 1× | return this.check(root, ["merge", name]).then((r) => r.stdout.toString("utf8").trim()); |
| 197 | 1× | } |
| 198 | 1× | |
| 199 | 1× | // ---------------------------------------------------------------- remotes and sync |
| 200 | 1× | |
| 201 | 1× | remotes(root: string): Promise<RemoteInfo[]> { |
| 202 | 1× | return this.json<RemoteInfo[]>(root, ["remote", "list"]); |
| 203 | 1× | } |
| 204 | 1× | |
| 205 | 1× | fetch(root: string, remote?: string): Promise<FetchInfo> { |
| 206 | 1× | return this.json<FetchInfo>(root, ["fetch", ...(remote ? [remote] : [])]); |
| 207 | 1× | } |
| 208 | 1× | |
| 209 | 1× | pull(root: string, remote?: string): Promise<PullInfo> { |
| 210 | 1× | return this.json<PullInfo>(root, ["pull", ...(remote ? [remote] : [])]); |
| 211 | 1× | } |
| 212 | 1× | |
| 213 | 1× | push(root: string, remote?: string, bookmark?: string, force = false): Promise<PushResult[]> { |
| 214 | 3× | const args = ["push", ...(remote ? [remote] : [])]; |
| 215 | 3× | if (bookmark) { |
| 216 | 1× | args.push("-b", bookmark); |
| 217 | 1× | } |
| 218 | 3× | if (force) { |
| 219 | 0× | args.push("--force"); |
| 220 | 0× | } |
| 221 | 3× | return this.json<PushResult[]>(root, args, [0, 1]); |
| 222 | 3× | } |
| 223 | 1× | |
| 224 | 1× | clone(cwd: string, url: string, dest: string): Promise<void> { |
| 225 | 1× | return this.check(cwd, ["clone", url, dest]).then(() => undefined); |
| 226 | 1× | } |
| 227 | 1× | |
| 228 | 1× | // ---------------------------------------------------------------- history and blame |
| 229 | 1× | |
| 230 | 1× | blame(root: string, path: string): Promise<BlameLine[]> { |
| 231 | 1× | return this.json<BlameLine[]>(root, ["blame", path]); |
| 232 | 1× | } |
| 233 | 1× | |
| 234 | 1× | show(root: string, change: string): Promise<ShowInfo> { |
| 235 | 2× | return this.json<ShowInfo>(root, ["show", change]); |
| 236 | 2× | } |
| 237 | 1× | |
| 238 | 1× | /** The rendered diff of a change (or the working copy), as `oxy diff` prints it. */ |
| 239 | 1× | diffText(root: string, change?: string): Promise<string> { |
| 240 | 1× | return this.check(root, ["diff", ...(change ? [change] : [])]).then((r) => r.stdout.toString("utf8")); |
| 241 | 1× | } |
| 242 | 1× | |
| 243 | 1× | describe(root: string, change: string, message: string): Promise<void> { |
| 244 | 0× | return this.check(root, ["describe", change, "-m", message]).then(() => undefined); |
| 245 | 0× | } |
| 246 | 1× | |
| 247 | 1× | abandon(root: string, change: string): Promise<string> { |
| 248 | 0× | return this.check(root, ["abandon", change]).then((r) => r.stdout.toString("utf8").trim()); |
| 249 | 0× | } |
| 250 | 1× | |
| 251 | 1× | /** The configured identity and how commits are signed; `null` without one. */ |
| 252 | 1× | identity(root: string): Promise<SigningInfo | null> { |
| 253 | 2× | return this.check(root, ["identity", "show"]).then((r) => parseIdentityShow(r.stdout.toString("utf8"))); |
| 254 | 2× | } |
| 255 | 1× | |
| 256 | 1× | /** Split a head: the edits to `paths` become a separate first change. Returns oxy's summary line. */ |
| 257 | 1× | split(root: string, change: string, paths: string[]): Promise<string> { |
| 258 | 1× | return this.check(root, ["split", change, ...paths]).then((r) => r.stdout.toString("utf8").trim()); |
| 259 | 1× | } |
| 260 | 1× | |
| 261 | 1× | /** Fold `change` into its dependency `into`, which keeps its ChangeId. */ |
| 262 | 1× | squash(root: string, change: string, into: string): Promise<string> { |
| 263 | 1× | return this.check(root, ["squash", change, "--into", into]).then((r) => r.stdout.toString("utf8").trim()); |
| 264 | 1× | } |
| 265 | 1× | |
| 266 | 1× | /** Re-express `change` against the state of `onto` (changes, a bookmark or a tag). */ |
| 267 | 1× | rebase(root: string, change: string, onto: string[]): Promise<string> { |
| 268 | 1× | return this.check(root, ["rebase", change, "--onto", ...onto]).then((r) => r.stdout.toString("utf8").trim()); |
| 269 | 1× | } |
| 270 | 1× | |
| 271 | 1× | checkout(root: string, changes: string[], discard = false): Promise<void> { |
| 272 | 0× | return this.check(root, ["checkout", ...changes, ...(discard ? ["--discard"] : [])]).then(() => undefined); |
| 273 | 0× | } |
| 274 | 1× | |
| 275 | 1× | tagCreate(root: string, name: string, changes: string[] = [], message = ""): Promise<void> { |
| 276 | 1× | return this.check(root, ["tag", "create", name, ...changes, "-m", message]).then(() => undefined); |
| 277 | 1× | } |
| 278 | 1× | |
| 279 | 1× | // ---------------------------------------------------------------- subrepos, bisect, trust, tags, workspaces |
| 280 | 1× | |
| 281 | 1× | submodules(root: string): Promise<SubrepoInfo[]> { |
| 282 | 1× | return this.json<SubrepoInfo[]>(root, ["submodule", "status"]); |
| 283 | 1× | } |
| 284 | 1× | |
| 285 | 1× | submoduleUpdate(root: string, init: boolean, paths: string[] = []): Promise<string> { |
| 286 | 0× | return this.check(root, ["submodule", "update", ...(init ? ["--init"] : []), ...paths], [0, 1]).then((r) => r.stdout.toString("utf8")); |
| 287 | 0× | } |
| 288 | 1× | |
| 289 | 1× | bisectStatus(root: string): Promise<BisectStatus | null> { |
| 290 | 2× | return this.json<BisectStatus | null>(root, ["bisect", "status"]); |
| 291 | 2× | } |
| 292 | 1× | |
| 293 | 1× | bisectStart(root: string): Promise<void> { |
| 294 | 1× | return this.check(root, ["bisect", "start"]).then(() => undefined); |
| 295 | 1× | } |
| 296 | 1× | |
| 297 | 1× | bisectMark(root: string, verdict: "good" | "bad" | "skip", changes: string[] = []): Promise<string> { |
| 298 | 0× | return this.check(root, ["bisect", verdict, ...changes]).then((r) => r.stdout.toString("utf8").trim()); |
| 299 | 0× | } |
| 300 | 1× | |
| 301 | 1× | bisectRun(root: string, command: string[]): Promise<string> { |
| 302 | 0× | return this.check(root, ["bisect", "run", ...command], [0, 1]).then((r) => r.stdout.toString("utf8").trim()); |
| 303 | 0× | } |
| 304 | 1× | |
| 305 | 1× | bisectReset(root: string): Promise<void> { |
| 306 | 1× | return this.check(root, ["bisect", "reset"]).then(() => undefined); |
| 307 | 1× | } |
| 308 | 1× | |
| 309 | 1× | policyShow(root: string): Promise<PolicyInfo | null> { |
| 310 | 1× | return this.json<PolicyInfo | null>(root, ["policy", "show"]); |
| 311 | 1× | } |
| 312 | 1× | |
| 313 | 1× | verify(root: string, change?: string): Promise<VerifyInfo[]> { |
| 314 | 1× | return this.json<VerifyInfo[]>(root, ["verify", ...(change ? [change] : [])], [0, 1]); |
| 315 | 1× | } |
| 316 | 1× | |
| 317 | 1× | tags(root: string): Promise<TagInfo[]> { |
| 318 | 1× | return this.json<TagInfo[]>(root, ["tag", "list"]); |
| 319 | 1× | } |
| 320 | 1× | |
| 321 | 1× | workspaces(root: string): Promise<WorkspaceInfo[]> { |
| 322 | 1× | return this.json<WorkspaceInfo[]>(root, ["workspace", "list"]); |
| 323 | 1× | } |
| 324 | 1× | |
| 325 | 1× | workspaceAdd(root: string, path: string, changes: string[] = []): Promise<void> { |
| 326 | 0× | return this.check(root, ["workspace", "add", path, ...changes]).then(() => undefined); |
| 327 | 0× | } |
| 328 | 1× | } |
| 329 | 1× | |
| 330 | 0× | export interface SubrepoInfo { |
| 331 | 0× | path: string; |
| 332 | 0× | pin: PinInfo; |
| 333 | 0× | actual: PinInfo | null; |
| 334 | 0× | at_pin: boolean; |
| 335 | 0× | dirty: boolean; |
| 336 | 0× | url: string | null; |
| 337 | 0× | } |
| 338 | 1× | |
| 339 | 0× | export type PinInfo = { kind: "oxy"; repo: string; heads: string[]; bookmark: string } | { kind: "git"; sha: string; branch: string }; |
| 340 | 1× | |
| 341 | 0× | export type BisectStatus = |
| 342 | 0× | | { state: "need-marks"; good: number; bad: number } |
| 343 | 0× | | { state: "testing"; heads: string[]; remaining: number; steps_left: number } |
| 344 | 0× | | { state: "found"; culprit: string } |
| 345 | 0× | | { state: "inconclusive"; candidates: string[] }; |
| 346 | 1× | |
| 347 | 0× | export interface PolicyInfo { |
| 348 | 0× | hash: string; |
| 349 | 0× | serial: number; |
| 350 | 0× | expires_ms: number; |
| 351 | 0× | expired: boolean; |
| 352 | 0× | root_threshold: number; |
| 353 | 0× | roots: { key: string; name: string; email: string }[]; |
| 354 | 0× | rules: { pattern: string; keys: { key: string; name: string; email: string }[]; threshold: number; require: string; allow_conflicts: boolean }[]; |
| 355 | 0× | revoked: { key: string; name: string; email: string }[]; |
| 356 | 0× | } |
| 357 | 1× | |
| 358 | 0× | export interface VerifyInfo { |
| 359 | 0× | hash: string; |
| 360 | 0× | change_id: string; |
| 361 | 0× | status: string; |
| 362 | 0× | key: string | null; |
| 363 | 0× | name: string | null; |
| 364 | 0× | revoked: boolean; |
| 365 | 0× | reason: string | null; |
| 366 | 0× | } |
| 367 | 1× | |
| 368 | 0× | export interface TagInfo { |
| 369 | 0× | name: string; |
| 370 | 0× | state: string; |
| 371 | 0× | heads: string[]; |
| 372 | 0× | message: string; |
| 373 | 0× | signer: string | null; |
| 374 | 0× | } |
| 375 | 1× | |
| 376 | 0× | export interface WorkspaceInfo { |
| 377 | 0× | id: string; |
| 378 | 0× | path: string; |
| 379 | 0× | current: boolean; |
| 380 | 0× | working_copy: string | null; |
| 381 | 0× | } |
| 382 | 1× | |
| 383 | 0× | export interface BlameLine { |
| 384 | 0× | line: number; |
| 385 | 0× | change_id: string; |
| 386 | 0× | hash: string; |
| 387 | 0× | index: number; |
| 388 | 0× | author: string; |
| 389 | 0× | when_ms: number; |
| 390 | 0× | } |
| 391 | 1× | |
| 392 | 0× | export interface ShowInfo extends LogEntry { |
| 393 | 0× | files: { path: string; kind: string; from: string | null }[]; |
| 394 | 0× | } |
| 395 | 1× | |
| 396 | 0× | export interface RemoteInfo { |
| 397 | 0× | name: string; |
| 398 | 0× | url: string; |
| 399 | 0× | /** The CA file `remote.NAME.ca` names (a self-signed hub), if any. */ |
| 400 | 0× | ca?: string | null; |
| 401 | 0× | bookmarks: { name: string; heads: string[] }[]; |
| 402 | 0× | } |
| 403 | 1× | |
| 404 | 0× | export interface FetchInfo { |
| 405 | 0× | remote: string; |
| 406 | 0× | refs: { name: string; heads: string[]; new: number }[]; |
| 407 | 0× | new_tags: number; |
| 408 | 0× | unverified: boolean; |
| 409 | 0× | } |
| 410 | 1× | |
| 411 | 0× | export interface PullInfo { |
| 412 | 0× | remote: string; |
| 413 | 0× | heads: string[]; |
| 414 | 0× | changed: boolean; |
| 415 | 0× | checked_out: boolean; |
| 416 | 0× | conflicted: boolean; |
| 417 | 0× | } |
| 418 | 1× | |
| 419 | 0× | export interface PushResult { |
| 420 | 0× | name: string; |
| 421 | 0× | ok: boolean; |
| 422 | 0× | reason: string; |
| 423 | 0× | } |
| 424 | 1× | |
| 425 | 0× | export interface HunkInfo { |
| 426 | 0× | index: number; |
| 427 | 0× | path: string; |
| 428 | 0× | text: string; |
| 429 | 0× | } |
| 430 | 1× | |
| 431 | 0× | export interface OperationInfo { |
| 432 | 0× | id: string; |
| 433 | 0× | when_ms: number; |
| 434 | 0× | command: string; |
| 435 | 0× | snapshot: boolean; |
| 436 | 0× | current: boolean; |
| 437 | 0× | } |
| 438 | 1× | |
| 439 | 0× | // ---------------------------------------------------------------- types |
| 440 | 1× | |
| 441 | 0× | export interface VersionInfo { |
| 442 | 0× | version: string; |
| 443 | 0× | protocol: number; |
| 444 | 0× | format: number; |
| 445 | 0× | } |
| 446 | 1× | |
| 447 | 0× | export interface RootInfo { |
| 448 | 0× | root: string; |
| 449 | 0× | workspace: string; |
| 450 | 0× | bookmark: string; |
| 451 | 0× | } |
| 452 | 1× | |
| 453 | 0× | export type PathStatus = "Added" | "Modified" | "Removed" | "Renamed" | "ModeChanged" | "ConflictEdited" | "Resolved"; |
| 454 | 1× | |
| 455 | 0× | export interface StatusInfo { |
| 456 | 0× | bookmark: string; |
| 457 | 0× | working_copy: string; |
| 458 | 0× | heads: number; |
| 459 | 0× | clean: boolean; |
| 460 | 0× | conflicted: boolean; |
| 461 | 0× | paths: { path: string; status: PathStatus }[]; |
| 462 | 0× | conflicts: ConflictInfo[]; |
| 463 | 0× | } |
| 464 | 1× | |
| 465 | 0× | export interface ConflictInfo { |
| 466 | 0× | kind: string; |
| 467 | 0× | path?: string; |
| 468 | 0× | node?: string; |
| 469 | 0× | nodes?: string[]; |
| 470 | 0× | changes?: string[]; |
| 471 | 0× | resolved?: boolean | "markers"; |
| 472 | 0× | } |
| 473 | 1× | |
| 474 | 0× | export interface LogEntry { |
| 475 | 0× | hash: string; |
| 476 | 0× | change_id: string; |
| 477 | 0× | author: string; |
| 478 | 0× | author_key: string; |
| 479 | 0× | when_ms: number; |
| 480 | 0× | message: string; |
| 481 | 0× | kind: string; |
| 482 | 0× | deps: string[]; |
| 483 | 0× | head: boolean; |
| 484 | 0× | working_copy: boolean; |
| 485 | 0× | signature: { status: string; key?: string; name?: string; revoked?: boolean; reason?: string } | null; |
| 486 | 0× | } |
| 487 | 1× | |
| 488 | 0× | export interface LogInfo { |
| 489 | 0× | bookmark: string; |
| 490 | 0× | total: number; |
| 491 | 0× | changes: LogEntry[]; |
| 492 | 0× | } |
| 493 | 1× | |
| 494 | 0× | export interface BookmarkInfo { |
| 495 | 0× | name: string; |
| 496 | 0× | heads: string[]; |
| 497 | 0× | current: boolean; |
| 498 | 0× | ahead: number | null; |
| 499 | 0× | behind: number | null; |
| 500 | 0× | } |