@osdlc/typed-git 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/async.d.ts CHANGED
@@ -2,14 +2,13 @@
2
2
  * `AsyncGit` — the awaitable client, bound to one working directory and one
3
3
  * {@link GitBackend}.
4
4
  *
5
- * The sync `Git` surface, promised, with one difference: what performs the
6
- * work is a backend rather than a runner. The default backend shells out to
7
- * `git`; any other implementation of {@link GitBackend} — a pure-JavaScript
8
- * git, a remote service, a recorded fixture — drives the same client
9
- * unchanged. Each method mirrors its {@link Git} twin, rejecting where that
10
- * one throws.
5
+ * The same methods as the sync `Git`, returning promises. One difference: a
6
+ * backend does the work, not a runner. The default backend runs the `git`
7
+ * CLI. Any other {@link GitBackend}, such as a pure-JavaScript git, a remote
8
+ * service or a recorded fixture, works with the same client. Each method
9
+ * matches its {@link Git} counterpart and rejects where that one throws.
11
10
  *
12
- * Which repository is a backend concern here:
11
+ * Here the repository is set on the backend:
13
12
  * `new AsyncGit(cwd, { backend: cliBackend({ gitDir }) })`, where the sync
14
13
  * client takes `gitDir` on its own constructor.
15
14
  */
@@ -41,7 +40,7 @@ export declare class AsyncGit {
41
40
  /** The same client rooted at a different directory (same backend). */
42
41
  at(cwd: string): AsyncGit;
43
42
  /**
44
- * The whole surface again, resolving to a `Result<T, GitFailure>` instead of
43
+ * Every method again, resolving to a `Result<T, GitFailure>` instead of
45
44
  * rejecting. A declared absence is `ok: true`; see `./outcome.ts`.
46
45
  *
47
46
  * The type leaves out `raw`, `rawChecked` and `at`, but at runtime the proxy
@@ -50,27 +49,27 @@ export declare class AsyncGit {
50
49
  */
51
50
  get try(): TriedAsync<AsyncGit>;
52
51
  /**
53
- * The tolerant door: each verb with an absence value (`null`, `[]` or
54
- * `false`) returns that value when git fails instead of throwing. For
55
- * callers that treat "could not ask" the same as "nothing there" —
56
- * `git.soft.resolveRef(x)` is `null` for a missing ref and for a broken
57
- * repo alike. Use `try` when the failure itself matters.
52
+ * Each verb with an absence value (`null`, `[]` or `false`) resolves to that
53
+ * value when git fails, instead of rejecting. It is for callers that treat
54
+ * "could not ask" the same as "nothing there": `git.soft.resolveRef(x)` is
55
+ * `null` both for a missing ref and for a broken repo. Use `try` when the
56
+ * failure itself matters.
58
57
  *
59
58
  * As with `try`, the proxy also wraps `raw`, `rawChecked` and `at` at
60
59
  * runtime, though the type leaves them out.
61
60
  */
62
61
  get soft(): Soft<AsyncGit>;
63
62
  /**
64
- * Unchecked argv passthrough. Only a CLI-shaped backend can serve this;
65
- * others reject with `UnsupportedRequest`.
63
+ * Runs any git argv without checking the exit code. Only a CLI backend can
64
+ * run this. Others reject with `UnsupportedRequest`.
66
65
  */
67
66
  raw(argv: string[], opts?: GitCallOptions & {
68
67
  input?: string | undefined;
69
68
  }): Promise<CommandResult>;
70
69
  /**
71
- * Checked argv passthrough — rejects with the classified failure on a non-zero
72
- * exit, and on output cut short at the output cap or a timeout. Report
73
- * `e.detail`, which joins both streams; see {@link Git.rawChecked}.
70
+ * Runs any git argv and rejects with the classified failure on a non-zero
71
+ * exit, or on output cut short at the output cap or a timeout. Report
72
+ * `e.failure.detail`, which holds both streams. See {@link Git.rawChecked}.
74
73
  */
75
74
  rawChecked(argv: string[], opts?: GitCallOptions & {
76
75
  input?: string | undefined;
@@ -241,11 +240,11 @@ export declare class AsyncGit {
241
240
  add(paths: string[], opts?: GitCallOptions & AddOptions): Promise<void>;
242
241
  /**
243
242
  * Commit with an inline message, a message file or a stdin message (exactly
244
- * one). A failing hook rejects; git writes hook output to stdout, which
245
- * `e.detail` reads.
243
+ * one). A failing hook rejects. git writes hook output to stdout, which
244
+ * `e.failure.detail` includes.
246
245
  */
247
246
  commit(opts: GitCallOptions & CommitOptions): Promise<void>;
248
- /** `git config <key> <value>` — the twin of {@link AsyncGit.configGet}. */
247
+ /** `git config <key> <value>`, the write counterpart of {@link AsyncGit.configGet}. */
249
248
  configSet(key: string, value: string, opts?: GitCallOptions & ConfigSetOptions): Promise<void>;
250
249
  /** `git init [path]`; `path` defaults to this client's `cwd`. */
251
250
  init(path?: string | undefined, opts?: GitCallOptions & InitOptions): Promise<void>;
@@ -308,8 +307,8 @@ export declare class AsyncGit {
308
307
  rebaseContinue(opts?: GitCallOptions): Promise<RebaseOutcome>;
309
308
  /**
310
309
  * What merging `theirs` into `ours` would do — no index, no checkout, no
311
- * worktree. The cheap way to ask "would this conflict, and where", and the
312
- * merged `tree` it returns is real enough to build a commit from.
310
+ * worktree. It is the cheap way to ask "would this conflict, and where". The
311
+ * merged `tree` it returns is a real object you can build a commit from.
313
312
  */
314
313
  mergeTree(ours: string, theirs: string, opts?: MergeTreeOptions & GitCallOptions): Promise<MergeTreeOutcome>;
315
314
  /** `git ls-files -u`, parsed — the stage detail behind each conflict. */
package/dist/async.js CHANGED
@@ -2,14 +2,13 @@
2
2
  * `AsyncGit` — the awaitable client, bound to one working directory and one
3
3
  * {@link GitBackend}.
4
4
  *
5
- * The sync `Git` surface, promised, with one difference: what performs the
6
- * work is a backend rather than a runner. The default backend shells out to
7
- * `git`; any other implementation of {@link GitBackend} — a pure-JavaScript
8
- * git, a remote service, a recorded fixture — drives the same client
9
- * unchanged. Each method mirrors its {@link Git} twin, rejecting where that
10
- * one throws.
5
+ * The same methods as the sync `Git`, returning promises. One difference: a
6
+ * backend does the work, not a runner. The default backend runs the `git`
7
+ * CLI. Any other {@link GitBackend}, such as a pure-JavaScript git, a remote
8
+ * service or a recorded fixture, works with the same client. Each method
9
+ * matches its {@link Git} counterpart and rejects where that one throws.
11
10
  *
12
- * Which repository is a backend concern here:
11
+ * Here the repository is set on the backend:
13
12
  * `new AsyncGit(cwd, { backend: cliBackend({ gitDir }) })`, where the sync
14
13
  * client takes `gitDir` on its own constructor.
15
14
  */
@@ -57,7 +56,7 @@ export class AsyncGit {
57
56
  return new AsyncGit(cwd, { backend: this.backend });
58
57
  }
59
58
  /**
60
- * The whole surface again, resolving to a `Result<T, GitFailure>` instead of
59
+ * Every method again, resolving to a `Result<T, GitFailure>` instead of
61
60
  * rejecting. A declared absence is `ok: true`; see `./outcome.ts`.
62
61
  *
63
62
  * The type leaves out `raw`, `rawChecked` and `at`, but at runtime the proxy
@@ -68,11 +67,11 @@ export class AsyncGit {
68
67
  return (this.tried ??= triedAsync(this));
69
68
  }
70
69
  /**
71
- * The tolerant door: each verb with an absence value (`null`, `[]` or
72
- * `false`) returns that value when git fails instead of throwing. For
73
- * callers that treat "could not ask" the same as "nothing there" —
74
- * `git.soft.resolveRef(x)` is `null` for a missing ref and for a broken
75
- * repo alike. Use `try` when the failure itself matters.
70
+ * Each verb with an absence value (`null`, `[]` or `false`) resolves to that
71
+ * value when git fails, instead of rejecting. It is for callers that treat
72
+ * "could not ask" the same as "nothing there": `git.soft.resolveRef(x)` is
73
+ * `null` both for a missing ref and for a broken repo. Use `try` when the
74
+ * failure itself matters.
76
75
  *
77
76
  * As with `try`, the proxy also wraps `raw`, `rawChecked` and `at` at
78
77
  * runtime, though the type leaves them out.
@@ -83,16 +82,16 @@ export class AsyncGit {
83
82
  }
84
83
  // ── escape hatch ──────────────────────────────────────────────────────────
85
84
  /**
86
- * Unchecked argv passthrough. Only a CLI-shaped backend can serve this;
87
- * others reject with `UnsupportedRequest`.
85
+ * Runs any git argv without checking the exit code. Only a CLI backend can
86
+ * run this. Others reject with `UnsupportedRequest`.
88
87
  */
89
88
  raw(argv, opts = {}) {
90
89
  return this.backend.execute(this.cwd, { kind: 'raw', argv, input: opts.input }, opts);
91
90
  }
92
91
  /**
93
- * Checked argv passthrough — rejects with the classified failure on a non-zero
94
- * exit, and on output cut short at the output cap or a timeout. Report
95
- * `e.detail`, which joins both streams; see {@link Git.rawChecked}.
92
+ * Runs any git argv and rejects with the classified failure on a non-zero
93
+ * exit, or on output cut short at the output cap or a timeout. Report
94
+ * `e.failure.detail`, which holds both streams. See {@link Git.rawChecked}.
96
95
  */
97
96
  rawChecked(argv, opts = {}) {
98
97
  return this.backend.execute(this.cwd, { kind: 'raw', argv, checked: true, input: opts.input }, opts);
@@ -397,14 +396,14 @@ export class AsyncGit {
397
396
  }
398
397
  /**
399
398
  * Commit with an inline message, a message file or a stdin message (exactly
400
- * one). A failing hook rejects; git writes hook output to stdout, which
401
- * `e.detail` reads.
399
+ * one). A failing hook rejects. git writes hook output to stdout, which
400
+ * `e.failure.detail` includes.
402
401
  */
403
402
  commit(opts) {
404
403
  const [call, req] = splitCallOptions(opts);
405
404
  return this.backend.execute(this.cwd, { kind: 'commit', ...req }, call);
406
405
  }
407
- /** `git config <key> <value>` — the twin of {@link AsyncGit.configGet}. */
406
+ /** `git config <key> <value>`, the write counterpart of {@link AsyncGit.configGet}. */
408
407
  configSet(key, value, opts = {}) {
409
408
  const [call, req] = splitCallOptions(opts);
410
409
  return this.backend.execute(this.cwd, { kind: 'configSet', key, value, ...req }, call);
@@ -507,8 +506,8 @@ export class AsyncGit {
507
506
  }
508
507
  /**
509
508
  * What merging `theirs` into `ours` would do — no index, no checkout, no
510
- * worktree. The cheap way to ask "would this conflict, and where", and the
511
- * merged `tree` it returns is real enough to build a commit from.
509
+ * worktree. It is the cheap way to ask "would this conflict, and where". The
510
+ * merged `tree` it returns is a real object you can build a commit from.
512
511
  */
513
512
  mergeTree(ours, theirs, opts = {}) {
514
513
  const [call, req] = splitCallOptions(opts);
package/dist/backend.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  /**
2
- * The backend seam — what `AsyncGit` talks to, and the thing you swap when
3
- * git should not come from a subprocess.
2
+ * The backend interface: what `AsyncGit` calls, and what you replace when git
3
+ * should not run as a subprocess.
4
4
  *
5
- * A backend takes a {@link GitRequest} — a plain, serializable description of
6
- * one git operation — and returns its typed result. That is deliberately not
7
- * argv: argv is a CLI detail, and a backend built on a pure-JavaScript git
8
- * implementation has no argv to receive. Describing the operation instead of
9
- * the invocation is what lets the same client drive either.
5
+ * A backend takes a {@link GitRequest}, a plain, serializable description of
6
+ * one git operation, and returns its typed result. The request is not argv on
7
+ * purpose. argv is a CLI detail, and a backend built on a pure-JavaScript git
8
+ * has no argv to receive. Describing the operation, not the command line, lets
9
+ * the same client work with either.
10
10
  *
11
- * It also means a request can be logged, queued, or replayed as data. The one
12
- * request that cannot cross that line is `raw`, which is argv by definition; a
13
- * non-CLI backend rejects it with {@link UnsupportedRequest}.
11
+ * It also means a request can be logged, queued, or replayed as data. The
12
+ * exception is `raw`, which is argv by definition. A non-CLI backend rejects
13
+ * it with {@link UnsupportedRequest}.
14
14
  *
15
- * The seam is experimental: `GitBackend`, `GitRequest`, `GitResults` and
15
+ * The interface is experimental: `GitBackend`, `GitRequest`, `GitResults` and
16
16
  * `partialBackend`. Each new verb adds a request kind, which breaks a backend
17
17
  * written as an exhaustive switch. Such a change can land in a minor release.
18
18
  * `cliBackend` and `AsyncGit` are stable.
@@ -22,24 +22,24 @@ import { type AddOptions, type AheadBehind, type CheckoutOptions, type CloneOpti
22
22
  /** Per-call concerns that are not part of the operation itself. */
23
23
  export interface GitCallOptions {
24
24
  /**
25
- * Hard cap on the call; a backend that cannot enforce one may ignore it.
26
- * Without it there is no cap, and the default async runner has no output
25
+ * Time limit for the call. A backend that cannot enforce one may ignore it.
26
+ * Without it there is no limit, and the default async runner has no output
27
27
  * cap either. An invalid value throws (sync) or rejects (async), as in command-seam:
28
28
  * `RangeError` for 0, a negative value or `NaN`; `TypeError` for a
29
29
  * non-number.
30
30
  */
31
31
  timeoutMs?: number | undefined;
32
- /** Mid-flight cancellation, where the backend supports it. */
32
+ /** Cancels the call while it runs, where the backend supports it. */
33
33
  signal?: AbortSignal | undefined;
34
34
  /**
35
- * Entries merged over the parent environment for this call only. Per-call
36
- * rather than part of the request, like `timeoutMs`: it describes how the
37
- * invocation runs, not what operation was asked for.
35
+ * Entries merged over the parent environment for this call only. It is a
36
+ * call option, not part of the request, like `timeoutMs`: it describes how
37
+ * the command runs, not which operation was asked for.
38
38
  */
39
39
  env?: Record<string, string> | undefined;
40
40
  /**
41
41
  * Cap on each output stream, in bytes. Past it the runner kills the child
42
- * and the call throws (sync) or rejects (async) with `CommandFailed`, so
42
+ * and the call throws (sync) or rejects (async) with the classified failure, so
43
43
  * cut-short output is never read as an answer. A backend that cannot
44
44
  * enforce it may ignore it. Without it the async runner has no cap and the
45
45
  * sync runner caps at 256 MB.
@@ -369,28 +369,26 @@ export declare class UnsupportedRequest extends Error {
369
369
  export declare function cliBackend(opts?: {
370
370
  runner?: AsyncCommandRunner | undefined;
371
371
  /**
372
- * Which repository to drive, as `--git-dir` / `--work-tree` prefixed onto
373
- * every invocation. They live on the backend rather than on `GitRequest`
374
- * because they are CLI flags: a backend built on a pure-JavaScript git has
375
- * no `--git-dir` to receive, so "which repository" binds the thing that
376
- * spawns git.
372
+ * The repository to work on, added to every call as `--git-dir` /
373
+ * `--work-tree`. They are set on the backend, not on `GitRequest`, because
374
+ * they are CLI flags. A backend built on a pure-JavaScript git has no
375
+ * `--git-dir` to receive.
377
376
  */
378
377
  gitDir?: string | undefined;
379
378
  workTree?: string | undefined;
380
379
  /**
381
380
  * Entries merged over the parent environment on every call this backend
382
- * makes, under any per-call `env`. Binds an identity or a
383
- * `GIT_SSH_COMMAND` once, rather than threading it through call sites.
381
+ * makes, under any per-call `env`. Use it to set an identity or a
382
+ * `GIT_SSH_COMMAND` once, instead of passing it on every call.
384
383
  */
385
384
  env?: Record<string, string> | undefined;
386
385
  }): GitBackend;
387
386
  /**
388
387
  * Wrap a partial implementation: any request kind the object does not handle
389
388
  * rejects with {@link UnsupportedRequest} instead of failing as `undefined`.
390
- * The way to ship a backend that covers the operations it can and says so
391
- * about the rest.
389
+ * Use it for a backend that covers only some operations.
392
390
  *
393
- * @experimental Part of the backend seam; see {@link GitBackend}.
391
+ * @experimental Part of the backend interface; see {@link GitBackend}.
394
392
  */
395
393
  export declare function partialBackend(name: string, impl: Partial<{
396
394
  [K in GitRequestKind]: (cwd: string, request: Extract<GitRequest, {
package/dist/backend.js CHANGED
@@ -1,18 +1,18 @@
1
1
  /**
2
- * The backend seam — what `AsyncGit` talks to, and the thing you swap when
3
- * git should not come from a subprocess.
2
+ * The backend interface: what `AsyncGit` calls, and what you replace when git
3
+ * should not run as a subprocess.
4
4
  *
5
- * A backend takes a {@link GitRequest} — a plain, serializable description of
6
- * one git operation — and returns its typed result. That is deliberately not
7
- * argv: argv is a CLI detail, and a backend built on a pure-JavaScript git
8
- * implementation has no argv to receive. Describing the operation instead of
9
- * the invocation is what lets the same client drive either.
5
+ * A backend takes a {@link GitRequest}, a plain, serializable description of
6
+ * one git operation, and returns its typed result. The request is not argv on
7
+ * purpose. argv is a CLI detail, and a backend built on a pure-JavaScript git
8
+ * has no argv to receive. Describing the operation, not the command line, lets
9
+ * the same client work with either.
10
10
  *
11
- * It also means a request can be logged, queued, or replayed as data. The one
12
- * request that cannot cross that line is `raw`, which is argv by definition; a
13
- * non-CLI backend rejects it with {@link UnsupportedRequest}.
11
+ * It also means a request can be logged, queued, or replayed as data. The
12
+ * exception is `raw`, which is argv by definition. A non-CLI backend rejects
13
+ * it with {@link UnsupportedRequest}.
14
14
  *
15
- * The seam is experimental: `GitBackend`, `GitRequest`, `GitResults` and
15
+ * The interface is experimental: `GitBackend`, `GitRequest`, `GitResults` and
16
16
  * `partialBackend`. Each new verb adds a request kind, which breaks a backend
17
17
  * written as an exhaustive switch. Such a change can land in a minor release.
18
18
  * `cliBackend` and `AsyncGit` are stable.
@@ -173,9 +173,8 @@ function toVerb(request) {
173
173
  case 'raw': {
174
174
  const verb = {
175
175
  argv: request.argv,
176
- // Unchecked `raw` bypasses the gate entirely (see `execute`), so this
177
- // declaration only matters for the checked door, where nothing is
178
- // absence.
176
+ // Unchecked `raw` skips `gate` (see `execute`), so this only matters
177
+ // for `rawChecked`, where no exit code is an absence.
179
178
  absent: [],
180
179
  parse: (r) => r,
181
180
  };
@@ -214,15 +213,15 @@ export function cliBackend(opts = {}) {
214
213
  runOpts.env = { ...runOpts.env, ...verb.env };
215
214
  const argv = prefix.length === 0 ? verb.argv : [...prefix, ...verb.argv];
216
215
  const result = await runner.run(argv, runOpts);
217
- // Unchecked `raw` is the one door outside the gate: it hands back
218
- // whatever came out, at any exit code. Everything else uses the same
219
- // gate the sync client does.
216
+ // Unchecked `raw` is the only request that skips `gate`: it returns the
217
+ // result at any exit code. Everything else goes through the same `gate`
218
+ // the sync client uses.
220
219
  const req = request;
221
220
  const gated = req.kind !== 'raw' || req.checked === true;
222
221
  // The prefixed argv is what ran, so it is what a `CommandFailed` reports.
223
222
  const value = gated ? gate(verb, result, argv) : verb.parse(result, argv);
224
- // `GitResults` restates the verb table's return types for callers; the
225
- // two are kept in step by hand, which this cast is the seam for.
223
+ // `GitResults` restates the verb table's return types for callers. The
224
+ // two are kept in step by hand, and this cast is where they meet.
226
225
  return value;
227
226
  },
228
227
  };
@@ -230,10 +229,9 @@ export function cliBackend(opts = {}) {
230
229
  /**
231
230
  * Wrap a partial implementation: any request kind the object does not handle
232
231
  * rejects with {@link UnsupportedRequest} instead of failing as `undefined`.
233
- * The way to ship a backend that covers the operations it can and says so
234
- * about the rest.
232
+ * Use it for a backend that covers only some operations.
235
233
  *
236
- * @experimental Part of the backend seam; see {@link GitBackend}.
234
+ * @experimental Part of the backend interface; see {@link GitBackend}.
237
235
  */
238
236
  export function partialBackend(name, impl) {
239
237
  return {
@@ -1,27 +1,27 @@
1
1
  /**
2
2
  * Locate the git checkout containing a path, and find the checkouts inside a
3
- * directory — pure filesystem walks, no git process involved. Every other query in this package answers by shelling
4
- * out (see `Git#topLevel()`, `git rev-parse --show-toplevel`); this one
5
- * exists for callers that must not depend on a git binary being present, or
6
- * that run before it would be safe to spawn one.
3
+ * directory, by reading the filesystem only, with no git process. Every other
4
+ * query in this package runs git (see `Git#topLevel()`, `git rev-parse
5
+ * --show-toplevel`). These exist for callers that must not depend on a git
6
+ * binary being present, or that run before it would be safe to spawn one.
7
7
  */
8
8
  /**
9
9
  * The git checkout containing `path` — the nearest ancestor (`path` itself
10
10
  * included) carrying a `.git` entry, or null when none does.
11
11
  *
12
12
  * `.git` is a directory in a main checkout and a file (`gitdir: <path>`) in a
13
- * linked worktree; `existsSync` matches either without distinguishing them,
14
- * which is what every call site actually wants.
13
+ * linked worktree. `existsSync` matches either without telling them apart,
14
+ * which is what callers want.
15
15
  *
16
- * `path` may be a file or a directory — a file (or anything that cannot be
17
- * stat'ed, e.g. it does not exist yet) starts the walk from its parent.
16
+ * `path` may be a file or a directory. A file, or anything that cannot be
17
+ * stat'ed (for example, it does not exist yet), starts the walk from its parent.
18
18
  * Returns null on a miss rather than throwing: "no checkout here" is an
19
19
  * answer, not a failure, matching this package's query contract.
20
20
  */
21
21
  export declare function checkoutRoot(path: string): string | null;
22
22
  /** How far below the search root {@link discoverCheckouts} looks by default. */
23
23
  export declare const DEFAULT_MAX_DEPTH = 3;
24
- /** Directories read before the walk says out loud that the tree is huge. */
24
+ /** Directories read before the walk warns that the tree is very large. */
25
25
  export declare const DEFAULT_WARN_AFTER = 10000;
26
26
  export interface DiscoverCheckoutsOptions {
27
27
  /**
@@ -35,17 +35,17 @@ export interface DiscoverCheckoutsOptions {
35
35
  */
36
36
  warnAfter?: number | undefined;
37
37
  /**
38
- * Told once, mid-walk, that this search root is enormous. Defaults to a
39
- * line on stderr: a walk that takes a noticeable amount of time should say
40
- * why while it is still happening, not in a summary afterwards. A host with
41
- * its own output passes its own; `() => {}` silences it.
38
+ * Called once, during the walk, when the search root turns out to be very
39
+ * large. Defaults to a line on stderr: a slow walk should say why while it
40
+ * is still running, not in a summary afterwards. A host with its own output
41
+ * passes its own function. `() => {}` silences it.
42
42
  */
43
43
  onWarn?: ((message: string) => void) | undefined;
44
44
  }
45
45
  export interface CheckoutScan {
46
46
  /** The checkouts found, sorted, as absolute paths. */
47
47
  checkouts: string[];
48
- /** Directories read, the search root included. The cost of the walk. */
48
+ /** Directories read, the search root included. */
49
49
  directoriesScanned: number;
50
50
  /**
51
51
  * Directories left unopened because `maxDepth` stopped the walk there. A
@@ -54,35 +54,36 @@ export interface CheckoutScan {
54
54
  depthLimited: number;
55
55
  }
56
56
  /**
57
- * The checkouts under `dir`, with what the walk cost to find them.
57
+ * The checkouts under `dir`, with counts of what the walk read.
58
58
  *
59
59
  * The walk descends through directories that are not checkouts and stops at
60
60
  * the ones that are, because people group repositories: `~/Developer` holds
61
61
  * an owner directory per GitHub org, or a folder per client, and the
62
- * checkouts sit a level or two inside. Stopping at a checkout is what keeps
63
- * this cheap — a repository's own `node_modules`, `vendor` and nested
64
- * worktrees are below one, so they are never entered.
62
+ * checkouts sit a level or two inside. Stopping at a checkout keeps this
63
+ * fast: a repository's own `node_modules`, `vendor` and nested worktrees are
64
+ * below it, so they are never entered.
65
65
  *
66
- * Two bounds keep an unlucky search root from becoming a full-disk walk:
67
- * dotted children are skipped, and nothing deeper than `maxDepth` is
68
- * entered. The depth cap is the one that matters, since a directory of
69
- * ordinary files — a documents folder, a media library — has no checkout to
70
- * stop the descent. `warnAfter` is the third line of defence, and the only
71
- * one a person sees: past that many directories the walk says so and carries
72
- * on, because the usual cause is a search root pointed at the wrong place.
66
+ * Two limits keep a bad search root from turning into a walk of the whole
67
+ * disk: children whose names start with a dot are skipped, and nothing
68
+ * deeper than `maxDepth` is entered. The depth limit matters most, since a
69
+ * directory of ordinary files, such as a documents folder or a media
70
+ * library, has no checkout to stop the walk. `warnAfter` is a third check,
71
+ * and the only one a person sees: past that many directories the walk warns
72
+ * and keeps going, because the usual cause is a search root pointed at the
73
+ * wrong place.
73
74
  *
74
- * Like {@link checkoutRoot}, a pure filesystem walk: no git process runs, so
75
- * the cost is a `readdir` per directory entered and a `stat` per child. A
76
- * linked worktree answers as a checkout here, since both carry a `.git`
77
- * entry; a caller that wants one row per repository resolves each result
78
- * through `Git#mainCheckout()` and de-duplicates.
75
+ * Like {@link checkoutRoot}, it reads the filesystem only. No git process
76
+ * runs, so the cost is a `readdir` per directory entered and a `stat` per
77
+ * child. A linked worktree answers as a checkout here, since both carry a
78
+ * `.git` entry. A caller that wants one row per repository resolves each
79
+ * result through `Git#mainCheckout()` and de-duplicates.
79
80
  *
80
81
  * An unreadable directory contributes nothing rather than throwing, matching
81
82
  * this module's contract that absence is an answer.
82
83
  */
83
84
  export declare function scanForCheckouts(dir: string, opts?: DiscoverCheckoutsOptions): CheckoutScan;
84
85
  /**
85
- * The checkouts under `dir`, sorted, as absolute paths — {@link
86
- * scanForCheckouts} for a caller that wants the answer and not the cost.
86
+ * The checkouts under `dir`, sorted, as absolute paths. {@link
87
+ * scanForCheckouts} without the counts.
87
88
  */
88
89
  export declare function discoverCheckouts(dir: string, opts?: DiscoverCheckoutsOptions): string[];
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Locate the git checkout containing a path, and find the checkouts inside a
3
- * directory — pure filesystem walks, no git process involved. Every other query in this package answers by shelling
4
- * out (see `Git#topLevel()`, `git rev-parse --show-toplevel`); this one
5
- * exists for callers that must not depend on a git binary being present, or
6
- * that run before it would be safe to spawn one.
3
+ * directory, by reading the filesystem only, with no git process. Every other
4
+ * query in this package runs git (see `Git#topLevel()`, `git rev-parse
5
+ * --show-toplevel`). These exist for callers that must not depend on a git
6
+ * binary being present, or that run before it would be safe to spawn one.
7
7
  */
8
8
  import { existsSync, readdirSync, statSync } from 'node:fs';
9
9
  import { dirname, resolve } from 'node:path';
@@ -21,11 +21,11 @@ function isDir(p) {
21
21
  * included) carrying a `.git` entry, or null when none does.
22
22
  *
23
23
  * `.git` is a directory in a main checkout and a file (`gitdir: <path>`) in a
24
- * linked worktree; `existsSync` matches either without distinguishing them,
25
- * which is what every call site actually wants.
24
+ * linked worktree. `existsSync` matches either without telling them apart,
25
+ * which is what callers want.
26
26
  *
27
- * `path` may be a file or a directory — a file (or anything that cannot be
28
- * stat'ed, e.g. it does not exist yet) starts the walk from its parent.
27
+ * `path` may be a file or a directory. A file, or anything that cannot be
28
+ * stat'ed (for example, it does not exist yet), starts the walk from its parent.
29
29
  * Returns null on a miss rather than throwing: "no checkout here" is an
30
30
  * answer, not a failure, matching this package's query contract.
31
31
  */
@@ -44,31 +44,32 @@ export function checkoutRoot(path) {
44
44
  }
45
45
  /** How far below the search root {@link discoverCheckouts} looks by default. */
46
46
  export const DEFAULT_MAX_DEPTH = 3;
47
- /** Directories read before the walk says out loud that the tree is huge. */
47
+ /** Directories read before the walk warns that the tree is very large. */
48
48
  export const DEFAULT_WARN_AFTER = 10_000;
49
49
  /**
50
- * The checkouts under `dir`, with what the walk cost to find them.
50
+ * The checkouts under `dir`, with counts of what the walk read.
51
51
  *
52
52
  * The walk descends through directories that are not checkouts and stops at
53
53
  * the ones that are, because people group repositories: `~/Developer` holds
54
54
  * an owner directory per GitHub org, or a folder per client, and the
55
- * checkouts sit a level or two inside. Stopping at a checkout is what keeps
56
- * this cheap — a repository's own `node_modules`, `vendor` and nested
57
- * worktrees are below one, so they are never entered.
55
+ * checkouts sit a level or two inside. Stopping at a checkout keeps this
56
+ * fast: a repository's own `node_modules`, `vendor` and nested worktrees are
57
+ * below it, so they are never entered.
58
58
  *
59
- * Two bounds keep an unlucky search root from becoming a full-disk walk:
60
- * dotted children are skipped, and nothing deeper than `maxDepth` is
61
- * entered. The depth cap is the one that matters, since a directory of
62
- * ordinary files — a documents folder, a media library — has no checkout to
63
- * stop the descent. `warnAfter` is the third line of defence, and the only
64
- * one a person sees: past that many directories the walk says so and carries
65
- * on, because the usual cause is a search root pointed at the wrong place.
59
+ * Two limits keep a bad search root from turning into a walk of the whole
60
+ * disk: children whose names start with a dot are skipped, and nothing
61
+ * deeper than `maxDepth` is entered. The depth limit matters most, since a
62
+ * directory of ordinary files, such as a documents folder or a media
63
+ * library, has no checkout to stop the walk. `warnAfter` is a third check,
64
+ * and the only one a person sees: past that many directories the walk warns
65
+ * and keeps going, because the usual cause is a search root pointed at the
66
+ * wrong place.
66
67
  *
67
- * Like {@link checkoutRoot}, a pure filesystem walk: no git process runs, so
68
- * the cost is a `readdir` per directory entered and a `stat` per child. A
69
- * linked worktree answers as a checkout here, since both carry a `.git`
70
- * entry; a caller that wants one row per repository resolves each result
71
- * through `Git#mainCheckout()` and de-duplicates.
68
+ * Like {@link checkoutRoot}, it reads the filesystem only. No git process
69
+ * runs, so the cost is a `readdir` per directory entered and a `stat` per
70
+ * child. A linked worktree answers as a checkout here, since both carry a
71
+ * `.git` entry. A caller that wants one row per repository resolves each
72
+ * result through `Git#mainCheckout()` and de-duplicates.
72
73
  *
73
74
  * An unreadable directory contributes nothing rather than throwing, matching
74
75
  * this module's contract that absence is an answer.
@@ -119,8 +120,8 @@ export function scanForCheckouts(dir, opts = {}) {
119
120
  return { checkouts: checkouts.sort(), directoriesScanned, depthLimited };
120
121
  }
121
122
  /**
122
- * The checkouts under `dir`, sorted, as absolute paths — {@link
123
- * scanForCheckouts} for a caller that wants the answer and not the cost.
123
+ * The checkouts under `dir`, sorted, as absolute paths. {@link
124
+ * scanForCheckouts} without the counts.
124
125
  */
125
126
  export function discoverCheckouts(dir, opts = {}) {
126
127
  return scanForCheckouts(dir, opts).checkouts;
package/dist/client.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  /**
2
- * `@osdlc/typed-git/client` — the git clients and their seams, without the
3
- * git-reference parsers and the checkout walks.
2
+ * `@osdlc/typed-git/client`: the git clients, their backend and runner
3
+ * types, without the git-reference parsers and the checkout walks.
4
4
  *
5
5
  * The package entry minus two groups. The first is `parseGitUrl`,
6
6
  * `gitSshUrl`, `parseRepoRef` and their types, which pull in
7
7
  * `hosted-git-info`. The second is the checkout walks: `checkoutRoot`,
8
8
  * `discoverCheckouts`, `scanForCheckouts`, their types and their defaults. A
9
- * consumer that only drives git — a runner discovery pass, a guard script —
9
+ * consumer that only runs git, such as a runner discovery pass or a check script,
10
10
  * imports from here and keeps `hosted-git-info` off its module graph. It stays
11
11
  * in `dependencies` either way, so this is a bundle saving, not an install
12
12
  * one.
13
13
  *
14
14
  * The package entry is defined as this module plus the URL exports, so there
15
- * is one definition of the surface rather than two lists to keep in step.
15
+ * is one list of exports rather than two to keep in step.
16
16
  */
17
17
  export { Git, type GitSyncCallOptions } from './sync.ts';
18
18
  export { AsyncGit } from './async.ts';