type-git 0.8.1 → 0.8.3
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/README.md +3 -0
- package/dist/adapters/bun/index.cjs +8 -8
- package/dist/adapters/bun/index.d.cts +2 -2
- package/dist/adapters/bun/index.d.ts +2 -2
- package/dist/adapters/bun/index.js +2 -2
- package/dist/adapters/deno/index.cjs +8 -8
- package/dist/adapters/deno/index.d.cts +2 -2
- package/dist/adapters/deno/index.d.ts +2 -2
- package/dist/adapters/deno/index.js +2 -2
- package/dist/adapters/node/index.cjs +4 -4
- package/dist/adapters/node/index.d.cts +2 -2
- package/dist/adapters/node/index.d.ts +2 -2
- package/dist/adapters/node/index.js +3 -3
- package/dist/{chunk-ADC26634.js → chunk-HCQGGKTC.js} +212 -135
- package/dist/{chunk-JDCCYWIX.cjs → chunk-I77B22ZE.cjs} +7 -7
- package/dist/{chunk-S3EFBFVP.js → chunk-MS6E5USB.js} +1 -1
- package/dist/{chunk-6HDMSFY7.cjs → chunk-QHIS7LHW.cjs} +69 -12
- package/dist/{chunk-UHZWPYTF.cjs → chunk-SNC324NL.cjs} +1059 -982
- package/dist/{chunk-UAKOSACD.js → chunk-V4ZRQG3O.js} +69 -12
- package/dist/{client.d-Cg5wWJnY.d.cts → client.d-ClMefrEh.d.ts} +2 -2
- package/dist/{client.d-DCiFA_CK.d.ts → client.d-Jwli7Qfw.d.cts} +2 -2
- package/dist/{git.d-DqAvRXEf.d.cts → git.d-BTNkPofF.d.cts} +83 -10
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/strict/index.cjs +99 -99
- package/dist/strict/index.d.cts +1 -1
- package/dist/strict/index.js +1 -1
- package/docs/adapters.md +40 -18
- package/package.json +1 -1
package/dist/strict/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as CompoundDecimalParser, l as COMPOUND_DECIMALS, m as GitDecimalParser, n as GitDecimalLiteral, o as GitDecimalValue, p as AtMost$1, D as Digit$1, q as AddDigit, F as FastImportUnsignedParser, T as Trim, U as UrlBytes, r as GitIntegerValue, N as NumberLiteralOrder, S as SafeIntegerAtLeast, s as GitScalarParser, t as Evidence, u as Constraint, P as Predicate, a as CompanionExecutable, v as GitBooleanSource, w as GitDecimalCallbacks, x as GitIntegerProfile, y as GitNumericParser, z as Constrained, H as GitNumericLiteral, J as GitBooleanCallback, K as GitBooleanCallbackLiteral, O as ObjectFilterLiteral, M as AsciiUpper, Q as StringCallbackParser, V as StringCallbackLiteral, X as AsciiLower, Y as GitNumericValue, Z as GitBooleanCallbackValue, _ as StringCallbackValue, $ as ConstraintRequirement, a0 as GitTimestampParser, a1 as GitDecimalCallback, a2 as LegacyGitDecimal, a3 as GitIntegerParser, a4 as GitOutputMode,
|
|
1
|
+
import { k as CompoundDecimalParser, l as COMPOUND_DECIMALS, m as GitDecimalParser, n as GitDecimalLiteral, o as GitDecimalValue, p as AtMost$1, D as Digit$1, q as AddDigit, F as FastImportUnsignedParser, T as Trim, U as UrlBytes, r as GitIntegerValue, N as NumberLiteralOrder, S as SafeIntegerAtLeast, s as GitScalarParser, t as Evidence, u as Constraint, P as Predicate, a as CompanionExecutable, v as GitBooleanSource, w as GitDecimalCallbacks, x as GitIntegerProfile, y as GitNumericParser, z as Constrained, H as GitNumericLiteral, J as GitBooleanCallback, K as GitBooleanCallbackLiteral, O as ObjectFilterLiteral, M as AsciiUpper, Q as StringCallbackParser, V as StringCallbackLiteral, X as AsciiLower, Y as GitNumericValue, Z as GitBooleanCallbackValue, _ as StringCallbackValue, $ as ConstraintRequirement, a0 as GitTimestampParser, a1 as GitDecimalCallback, a2 as LegacyGitDecimal, a3 as GitIntegerParser, a4 as GitOutputMode, a5 as CommandExecOpts, R as RawResult, G as Git, W as WorktreeRepo, B as BareRepo } from '../git.d-BTNkPofF.cjs';
|
|
2
2
|
|
|
3
3
|
type Profile<P extends CompoundDecimalParser> = (typeof COMPOUND_DECIMALS)[P];
|
|
4
4
|
type DecimalProfile<P extends CompoundDecimalParser, Bits extends 32 | 64, NegateOverflow extends boolean> = Omit<Profile<P>['decimal'], 'longBits'> & {
|
package/dist/strict/index.js
CHANGED
package/docs/adapters.md
CHANGED
|
@@ -20,10 +20,16 @@ The built-in adapters are `NodeExecAdapter` (`type-git/node`), `BunExecAdapter`
|
|
|
20
20
|
## `SpawnOptions` as the runner sends them
|
|
21
21
|
|
|
22
22
|
- `argv`: `[gitBinary, ...]` (or a companion program path). The first element is the program;
|
|
23
|
-
arguments are never passed through a shell. Do not join them into a command line.
|
|
23
|
+
arguments are never passed through a shell. Do not join them into a command line. When a Git
|
|
24
|
+
command also gets `cwd` (see below) and `gitBinary` is a relative path such as `./tools/git`,
|
|
25
|
+
the runner prefixes the host process's current directory, so the program is the same one a
|
|
26
|
+
call without `cwd` would run. A bare name such as `git` is left for `PATH` lookup.
|
|
24
27
|
- `env`: the **complete** environment for the child. The runner has already resolved the
|
|
25
28
|
inherited variables (see `inheritEnv` on `createGit`/`open`), layered `env`, `home` and
|
|
26
|
-
`pathPrefix` on top, and applied any per-call overrides.
|
|
29
|
+
`pathPrefix` on top, and applied any per-call overrides. When the spawn also gets `cwd`, every
|
|
30
|
+
relative or empty `PATH` entry (from `pathPrefix`, `env`, a per-call override, or the inherited
|
|
31
|
+
value) is anchored to the host process's current directory, so the program search does not
|
|
32
|
+
look inside the repository. Rooted entries, and quoted entries on Windows, are unchanged.
|
|
27
33
|
- `inheritEnv`: always `false` from the runner. The adapter must not merge the parent process
|
|
28
34
|
environment underneath `env`; doing so would defeat the environment allowlist.
|
|
29
35
|
- `stdin`: `undefined`, a UTF-8 `string`, or a `Uint8Array`. When present, write all of it and
|
|
@@ -43,8 +49,8 @@ Git commands select the repository with an explicit flag. Companion programs (`s
|
|
|
43
49
|
| Context | argv | `cwd` sent to the adapter |
|
|
44
50
|
| --- | --- | --- |
|
|
45
51
|
| Repository-agnostic (`git.raw`, `git.version`, `clone`, `init`, …) | `git …` | `undefined` |
|
|
46
|
-
| Worktree repository | `git -C <workdir> …` | `<workdir>` |
|
|
47
|
-
| Bare repository | `git --git-dir <gitDir> …` | `undefined` |
|
|
52
|
+
| Worktree repository | `git -C <workdir> …` | `<workdir>` if absolute, else `undefined` |
|
|
53
|
+
| Bare repository | `git --git-dir <gitDir> …` | `<gitDir>` if absolute, else `undefined` |
|
|
48
54
|
| Companion program, repository-agnostic | `<program> …` | `undefined` |
|
|
49
55
|
| Companion program, worktree repository | `<program> …` | `<workdir>` |
|
|
50
56
|
| Companion program, bare repository | `<program> …` | `<gitDir>` |
|
|
@@ -53,15 +59,22 @@ When a credential helper is configured, Git argv starts with
|
|
|
53
59
|
`git -c credential.helper=<helper>` before the context flag.
|
|
54
60
|
|
|
55
61
|
`undefined` means "do not set one"; the child then inherits the host process's current
|
|
56
|
-
directory. The runner passes repository paths unchanged, as the table shows
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
`
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
`repo
|
|
64
|
-
|
|
62
|
+
directory. The runner passes repository paths unchanged, as the table shows. Git commands get the
|
|
63
|
+
path in `-C` / `--git-dir` and, when the path is absolute on the host platform, also as `cwd`
|
|
64
|
+
(on POSIX a path starting with `/`; on Windows also `\x`, `C:\x`, `C:/x`, and UNC paths, but not
|
|
65
|
+
drive-relative `C:x`). A relative path is not sent as `cwd`, because Git resolves `-C` / `--git-dir`
|
|
66
|
+
against the working directory and would otherwise look in `<path>/<path>`; Git then resolves it
|
|
67
|
+
against the host process's current directory, as the Git CLI would. Companion programs get the
|
|
68
|
+
path only as `cwd`, whether absolute or not. Relative path arguments of a repository command
|
|
69
|
+
(for example `repo.raw(['archive', '-o', 'out.tar', 'HEAD'])`) resolve inside the worktree for
|
|
70
|
+
a worktree repository, whether it was opened by an absolute or a relative path, because `-C`
|
|
71
|
+
changes Git's directory. For a bare repository they resolve inside the repository directory
|
|
72
|
+
when it was opened by an absolute path, and against the host process's current directory when
|
|
73
|
+
it was opened by a relative path, because `--git-dir` does not change Git's directory. `clone` and `init` are repository-agnostic: the
|
|
74
|
+
destination is a positional argument. Use absolute repository paths so that the selected
|
|
75
|
+
repository does not depend on the inherited directory and the adapter always receives `cwd` for
|
|
76
|
+
repository calls. `clone`, `init`, repository-agnostic calls, and calls on a repository opened by
|
|
77
|
+
a relative path get `cwd: undefined`, so an adapter that requires a working directory must
|
|
65
78
|
handle `undefined` (for example by using the host's current directory) instead of rejecting
|
|
66
79
|
these calls. Repository-agnostic calls are different: `git.raw()`, `strict(git).command()`
|
|
67
80
|
and repository-agnostic companion programs run with `cwd: undefined`, so a command that needs a
|
|
@@ -75,11 +88,20 @@ directory, as the Git CLI would. Open a repository and use `repo.raw()` to avoid
|
|
|
75
88
|
- `git.open(path)`, `git.openBare(path)`, `git.openRaw(path)`:
|
|
76
89
|
1. `git -C <path> rev-parse --is-bare-repository` with `cwd: <path>`.
|
|
77
90
|
2. Only if step 1 exits non-zero: `git --git-dir <path> rev-parse --is-bare-repository` with
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
`
|
|
91
|
+
`cwd: <path>`.
|
|
92
|
+
|
|
93
|
+
Both steps follow the `cwd` rule above, so a relative `<path>` runs with `cwd: undefined`.
|
|
94
|
+
When both steps fail, the `GitError` (kind `NonZeroExit`) carries step 2's `exitCode` and
|
|
95
|
+
`stderr`, and `context.firstProbe` carries step 1's `argv`, `exitCode` and `stderr`. Step 1
|
|
96
|
+
usually names the cause (for example `detected dubious ownership` when `safe.directory` does
|
|
97
|
+
not allow the repository), while step 2 only says `not a git repository`, so the message also
|
|
98
|
+
ends with step 1's first `fatal:` line when there is one.
|
|
99
|
+
|
|
100
|
+
If an absolute `<path>` does not exist, step 1 fails to start (the built-in Node adapter
|
|
101
|
+
reports `spawn git ENOENT` because the working directory is missing) and `open` throws a
|
|
102
|
+
`GitError` with kind `SpawnFailed`; step 2 does not run. A relative `<path>` that does not
|
|
103
|
+
exist runs without `cwd`, so both steps run and fail, and `open` throws the `NonZeroExit`
|
|
104
|
+
error above with `firstProbe` (step 1 says `cannot change to '<path>'`).
|
|
83
105
|
- Typed `strict(...).command()` calls may start **internal probes** before the real command when the
|
|
84
106
|
result depends on how the installed Git parses an argument (for example `git <command> -h`,
|
|
85
107
|
`git --exec-path`, or a probe inside a throwaway bare repository created with
|
package/package.json
CHANGED