@osdlc/typed-git 0.8.1 → 0.8.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @osdlc/typed-git
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - f013f38: The default runners now find `git` and `gh` on absolute `PATH` entries only, and spawn the absolute path found. Before, a bare `git` or `gh` was spawned by name with the child's `cwd` set to the checkout, so a file of that name in the checkout could run in place of the real binary: on Windows, where a bare name is searched in `cwd` first, and on every platform through a relative or empty `PATH` entry. A binary that is not found on an absolute entry fails as a missing binary (`not-installed`). typed-gh's `defaultRunnerFactory` does the same lookup. An injected runner is unchanged.
8
+ - Updated dependencies [f013f38]
9
+ - @osdlc/command-seam@0.12.1
10
+
3
11
  ## 0.8.1
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -610,6 +610,7 @@ Integration, declares exit 1 absent and returns the rejected refs.
610
610
  | `worktreeAdd(path, { branch, startPoint, detach })` | `worktree add` |
611
611
  | `worktreeRemove(path, { force })` | `worktree remove` |
612
612
  | `worktreeMove(from, to, { force })` | `worktree move` |
613
+ | `worktreeUnlock(path)` | `worktree unlock` |
613
614
  | `worktreePrune()` | `worktree prune` |
614
615
  | `remoteAdd(name, url)` | `remote add` |
615
616
  | `checkout(ref, { branch, resetBranch, force })` | `checkout` — `resetBranch` picks `-B` |
@@ -698,6 +699,10 @@ const failing: CommandRunner = {
698
699
  new Git("/nowhere", { runner: failing }).currentBranch(); // throws FailureError (kind "not-a-repo")
699
700
  ```
700
701
 
702
+ The default runner finds `git` on absolute `PATH` entries only, so a file named
703
+ `git` in the checkout cannot run in its place. A real runner you build yourself
704
+ should do the same: `spawnRunner("git", { absolutePathOnly: true })`.
705
+
701
706
  `runner: undefined` is the same as omitting it, so a caller holding an optional
702
707
  runner passes it straight through, without a conditional spread. `cliBackend`
703
708
  accepts it too.
package/SECURITY.md CHANGED
@@ -24,8 +24,10 @@ We will credit you in the release notes if you want that.
24
24
 
25
25
  ## Scope
26
26
 
27
- - The client runs the `git` found on `PATH`. It builds argument arrays and
28
- starts no shell.
27
+ - The client runs the `git` found on an absolute `PATH` entry, by its
28
+ absolute path, so a file named `git` in the checkout cannot run in its
29
+ place. It builds argument arrays and starts no shell. A runner you inject
30
+ replaces this lookup.
29
31
  - Starting the process is the job of `@osdlc/command-seam`. Report problems
30
32
  in how a process is started there.
31
33
  - `@osdlc/typed-git/testing` makes and deletes temporary directories. It is
package/dist/async.d.ts CHANGED
@@ -293,6 +293,8 @@ export declare class AsyncGit {
293
293
  }): Promise<void>;
294
294
  /** `git worktree move [--force] <from> <to>`. */
295
295
  worktreeMove(from: string, to: string, opts?: GitCallOptions & WorktreeMoveOptions): Promise<void>;
296
+ /** `git worktree unlock <path>`. */
297
+ worktreeUnlock(path: string, opts?: GitCallOptions): Promise<void>;
296
298
  /** `git worktree prune`. */
297
299
  worktreePrune(opts?: GitCallOptions): Promise<void>;
298
300
  /** `git remote add <name> <url>`. */
package/dist/async.js CHANGED
@@ -478,6 +478,10 @@ export class AsyncGit {
478
478
  const [call, req] = splitCallOptions(opts);
479
479
  return this.backend.execute(this.cwd, { kind: 'worktreeMove', from, to, ...req }, call);
480
480
  }
481
+ /** `git worktree unlock <path>`. */
482
+ worktreeUnlock(path, opts = {}) {
483
+ return this.backend.execute(this.cwd, { kind: 'worktreeUnlock', path }, opts);
484
+ }
481
485
  /** `git worktree prune`. */
482
486
  worktreePrune(opts = {}) {
483
487
  return this.backend.execute(this.cwd, { kind: 'worktreePrune' }, opts);
package/dist/backend.d.ts CHANGED
@@ -220,6 +220,9 @@ export type GitRequest = {
220
220
  from: string;
221
221
  to: string;
222
222
  } & WorktreeMoveOptions) | {
223
+ kind: 'worktreeUnlock';
224
+ path: string;
225
+ } | {
223
226
  kind: 'worktreePrune';
224
227
  } | ({
225
228
  kind: 'merge';
@@ -327,6 +330,7 @@ export interface GitResults {
327
330
  worktreeAdd: void;
328
331
  worktreeRemove: void;
329
332
  worktreeMove: void;
333
+ worktreeUnlock: void;
330
334
  worktreePrune: void;
331
335
  merge: MergeOutcome;
332
336
  mergeAbort: void;
@@ -369,7 +373,9 @@ export declare class UnsupportedRequest extends Error {
369
373
  /**
370
374
  * The default backend: every request becomes a `git` subprocess, run through
371
375
  * an {@link AsyncCommandRunner} so the caller decides how spawning happens
372
- * (and tests inject a fake).
376
+ * (and tests inject a fake). The default runner spawns the `git` found on an
377
+ * absolute `PATH` entry, so a `git` file in the checkout cannot run in its
378
+ * place.
373
379
  */
374
380
  export declare function cliBackend(opts?: {
375
381
  runner?: AsyncCommandRunner | undefined;
package/dist/backend.js CHANGED
@@ -17,7 +17,7 @@
17
17
  * written as an exhaustive switch. Such a change can land in a minor release.
18
18
  * `cliBackend` and `AsyncGit` are stable.
19
19
  */
20
- import { resolveRunnerAsync, } from '@osdlc/command-seam';
20
+ import { spawnRunnerAsync, } from '@osdlc/command-seam';
21
21
  import * as v from "./verbs.js";
22
22
  import { gate, mergeEnv, repoPrefix, } from "./verbs.js";
23
23
  /** Thrown by a backend asked for an operation it cannot perform. */
@@ -142,6 +142,8 @@ function toVerb(request) {
142
142
  return v.worktreeRemove(request.path, { force: request.force });
143
143
  case 'worktreeMove':
144
144
  return v.worktreeMove(request.from, request.to, request);
145
+ case 'worktreeUnlock':
146
+ return v.worktreeUnlock(request.path);
145
147
  case 'worktreePrune':
146
148
  return v.worktreePrune();
147
149
  case 'merge':
@@ -189,10 +191,12 @@ function toVerb(request) {
189
191
  /**
190
192
  * The default backend: every request becomes a `git` subprocess, run through
191
193
  * an {@link AsyncCommandRunner} so the caller decides how spawning happens
192
- * (and tests inject a fake).
194
+ * (and tests inject a fake). The default runner spawns the `git` found on an
195
+ * absolute `PATH` entry, so a `git` file in the checkout cannot run in its
196
+ * place.
193
197
  */
194
198
  export function cliBackend(opts = {}) {
195
- const runner = resolveRunnerAsync('git', opts.runner);
199
+ const runner = opts.runner ?? spawnRunnerAsync('git', { absolutePathOnly: true });
196
200
  const prefix = repoPrefix(opts.gitDir, opts.workTree);
197
201
  return {
198
202
  async execute(cwd, request, callOpts = {}) {
package/dist/sync.d.ts CHANGED
@@ -68,7 +68,9 @@ export declare class Git {
68
68
  * `backend.ts`.
69
69
  *
70
70
  * This client takes a `runner`, where `AsyncGit` takes a `backend`. The
71
- * default runner spawns `git`; tests pass a fake `CommandRunner`.
71
+ * default runner spawns the `git` found on an absolute `PATH` entry, so a
72
+ * `git` file in the checkout cannot run in its place. Tests pass a fake
73
+ * `CommandRunner`.
72
74
  *
73
75
  * Neither client has a default timeout. This client kills a child whose
74
76
  * output on one stream passes 256 MB; `AsyncGit` has no output cap. The
@@ -399,6 +401,8 @@ export declare class Git {
399
401
  }): void;
400
402
  /** `git worktree move [--force] <from> <to>`. */
401
403
  worktreeMove(from: string, to: string, opts?: GitSyncCallOptions & WorktreeMoveOptions): void;
404
+ /** `git worktree unlock <path>`. */
405
+ worktreeUnlock(path: string, opts?: GitSyncCallOptions): void;
402
406
  /** `git worktree prune`. */
403
407
  worktreePrune(opts?: GitSyncCallOptions): void;
404
408
  /** `git remote add <name> <url>`. */
package/dist/sync.js CHANGED
@@ -16,7 +16,7 @@
16
16
  * service's compare-and-swap ref operations. That is not general git.
17
17
  */
18
18
  import { dirname } from 'node:path';
19
- import { resolveRunner, } from '@osdlc/command-seam';
19
+ import { spawnRunner, } from '@osdlc/command-seam';
20
20
  import { softSync, triedSync } from "./outcome.js";
21
21
  import { parseRemoteUrl } from "./remote-url.js";
22
22
  import { SOFT_TABLE } from "./soft.js";
@@ -47,7 +47,9 @@ export class Git {
47
47
  * `backend.ts`.
48
48
  *
49
49
  * This client takes a `runner`, where `AsyncGit` takes a `backend`. The
50
- * default runner spawns `git`; tests pass a fake `CommandRunner`.
50
+ * default runner spawns the `git` found on an absolute `PATH` entry, so a
51
+ * `git` file in the checkout cannot run in its place. Tests pass a fake
52
+ * `CommandRunner`.
51
53
  *
52
54
  * Neither client has a default timeout. This client kills a child whose
53
55
  * output on one stream passes 256 MB; `AsyncGit` has no output cap. The
@@ -55,7 +57,7 @@ export class Git {
55
57
  */
56
58
  constructor(cwd, opts = {}) {
57
59
  this.cwd = cwd;
58
- this.runner = resolveRunner('git', opts.runner);
60
+ this.runner = opts.runner ?? spawnRunner('git', { absolutePathOnly: true });
59
61
  this.boundGitDir = opts.gitDir;
60
62
  this.workTree = opts.workTree;
61
63
  this.env = opts.env;
@@ -552,6 +554,10 @@ export class Git {
552
554
  worktreeMove(from, to, opts = {}) {
553
555
  this.exec(v.worktreeMove(from, to, opts), opts);
554
556
  }
557
+ /** `git worktree unlock <path>`. */
558
+ worktreeUnlock(path, opts = {}) {
559
+ this.exec(v.worktreeUnlock(path), opts);
560
+ }
555
561
  /** `git worktree prune`. */
556
562
  worktreePrune(opts = {}) {
557
563
  this.exec(v.worktreePrune(), opts);
package/dist/verbs.d.ts CHANGED
@@ -1134,6 +1134,8 @@ export interface WorktreeMoveOptions {
1134
1134
  }
1135
1135
  /** `git worktree move [--force] <from> <to>`. */
1136
1136
  export declare function worktreeMove(from: string, to: string, opts?: WorktreeMoveOptions): GitVerb<void>;
1137
+ /** `git worktree unlock <path>`. */
1138
+ export declare function worktreeUnlock(path: string): GitVerb<void>;
1137
1139
  /** `git worktree prune`. */
1138
1140
  export declare function worktreePrune(): GitVerb<void>;
1139
1141
  /** `git remote add <name> <url>`. */
package/dist/verbs.js CHANGED
@@ -1518,6 +1518,14 @@ export function worktreeMove(from, to, opts = {}) {
1518
1518
  argv.push(positional('worktreeMove', 'from', from), positional('worktreeMove', 'to', to));
1519
1519
  return { argv, absent: NONE, parse: nothing };
1520
1520
  }
1521
+ /** `git worktree unlock <path>`. */
1522
+ export function worktreeUnlock(path) {
1523
+ return {
1524
+ argv: ['worktree', 'unlock', positional('worktreeUnlock', 'path', path)],
1525
+ absent: NONE,
1526
+ parse: nothing,
1527
+ };
1528
+ }
1521
1529
  /** `git worktree prune`. */
1522
1530
  export function worktreePrune() {
1523
1531
  return { argv: ['worktree', 'prune'], absent: NONE, parse: nothing };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdlc/typed-git",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "A typed git client for TypeScript, sync and awaitable. Each verb declares what absence means for it; every other failure throws. git.try.* inspects, raw() bypasses — over an injectable backend that drives the git CLI or any other implementation.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "sksizer",
@@ -52,7 +52,7 @@
52
52
  ],
53
53
  "dependencies": {
54
54
  "hosted-git-info": "^10.1.1",
55
- "@osdlc/command-seam": "^0.12.0",
55
+ "@osdlc/command-seam": "^0.12.1",
56
56
  "@osdlc/result": "^0.1.0"
57
57
  },
58
58
  "devDependencies": {