@osdlc/typed-git 0.10.0 → 0.11.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/CHANGELOG.md +25 -0
- package/README.md +87 -10
- package/dist/async.d.ts +17 -1
- package/dist/async.js +21 -0
- package/dist/backend.d.ts +27 -1
- package/dist/backend.js +33 -4
- package/dist/client.d.ts +3 -1
- package/dist/client.js +2 -0
- package/dist/failure.d.ts +18 -4
- package/dist/failure.js +4 -0
- package/dist/features.d.ts +91 -0
- package/dist/features.js +98 -0
- package/dist/git-url.d.ts +3 -0
- package/dist/git-url.js +14 -2
- package/dist/git-version.d.ts +90 -0
- package/dist/git-version.js +225 -0
- package/dist/soft.d.ts +1 -0
- package/dist/soft.js +1 -0
- package/dist/sync.d.ts +33 -3
- package/dist/sync.js +61 -3
- package/dist/verbs.d.ts +63 -2
- package/dist/verbs.js +117 -42
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @osdlc/typed-git
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7fe7f51: `parseRemoteRepo` reads `ssh.github.com` (GitHub's SSH over port 443) and `www.github.com` as `github.com`, so a remote on either names the same repository as one on `github.com`.
|
|
8
|
+
|
|
9
|
+
## 0.11.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 82d9841: Add `cherry(upstream, head?)` and `commitTree(tree, { parents, message })` to `Git` and `AsyncGit`.
|
|
14
|
+
|
|
15
|
+
- `cherry` runs `git cherry` and returns `{ sha, equivalent }` per commit on `head` that `upstream` lacks. Output it cannot read throws instead of being skipped. `soft.cherry` falls back to `[]`.
|
|
16
|
+
- `commitTree` runs `git commit-tree` and returns the new commit's sha. It writes an object and no ref, and needs a git identity. A reply that is not a sha throws.
|
|
17
|
+
- Both refuse a leading-dash revision before spawning, like the other revision-taking verbs.
|
|
18
|
+
- ebe0e0d: typed-git knows which git it runs, and which features need a newer one. The supported floor is git 2.34 (Ubuntu 22.04 LTS). One table, `GIT_FEATURES`, lists the features newer than that: `merge-tree --write-tree` (git 2.38), `merge-tree --merge-base` (2.40) and `worktree list -z` (2.36). The README's new "Git versions" section is checked against it.
|
|
19
|
+
|
|
20
|
+
- A verb that uses one of these features runs `git --version` first and caches it per runner and per effective `PATH`. Other verbs never run it. The probe runs in the OS temp directory, and a failed probe names the verb that asked (`git worktree: …`) and is not cached. Concurrent `AsyncGit` callers share one probe, which runs with no caller's signal and a fixed 15 s limit; each caller waits under its own `timeoutMs` and `signal`. The first gated call can take up to the probe's time plus its own `timeoutMs`. `git.version()` and `await asyncGit.version()` return the parsed version, `{ major, minor, patch, text }`, for plain, Apple (`2.39.3 (Apple Git-146)`), Windows (`2.45.1.windows.1`) and rc builds.
|
|
21
|
+
- **Breaking:** new `GitFailureKind` `unsupported-git`. On a git older than the feature, `mergeTree` fails with it before git runs ("merge-tree --write-tree needs git 2.38 or later; found 2.34.1."), where it failed as a generic `exit` with git's usage error. On a git older than 2.34, `worktrees()` and `mergeTree()` now fail as `unsupported-git` with the feature `typed-git`. `worktrees()` worked there before; a caller that used `git.soft.worktrees()` now gets `[]` on such a git, so do not read that `[]` as "no worktrees" where it matters. The failure carries `unsupported: { feature, needs, have }`. An exhaustive `switch` over `GitFailureKind` needs the new case. `git.try` returns it and `git.soft` falls back on it, like any other failure.
|
|
22
|
+
- **Breaking:** `GitFailure.cause` is now optional (`CommandFailed | undefined`), as in `@osdlc/typed-gh`. It is absent only for `unsupported-git`, where git did not run. Read `error.cause?.result`.
|
|
23
|
+
- `worktrees()` runs `worktree list --porcelain -z` on git 2.36 or later (#381). A path holding a newline parses, and `lockReason` is the reason as written, where it came back C-quoted. Older git runs the newline form as before.
|
|
24
|
+
- **Breaking for fake runners:** a `CommandRunner` behind `worktrees()` or `mergeTree()` is now also asked for `["--version"]`. To migrate, pin the version with the new `gitVersion` option: `new Git(cwd, { runner, gitVersion: '2.55.0' })` or `cliBackend({ runner, gitVersion: '2.55.0' })`. Gated verbs then use it and never run `git --version`, `version()` returns it, and `at()` keeps it. It takes `'2.55.0'` or a whole `git version …` line, and throws a `RangeError` at construction for anything else. A fake without the pin must answer `--version` with `git version <x.y.z>`; output that is not a version line fails as `exit`.
|
|
25
|
+
- `cliBackend` does the version check. A backend other than the CLI gets every request unchecked, and answers the new `version` request kind itself (`partialBackend` rejects it with `UnsupportedRequest` when it is not implemented).
|
|
26
|
+
- New exports: `GIT_FEATURES`, `GIT_FLOOR`, `gitSupports`, `parseGitVersion`, `compareGitVersions`, and the types `GitVersion`, `GitFeature`, `GitFeatureSpec`, `GitRelease` and `UnsupportedGit`.
|
|
27
|
+
|
|
3
28
|
## 0.10.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -29,16 +29,72 @@ Node.js, on macOS, Linux and Windows. CI runs the tests and the built package
|
|
|
29
29
|
on Linux and macOS, on Node 22 and 24. Windows is supported but not tested in
|
|
30
30
|
CI yet.
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
GitHub-hosted runners ship. On 2026-10-20 that was git 2.55.0 on
|
|
34
|
-
`ubuntu-latest` (Ubuntu 24.04) and git 2.56.0 on `macos-latest` (macOS 26), as
|
|
35
|
-
the checkout step logs it. So the tested minimum is git 2.55.0. Older git may
|
|
36
|
-
work, but no test shows it. The behaviour tables below were measured against
|
|
37
|
-
git 2.50.1. A verb that needs a newer git than you have fails with git's own
|
|
38
|
-
error and throws the classified failure. `mergeTree` needs git 2.38 or later.
|
|
32
|
+
It needs git 2.34 or later, the git of Ubuntu 22.04 LTS. See [Git versions](#git-versions).
|
|
39
33
|
|
|
40
34
|
The tests run on Vitest under Node. Bun is not a tested runtime for consumers.
|
|
41
35
|
|
|
36
|
+
## Git versions
|
|
37
|
+
|
|
38
|
+
The supported floor is git 2.34, the git of Ubuntu 22.04 LTS. CI tests the
|
|
39
|
+
git that the GitHub-hosted runners ship. On 2026-10-20 that was git 2.55.0 on
|
|
40
|
+
`ubuntu-latest` (Ubuntu 24.04) and git 2.56.0 on `macos-latest` (macOS 26), as
|
|
41
|
+
the checkout step logs it. The behaviour tables below were measured against
|
|
42
|
+
git 2.50.1.
|
|
43
|
+
|
|
44
|
+
Every flag typed-git passes unconditionally is in git 2.34. A few features are
|
|
45
|
+
newer, and one table (`GIT_FEATURES`, in `src/features.ts`) lists them:
|
|
46
|
+
|
|
47
|
+
| Feature | Needs git | Used by | On an older git |
|
|
48
|
+
| --- | --- | --- | --- |
|
|
49
|
+
| `merge-tree --write-tree` | 2.38 | `mergeTree` | throws `unsupported-git` |
|
|
50
|
+
| `merge-tree --merge-base` | 2.40 | `mergeTree({ mergeBase })` | throws `unsupported-git` |
|
|
51
|
+
| `worktree list -z` | 2.36 | `worktrees` | newline-split `worktree list --porcelain`: a path with a newline breaks it, and a lock reason comes back C-quoted |
|
|
52
|
+
|
|
53
|
+
A verb that uses one of these runs `git --version` first, once per runner,
|
|
54
|
+
and caches the answer. A client that never calls such a verb never runs it.
|
|
55
|
+
`git.version()` (and `await asyncGit.version()`) returns the same parsed
|
|
56
|
+
version: `{ major, minor, patch, text }`, where `text` keeps a vendor suffix
|
|
57
|
+
such as `2.39.3 (Apple Git-146)` or `2.45.1.windows.1`.
|
|
58
|
+
|
|
59
|
+
The answer is cached per runner and per effective `PATH` (the call's `env`
|
|
60
|
+
over the client's over the process's; `PATHEXT` too on Windows), because the
|
|
61
|
+
default runner runs whichever `git` that `PATH` finds. The probe runs in the
|
|
62
|
+
OS temp directory, so a missing cwd cannot fail it; the verb itself still
|
|
63
|
+
runs in its own cwd. A failed probe is not cached, and its failure names the
|
|
64
|
+
verb that asked (`git worktree: …`), not `--version`.
|
|
65
|
+
|
|
66
|
+
`AsyncGit` callers that probe at the same time share one probe. It runs with
|
|
67
|
+
no caller's `signal` and a fixed 15 s limit. Each caller waits under its own
|
|
68
|
+
`timeoutMs` and `signal`, so one that gives up rejects alone. The sync client
|
|
69
|
+
probes under the call's `timeoutMs` (15 s at most). Either way the first gated
|
|
70
|
+
call can take up to the probe's time plus its own `timeoutMs`.
|
|
71
|
+
|
|
72
|
+
The `gitVersion` option pins the version instead: `new Git(cwd, { runner,
|
|
73
|
+
gitVersion: "2.55.0" })`, or `cliBackend({ runner, gitVersion: "2.55.0" })`.
|
|
74
|
+
It takes a version string, either `"2.55.0"` or a whole
|
|
75
|
+
`"git version 2.39.3 (Apple Git-146)"` line. Gated verbs then use it and
|
|
76
|
+
never run `git --version`, `version()` returns it, and `at()` keeps it. An
|
|
77
|
+
unparsable value throws a `RangeError` when the client or backend is built.
|
|
78
|
+
It is the way to put a fake runner behind a gated verb, and to test either
|
|
79
|
+
side of a feature.
|
|
80
|
+
|
|
81
|
+
On a git older than a feature, a verb with a fallback runs it, and one
|
|
82
|
+
without fails as `unsupported-git` before git runs:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const r = git.try.mergeTree("main", "topic");
|
|
86
|
+
if (!r.ok && r.error.kind === "unsupported-git") {
|
|
87
|
+
// r.error.message: "merge-tree --write-tree needs git 2.38 or later; found 2.34.1."
|
|
88
|
+
// r.error.unsupported: { feature, needs, have }
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Below 2.34 every one of these verbs fails that way, with the feature
|
|
93
|
+
`typed-git`, and no fallback is tried. Verbs that need no newer feature run
|
|
94
|
+
on any git without a version check. A backend other than `cliBackend` has no
|
|
95
|
+
git version, so `AsyncGit` checks nothing for it; it answers or rejects each
|
|
96
|
+
request itself.
|
|
97
|
+
|
|
42
98
|
## Stability
|
|
43
99
|
|
|
44
100
|
The package is on the 0.x line. A breaking change ships only in a new minor
|
|
@@ -141,7 +197,8 @@ use(r.value);
|
|
|
141
197
|
The error is a `GitFailure`: a `Failure` from `@osdlc/result` with a `kind` to
|
|
142
198
|
branch on, a one-line `message` and a `hint` for a person (`describe(error)`
|
|
143
199
|
joins them), git's own output in `detail`, the `argv` and `exitCode`, and the
|
|
144
|
-
`CommandFailed` it was read from in `cause`.
|
|
200
|
+
`CommandFailed` it was read from in `cause`. An `unsupported-git` failure has
|
|
201
|
+
no `cause`, because git did not run; it carries `unsupported` instead.
|
|
145
202
|
|
|
146
203
|
The methods that throw (`git.push()` and the rest) throw the same failure,
|
|
147
204
|
wrapped in a `FailureError` (`error.failure`). So a CLI that reports a thrown
|
|
@@ -161,6 +218,7 @@ line for a failure from `git.try.*`.
|
|
|
161
218
|
| `not-authenticated` | `Authentication failed`, `Permission denied (publickey)`, `could not read Username`, `unable to access` with HTTP 401 or 403 | `The remote refused the credentials.` / `Check that you are signed in to the host, or that your SSH key is added.` |
|
|
162
219
|
| `not-found` | `unable to access` with HTTP 404 | `The remote repository was not found, or you cannot see it.` / `Check the remote URL, and that your account can see the repository.` |
|
|
163
220
|
| `tls` | `unable to access` with `SSL certificate problem` | `The remote's TLS certificate could not be verified.` / `Check the system clock and CA certificates, or the remote's certificate.` |
|
|
221
|
+
| `unsupported-git` | the local git is older than the verb needs (see [Git versions](#git-versions)); git did not run, so there is no `cause` | `merge-tree --write-tree needs git 2.38 or later; found 2.34.1.` / `Upgrade git to 2.38 or later from https://git-scm.com.` |
|
|
164
222
|
| `not-executable`, `bad-cwd`, `timeout`, `output-cap`, `signal`, `aborted`, `spawn` | as in `@osdlc/command-seam` | command-seam's message, no hint |
|
|
165
223
|
| `exit` | any other non-zero exit | git's first stderr line |
|
|
166
224
|
|
|
@@ -541,6 +599,7 @@ exit throws the classified failure.
|
|
|
541
599
|
| `resolveRef(ref)` | `rev-parse --verify --quiet <ref>` | `1` → `null` |
|
|
542
600
|
| `hasHistory()` | `resolveRef("HEAD") !== null` | — |
|
|
543
601
|
| `headRef()` | `rev-parse --abbrev-ref HEAD` | none — literal `"HEAD"` when detached |
|
|
602
|
+
| `version()` | `--version`, once per runner | none — `{ major, minor, patch, text }`; see [Git versions](#git-versions) |
|
|
544
603
|
| `topLevel()` | `rev-parse --show-toplevel` | `128` → `null` (not a repository) |
|
|
545
604
|
| `gitCommonDir()` | `rev-parse --path-format=absolute --git-common-dir` | `128` → `null` |
|
|
546
605
|
| `gitDir()` | `rev-parse --absolute-git-dir` | `128` → `null` — this worktree's own dir, `<common>/worktrees/<name>` in a linked worktree |
|
|
@@ -553,7 +612,7 @@ exit throws the classified failure.
|
|
|
553
612
|
| `hasStagedChanges()` | `diff --cached --quiet` | `1` → `true`, `0` → `false` — on an unborn HEAD the index is compared against the empty tree; outside a repository (`129`) it throws |
|
|
554
613
|
| `branches(pattern)` | `branch --list --format=%(refname:lstrip=2)` | none |
|
|
555
614
|
| `branchExists(name)` | `branches(name).includes(name)` | none |
|
|
556
|
-
| `worktrees()` | `worktree list --porcelain` | none — rows carry `locked` and `lockReason` |
|
|
615
|
+
| `worktrees()` | `worktree list --porcelain -z` (git 2.36; the newline form before) | none — rows carry `locked` and `lockReason` |
|
|
557
616
|
| `mergeBase(a, b)` | `merge-base <a> <b>` | `1` → `null` (unrelated histories) |
|
|
558
617
|
| `logSubject(ref)` | `log -1 --format=%s <ref>` | `128` → `null` |
|
|
559
618
|
| `configGet(key, { scope })` | `config [--local\|--global\|--system] --get <key>` | `1` → `null` (unset) |
|
|
@@ -581,6 +640,8 @@ exit throws the classified failure.
|
|
|
581
640
|
| `grep(pattern, { extendedRegexp, lineNumber, noColor, paths })` | `grep` | `1` → `[]` (no match) |
|
|
582
641
|
| `isAncestor(a, b)` | `merge-base --is-ancestor` | `1` → `false` |
|
|
583
642
|
| `aheadBehind(base, tip)` | `rev-list --left-right --count <base>...<tip>` | none |
|
|
643
|
+
| `cherry(upstream, head)` | `cherry <upstream> [<head>]` | none — `{ sha, equivalent }` per commit; empty output is `[]`, an unreadable line throws |
|
|
644
|
+
| `commitTree(tree, { parents, message })` | `commit-tree <tree> [-p <parent>]... -m <message>` | none — writes an object and no ref; needs a git identity |
|
|
584
645
|
| `remotes()` | `remote` | none — names, not remotes |
|
|
585
646
|
| `remote()` | `remote` | none — deprecated alias of `remotes()` |
|
|
586
647
|
| `remoteGetUrl(name, { push })` | `remote get-url [--push] <name>` | `2` → `null` (unknown remote) — the first URL |
|
|
@@ -713,6 +774,18 @@ The default runner finds `git` on absolute `PATH` entries only, so a file named
|
|
|
713
774
|
`git` in the checkout cannot run in its place. A real runner you build yourself
|
|
714
775
|
should do the same: `spawnRunner("git", { absolutePathOnly: true })`.
|
|
715
776
|
|
|
777
|
+
A fake runner behind a version-gated verb (`worktrees`, `mergeTree`; see
|
|
778
|
+
[Git versions](#git-versions)) would also be asked for `git --version`. Pin
|
|
779
|
+
the version so it is not:
|
|
780
|
+
|
|
781
|
+
```ts
|
|
782
|
+
const git = new Git("/nowhere", { runner: recording, gitVersion: "2.55.0" });
|
|
783
|
+
git.worktrees(); // runs `worktree list --porcelain -z`, and no `--version`
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
A fake without the pin must answer `["--version"]` (once per runner) with
|
|
787
|
+
`git version <x.y.z>`, or the gated verb fails as `exit`.
|
|
788
|
+
|
|
716
789
|
`runner: undefined` is the same as omitting it, so a caller holding an optional
|
|
717
790
|
runner passes it straight through, without a conditional spread. `cliBackend`
|
|
718
791
|
accepts it too.
|
|
@@ -749,7 +822,9 @@ Use it for a remote read from a checkout (any host); use `parseGitUrl` /
|
|
|
749
822
|
host and any other alike. It tries `parseGitUrl` first, so shorthand reads as
|
|
750
823
|
GitHub and a GitLab nested group stays whole in `owner`, then falls back to
|
|
751
824
|
`parseRemoteUrl`, so a GitHub Enterprise or self-hosted Forgejo remote
|
|
752
|
-
answers too. `host` is lower-cased and carries no port
|
|
825
|
+
answers too. `host` is lower-cased and carries no port, and GitHub's other
|
|
826
|
+
names for itself (`ssh.github.com`, its SSH over port 443, and
|
|
827
|
+
`www.github.com`) read as `github.com`. Decide which forge a
|
|
753
828
|
remote is on from `host`, not from the URL text.
|
|
754
829
|
|
|
755
830
|
```ts
|
|
@@ -757,6 +832,8 @@ parseRemoteRepo("git@github.com:acme/widgets.git");
|
|
|
757
832
|
// { host: "github.com", owner: "acme", repo: "widgets" }
|
|
758
833
|
parseRemoteRepo("https://forge.example.com:3000/team/app.git");
|
|
759
834
|
// { host: "forge.example.com", owner: "team", repo: "app" }
|
|
835
|
+
parseRemoteRepo("ssh://git@ssh.github.com:443/acme/widgets.git");
|
|
836
|
+
// { host: "github.com", owner: "acme", repo: "widgets" }
|
|
760
837
|
parseRemoteRepo("/srv/git/repo.git"); // null — a local path names no project
|
|
761
838
|
```
|
|
762
839
|
|
package/dist/async.d.ts
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { CommandResult } from '@osdlc/command-seam';
|
|
16
16
|
import { type GitBackend, type GitCallOptions } from './backend.ts';
|
|
17
|
+
import type { GitVersion } from './git-version.ts';
|
|
17
18
|
import { type Soft, type TriedAsync } from './outcome.ts';
|
|
18
19
|
import { type RemoteCoordinate } from './remote-url.ts';
|
|
19
|
-
import { type AddOptions, type AheadBehind, type CommitOptions, type CheckoutOptions, type ConfigGetOptions, type CloneOptions, type ConflictSide, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type TaggedFile, type UnmergedEntry, type ConfigSetOptions, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffTextOptions, type DiffTreeOptions, type FetchOptions, type ForEachRefOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type NumstatEntry, type PushPorcelainOptions, type PushReport, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, type GcOptions, type PushOptions, type RemoteSetBranchesOptions, type RemoteSetHeadOptions } from './verbs.ts';
|
|
20
|
+
import { type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CommitOptions, type CheckoutOptions, type ConfigGetOptions, type CloneOptions, type ConflictSide, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type TaggedFile, type UnmergedEntry, type ConfigSetOptions, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffTextOptions, type DiffTreeOptions, type FetchOptions, type ForEachRefOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type NumstatEntry, type PushPorcelainOptions, type PushReport, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, type GcOptions, type PushOptions, type RemoteSetBranchesOptions, type RemoteSetHeadOptions } from './verbs.ts';
|
|
20
21
|
/** A typed, awaitable git client bound to one working directory. */
|
|
21
22
|
export declare class AsyncGit {
|
|
22
23
|
readonly cwd: string;
|
|
@@ -74,6 +75,14 @@ export declare class AsyncGit {
|
|
|
74
75
|
rawChecked(argv: string[], opts?: GitCallOptions & {
|
|
75
76
|
input?: string | undefined;
|
|
76
77
|
}): Promise<CommandResult>;
|
|
78
|
+
/**
|
|
79
|
+
* The git the backend runs, from `git --version`; see {@link Git.version}.
|
|
80
|
+
* `cliBackend` probes once per runner and caches it, or returns its
|
|
81
|
+
* `gitVersion` option without running anything. A non-CLI backend has
|
|
82
|
+
* no git version unless it answers the `version` request itself;
|
|
83
|
+
* `partialBackend` rejects it with `UnsupportedRequest` otherwise.
|
|
84
|
+
*/
|
|
85
|
+
version(opts?: GitCallOptions): Promise<GitVersion>;
|
|
77
86
|
/** A file's content at a rev, null if absent. */
|
|
78
87
|
showAtRev(rev: string, relPath: string, opts?: GitCallOptions): Promise<string | null>;
|
|
79
88
|
/** A file's content at a rev, rejecting when the path is missing. See {@link Git.showAtRevChecked}. */
|
|
@@ -215,6 +224,13 @@ export declare class AsyncGit {
|
|
|
215
224
|
isAncestor(a: string, b: string, opts?: GitCallOptions): Promise<boolean>;
|
|
216
225
|
/** How far `tip` has diverged from `base`. See {@link AheadBehind}. */
|
|
217
226
|
aheadBehind(base: string, tip: string, opts?: GitCallOptions): Promise<AheadBehind>;
|
|
227
|
+
/**
|
|
228
|
+
* Commits on `head` (default `HEAD`) that `upstream` lacks, each marked by
|
|
229
|
+
* whether `upstream` has the same patch. See {@link CherryEntry}.
|
|
230
|
+
*/
|
|
231
|
+
cherry(upstream: string, head?: string, opts?: GitCallOptions): Promise<CherryEntry[]>;
|
|
232
|
+
/** Write a commit for `tree` and return its sha; no ref moves. Needs a git identity. */
|
|
233
|
+
commitTree(tree: string, commitOpts: CommitTreeOptions, opts?: GitCallOptions): Promise<string>;
|
|
218
234
|
/** Configured remote names (`git remote`); `[]` when there are none. */
|
|
219
235
|
remotes(opts?: GitCallOptions): Promise<string[]>;
|
|
220
236
|
/**
|
package/dist/async.js
CHANGED
|
@@ -97,6 +97,16 @@ export class AsyncGit {
|
|
|
97
97
|
return this.backend.execute(this.cwd, { kind: 'raw', argv, checked: true, input: opts.input }, opts);
|
|
98
98
|
}
|
|
99
99
|
// ── queries ───────────────────────────────────────────────────────────────
|
|
100
|
+
/**
|
|
101
|
+
* The git the backend runs, from `git --version`; see {@link Git.version}.
|
|
102
|
+
* `cliBackend` probes once per runner and caches it, or returns its
|
|
103
|
+
* `gitVersion` option without running anything. A non-CLI backend has
|
|
104
|
+
* no git version unless it answers the `version` request itself;
|
|
105
|
+
* `partialBackend` rejects it with `UnsupportedRequest` otherwise.
|
|
106
|
+
*/
|
|
107
|
+
version(opts = {}) {
|
|
108
|
+
return this.backend.execute(this.cwd, { kind: 'version' }, opts);
|
|
109
|
+
}
|
|
100
110
|
/** A file's content at a rev, null if absent. */
|
|
101
111
|
showAtRev(rev, relPath, opts = {}) {
|
|
102
112
|
return this.backend.execute(this.cwd, { kind: 'showAtRev', rev, relPath }, opts);
|
|
@@ -363,6 +373,17 @@ export class AsyncGit {
|
|
|
363
373
|
aheadBehind(base, tip, opts = {}) {
|
|
364
374
|
return this.backend.execute(this.cwd, { kind: 'aheadBehind', base, tip }, opts);
|
|
365
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Commits on `head` (default `HEAD`) that `upstream` lacks, each marked by
|
|
378
|
+
* whether `upstream` has the same patch. See {@link CherryEntry}.
|
|
379
|
+
*/
|
|
380
|
+
cherry(upstream, head, opts = {}) {
|
|
381
|
+
return this.backend.execute(this.cwd, { kind: 'cherry', upstream, head }, opts);
|
|
382
|
+
}
|
|
383
|
+
/** Write a commit for `tree` and return its sha; no ref moves. Needs a git identity. */
|
|
384
|
+
commitTree(tree, commitOpts, opts = {}) {
|
|
385
|
+
return this.backend.execute(this.cwd, { kind: 'commitTree', tree, ...commitOpts }, opts);
|
|
386
|
+
}
|
|
366
387
|
/** Configured remote names (`git remote`); `[]` when there are none. */
|
|
367
388
|
remotes(opts = {}) {
|
|
368
389
|
return this.backend.execute(this.cwd, { kind: 'remote' }, opts);
|
package/dist/backend.d.ts
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* `cliBackend` and `AsyncGit` are stable.
|
|
19
19
|
*/
|
|
20
20
|
import { type AsyncCommandRunner, type CommandResult } from '@osdlc/command-seam';
|
|
21
|
-
import { type
|
|
21
|
+
import { type GitVersion } from './git-version.ts';
|
|
22
|
+
import { type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CheckoutOptions, type CloneOptions, type CommitOptions, type ConfigGetOptions, type ConfigSetOptions, type ConflictSide, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffTextOptions, type DiffTreeOptions, type FetchOptions, type ForEachRefOptions, type GcOptions, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type NumstatEntry, type PushOptions, type PushPorcelainOptions, type PushReport, type RemoteSetBranchesOptions, type RemoteSetHeadOptions, type WorktreeAddOptions, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type TaggedFile, type UnmergedEntry, type Worktree, type WorktreeMoveOptions } from './verbs.ts';
|
|
22
23
|
/** Per-call concerns that are not part of the operation itself. */
|
|
23
24
|
export interface GitCallOptions {
|
|
24
25
|
/**
|
|
@@ -57,6 +58,8 @@ export interface GitCallOptions {
|
|
|
57
58
|
* @experimental Each new verb adds a kind, in a minor release.
|
|
58
59
|
*/
|
|
59
60
|
export type GitRequest = {
|
|
61
|
+
kind: 'version';
|
|
62
|
+
} | {
|
|
60
63
|
kind: 'showAtRev';
|
|
61
64
|
rev: string;
|
|
62
65
|
relPath: string;
|
|
@@ -129,7 +132,14 @@ export type GitRequest = {
|
|
|
129
132
|
kind: 'aheadBehind';
|
|
130
133
|
base: string;
|
|
131
134
|
tip: string;
|
|
135
|
+
} | {
|
|
136
|
+
kind: 'cherry';
|
|
137
|
+
upstream: string;
|
|
138
|
+
head?: string | undefined;
|
|
132
139
|
} | ({
|
|
140
|
+
kind: 'commitTree';
|
|
141
|
+
tree: string;
|
|
142
|
+
} & CommitTreeOptions) | ({
|
|
133
143
|
kind: 'lsFiles';
|
|
134
144
|
} & LsFilesOptions) | {
|
|
135
145
|
kind: 'lsFilesTagged';
|
|
@@ -287,6 +297,7 @@ export type GitRequest = {
|
|
|
287
297
|
* @experimental It grows with {@link GitRequest}.
|
|
288
298
|
*/
|
|
289
299
|
export interface GitResults {
|
|
300
|
+
version: GitVersion;
|
|
290
301
|
showAtRev: string | null;
|
|
291
302
|
showAtRevChecked: string;
|
|
292
303
|
revParse: string | null;
|
|
@@ -312,6 +323,8 @@ export interface GitResults {
|
|
|
312
323
|
checkIgnoreVerbose: IgnoreMatch[];
|
|
313
324
|
isAncestor: boolean;
|
|
314
325
|
aheadBehind: AheadBehind;
|
|
326
|
+
cherry: CherryEntry[];
|
|
327
|
+
commitTree: string;
|
|
315
328
|
lsFiles: string[];
|
|
316
329
|
lsFilesTagged: TaggedFile[];
|
|
317
330
|
forEachRef: string[];
|
|
@@ -375,6 +388,12 @@ export type GitRequestKind = GitRequest['kind'];
|
|
|
375
388
|
* config key. It rejects with the classified failure — or whatever error the backend
|
|
376
389
|
* considers equivalent — when git failed rather than answered.
|
|
377
390
|
*
|
|
391
|
+
* The git version check is `cliBackend`'s: it probes `git --version` before
|
|
392
|
+
* a request whose verb needs a newer git (see `features.ts`) and rejects with
|
|
393
|
+
* the `unsupported-git` failure when the git is too old. Another backend has
|
|
394
|
+
* no git version to check, so it gets every request and decides itself. It
|
|
395
|
+
* may reject one with that same failure, or with {@link UnsupportedRequest}.
|
|
396
|
+
*
|
|
378
397
|
* @experimental New request kinds land in minor releases. Use
|
|
379
398
|
* {@link partialBackend} rather than an exhaustive switch.
|
|
380
399
|
*/
|
|
@@ -409,6 +428,13 @@ export declare function cliBackend(opts?: {
|
|
|
409
428
|
* `GIT_SSH_COMMAND` once, instead of passing it on every call.
|
|
410
429
|
*/
|
|
411
430
|
env?: Record<string, string> | undefined;
|
|
431
|
+
/**
|
|
432
|
+
* Pins the git version: `'2.55.0'`, or a whole `git version …` line.
|
|
433
|
+
* Version-gated requests then use it and never run `git --version`, and
|
|
434
|
+
* the `version` request returns it. Set it with a fake runner. An
|
|
435
|
+
* unparsable value throws a `RangeError` here.
|
|
436
|
+
*/
|
|
437
|
+
gitVersion?: string | undefined;
|
|
412
438
|
}): GitBackend;
|
|
413
439
|
/**
|
|
414
440
|
* Wrap a partial implementation: any request kind the object does not handle
|
package/dist/backend.js
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* `cliBackend` and `AsyncGit` are stable.
|
|
19
19
|
*/
|
|
20
20
|
import { spawnRunnerAsync, } from '@osdlc/command-seam';
|
|
21
|
+
import { versionedVerb } from "./features.js";
|
|
22
|
+
import { pinnedGitVersion, probeGitVersionAsync, versionVerb, } from "./git-version.js";
|
|
21
23
|
import * as v from "./verbs.js";
|
|
22
24
|
import { gate, mergeEnv, repoPrefix, } from "./verbs.js";
|
|
23
25
|
/** Thrown by a backend asked for an operation it cannot perform. */
|
|
@@ -32,6 +34,8 @@ export class UnsupportedRequest extends Error {
|
|
|
32
34
|
/** Translate a request into the CLI verb that performs it. */
|
|
33
35
|
function toVerb(request) {
|
|
34
36
|
switch (request.kind) {
|
|
37
|
+
case 'version':
|
|
38
|
+
return versionVerb();
|
|
35
39
|
case 'showAtRev':
|
|
36
40
|
return v.showAtRev(request.rev, request.relPath);
|
|
37
41
|
case 'showAtRevChecked':
|
|
@@ -78,6 +82,10 @@ function toVerb(request) {
|
|
|
78
82
|
return v.isAncestor(request.a, request.b);
|
|
79
83
|
case 'aheadBehind':
|
|
80
84
|
return v.aheadBehind(request.base, request.tip);
|
|
85
|
+
case 'cherry':
|
|
86
|
+
return v.cherry(request.upstream, request.head);
|
|
87
|
+
case 'commitTree':
|
|
88
|
+
return v.commitTree(request.tree, request);
|
|
81
89
|
case 'checkIgnore':
|
|
82
90
|
return v.checkIgnore(request.relPaths);
|
|
83
91
|
case 'checkIgnoreVerbose':
|
|
@@ -205,10 +213,21 @@ function toVerb(request) {
|
|
|
205
213
|
*/
|
|
206
214
|
export function cliBackend(opts = {}) {
|
|
207
215
|
const runner = opts.runner ?? spawnRunnerAsync('git', { absolutePathOnly: true });
|
|
216
|
+
const pinned = pinnedGitVersion(opts.gitVersion);
|
|
217
|
+
// A failed probe names `report`: the gated verb's argv, so a missing git
|
|
218
|
+
// reads `git worktree: …` rather than `git --version: …`.
|
|
219
|
+
const versionOf = (run, report) => pinned === undefined
|
|
220
|
+
? probeGitVersionAsync(runner, {
|
|
221
|
+
env: run.env,
|
|
222
|
+
timeoutMs: run.timeoutMs,
|
|
223
|
+
signal: run.signal,
|
|
224
|
+
report,
|
|
225
|
+
})
|
|
226
|
+
: Promise.resolve(pinned);
|
|
208
227
|
const prefix = repoPrefix(opts.gitDir, opts.workTree);
|
|
209
228
|
return {
|
|
210
229
|
async execute(cwd, request, callOpts = {}) {
|
|
211
|
-
const
|
|
230
|
+
const gated = toVerb(request);
|
|
212
231
|
const runOpts = { cwd };
|
|
213
232
|
if (callOpts.timeoutMs !== undefined)
|
|
214
233
|
runOpts.timeoutMs = callOpts.timeoutMs;
|
|
@@ -220,6 +239,17 @@ export function cliBackend(opts = {}) {
|
|
|
220
239
|
const env = mergeEnv(opts.env, callOpts.env);
|
|
221
240
|
if (env !== undefined)
|
|
222
241
|
runOpts.env = env;
|
|
242
|
+
const req = request;
|
|
243
|
+
// `version` is answered from the per-runner cache, like the probe a
|
|
244
|
+
// version-gated verb makes.
|
|
245
|
+
if (req.kind === 'version') {
|
|
246
|
+
return (await versionOf(runOpts, ['--version']));
|
|
247
|
+
}
|
|
248
|
+
// A verb that needs a git feature runs in the form this git supports,
|
|
249
|
+
// or rejects as `unsupported-git`. Others never probe.
|
|
250
|
+
const verb = gated.needs === undefined
|
|
251
|
+
? gated
|
|
252
|
+
: versionedVerb(gated, await versionOf(runOpts, [...prefix, ...gated.argv]), prefix);
|
|
223
253
|
if (verb.input !== undefined)
|
|
224
254
|
runOpts.input = verb.input;
|
|
225
255
|
// The verb's own entries (the C locale) win over the backend's and the call's.
|
|
@@ -230,10 +260,9 @@ export function cliBackend(opts = {}) {
|
|
|
230
260
|
// Unchecked `raw` is the only request that skips `gate`: it returns the
|
|
231
261
|
// result at any exit code. Everything else goes through the same `gate`
|
|
232
262
|
// the sync client uses.
|
|
233
|
-
const
|
|
234
|
-
const gated = req.kind !== 'raw' || req.checked === true;
|
|
263
|
+
const checked = req.kind !== 'raw' || req.checked === true;
|
|
235
264
|
// The prefixed argv is what ran, so it is what a `CommandFailed` reports.
|
|
236
|
-
const value =
|
|
265
|
+
const value = checked ? gate(verb, result, argv) : verb.parse(result, argv);
|
|
237
266
|
// `GitResults` restates the verb table's return types for callers. The
|
|
238
267
|
// two are kept in step by hand, and this cast is where they meet.
|
|
239
268
|
return value;
|
package/dist/client.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ export { parseRemoteUrl, type RemoteCoordinate } from './remote-url.ts';
|
|
|
20
20
|
export { cliBackend, partialBackend, UnsupportedRequest, type GitBackend, type GitCallOptions, type GitRequest, type GitRequestKind, type GitResults, } from './backend.ts';
|
|
21
21
|
export { classifyGitFailure, describeGitFailure, type GitFailure, type GitFailureKind, } from './failure.ts';
|
|
22
22
|
export { type Soft, type TriedAsync, type TriedSync } from './outcome.ts';
|
|
23
|
-
export {
|
|
23
|
+
export { GIT_FEATURES, GIT_FLOOR, gitSupports, type GitFeature, type GitFeatureSpec, type GitRelease, type UnsupportedGit, } from './features.ts';
|
|
24
|
+
export { compareGitVersions, parseGitVersion, type GitVersion } from './git-version.ts';
|
|
25
|
+
export { forceWithLeaseArg, parseRefRows, REF_FORMAT, type AddOptions, type AheadBehind, type CherryEntry, type CommitTreeOptions, type CheckoutOptions, type CleanOptions, type CloneOptions, type CommitFlags, type CommitOptions, type ConfigGetOptions, type ConfigScope, type ConfigSetOptions, type ConflictSide, type DiffCheckOptions, type DiffCheckResult, type DiffEntry, type DiffNameOnlyOptions, type DiffNameStatusOptions, type DiffStatOptions, type DiffTextOptions, type DiffTreeOptions, type FetchOptions, type ForEachRefOptions, type ForceLease, type GcOptions, type GrepOptions, type InitOptions, type IntegrationOutcome, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type NumstatEntry, type PushFlag, type PushOptions, type PushPorcelainOptions, type PushRefResult, type PushRejection, type PushReport, type RebaseOptions, type RebaseOutcome, type RemoteGetUrlOptions, type RemoteRef, type RemoteSetBranchesOptions, type RemoteSetHeadOptions, type StatusEntry, type StatusPorcelainOptions, type TaggedFile, type TreeEntry, type UnmergedEntry, type Worktree, type WorktreeAddOptions, type WorktreeMoveOptions, } from './verbs.ts';
|
|
24
26
|
export { asAsync, CommandFailed, runChecked, runCheckedAsync, spawnRunner, spawnRunnerAsync, type AsyncCommandRunner, type AsyncCommandRunOptions, type CommandResult, type CommandRunner, type CommandRunOptions, } from '@osdlc/command-seam';
|
package/dist/client.js
CHANGED
|
@@ -20,6 +20,8 @@ export { parseRemoteUrl } from "./remote-url.js";
|
|
|
20
20
|
export { cliBackend, partialBackend, UnsupportedRequest, } from "./backend.js";
|
|
21
21
|
export { classifyGitFailure, describeGitFailure, } from "./failure.js";
|
|
22
22
|
export {} from "./outcome.js";
|
|
23
|
+
export { GIT_FEATURES, GIT_FLOOR, gitSupports, } from "./features.js";
|
|
24
|
+
export { compareGitVersions, parseGitVersion } from "./git-version.js";
|
|
23
25
|
export { forceWithLeaseArg, parseRefRows, REF_FORMAT, } from "./verbs.js";
|
|
24
26
|
// The command-seam exports are re-exported so a caller wiring a runner or catching
|
|
25
27
|
// a failure needs one import, not two. `@osdlc/command-seam` is the package
|
package/dist/failure.d.ts
CHANGED
|
@@ -7,9 +7,14 @@
|
|
|
7
7
|
* non-English locale git translates its messages. Those keep command-seam's
|
|
8
8
|
* kind, so an unrecognised failure is still an `exit` with git's first stderr
|
|
9
9
|
* line as its message, never a wrong git kind.
|
|
10
|
+
*
|
|
11
|
+
* One kind is not read from git's output: `unsupported-git`, which a client
|
|
12
|
+
* reports before it runs a verb the local git is too old for (see
|
|
13
|
+
* `./features.ts`).
|
|
10
14
|
*/
|
|
11
15
|
import { type CommandFailed, type CommandFailureKind } from '@osdlc/command-seam';
|
|
12
16
|
import { type Failure } from '@osdlc/result';
|
|
17
|
+
import type { UnsupportedGit } from './features.ts';
|
|
13
18
|
/**
|
|
14
19
|
* Why a git call failed:
|
|
15
20
|
*
|
|
@@ -29,9 +34,13 @@ import { type Failure } from '@osdlc/result';
|
|
|
29
34
|
* - `tls`: the TLS handshake failed ("unable to access … SSL certificate
|
|
30
35
|
* problem"). The host was reached, so this is not `remote-unreachable`, and
|
|
31
36
|
* retrying will not help until the clock, the CA certificates or the remote's
|
|
32
|
-
* certificate is fixed
|
|
37
|
+
* certificate is fixed;
|
|
38
|
+
* - `unsupported-git`: the local git is older than the verb needs ("merge-tree
|
|
39
|
+
* --write-tree needs git 2.38 or later; found 2.34.1"), or older than the
|
|
40
|
+
* 2.34 floor. The verb did not run. `unsupported` says which feature, and
|
|
41
|
+
* which git it needs and found.
|
|
33
42
|
*/
|
|
34
|
-
export type GitFailureKind = CommandFailureKind | 'not-a-repo' | 'no-remote' | 'remote-unreachable' | 'not-authenticated' | 'not-found' | 'tls';
|
|
43
|
+
export type GitFailureKind = CommandFailureKind | 'not-a-repo' | 'no-remote' | 'remote-unreachable' | 'not-authenticated' | 'not-found' | 'tls' | 'unsupported-git';
|
|
35
44
|
/** A failed git call. `message` is one line for a person; `detail` is git's own output. */
|
|
36
45
|
export interface GitFailure extends Failure<GitFailureKind> {
|
|
37
46
|
/** The binary that ran (`git`), when the runner reports one. */
|
|
@@ -42,8 +51,13 @@ export interface GitFailure extends Failure<GitFailureKind> {
|
|
|
42
51
|
exitCode: number | null;
|
|
43
52
|
/** The signal that ended git, when the runner knows it. */
|
|
44
53
|
signal?: NodeJS.Signals | null | undefined;
|
|
45
|
-
/**
|
|
46
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The `CommandFailed` this was classified from. Absent for
|
|
56
|
+
* `unsupported-git`, where the verb never ran.
|
|
57
|
+
*/
|
|
58
|
+
cause?: CommandFailed | undefined;
|
|
59
|
+
/** For `unsupported-git`: the feature, the git it needs, and the git found. */
|
|
60
|
+
unsupported?: UnsupportedGit | undefined;
|
|
47
61
|
}
|
|
48
62
|
/** The git failure for a failed `git` run. */
|
|
49
63
|
export declare function classifyGitFailure(failed: CommandFailed): GitFailure;
|
package/dist/failure.js
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* non-English locale git translates its messages. Those keep command-seam's
|
|
8
8
|
* kind, so an unrecognised failure is still an `exit` with git's first stderr
|
|
9
9
|
* line as its message, never a wrong git kind.
|
|
10
|
+
*
|
|
11
|
+
* One kind is not read from git's output: `unsupported-git`, which a client
|
|
12
|
+
* reports before it runs a verb the local git is too old for (see
|
|
13
|
+
* `./features.ts`).
|
|
10
14
|
*/
|
|
11
15
|
import { classifyFailed, isCommandFailed, } from '@osdlc/command-seam';
|
|
12
16
|
import { describe, FailureError, isFailure } from '@osdlc/result';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The git feature table: the one place that says which git release each
|
|
3
|
+
* version-dependent feature needs, and which of them have a fallback.
|
|
4
|
+
*
|
|
5
|
+
* A verb that uses one of these features names it in `needs` (see `GitVerb`
|
|
6
|
+
* in `./verbs.ts`). Before such a verb runs, the client probes the git version
|
|
7
|
+
* once per runner (`./git-version.ts`) and calls {@link versionedVerb}, which
|
|
8
|
+
* picks the verb's own form, its `fallback` form, or throws the
|
|
9
|
+
* `unsupported-git` failure. No other module compares versions.
|
|
10
|
+
*
|
|
11
|
+
* Every feature at or below {@link GIT_FLOOR} is used without a check. Below
|
|
12
|
+
* the floor itself, every version-gated verb fails as `unsupported-git` with
|
|
13
|
+
* the feature `typed-git`, and no fallback is tried.
|
|
14
|
+
*
|
|
15
|
+
* The README's "Git versions" table is checked against this one by
|
|
16
|
+
* `tests/features.test.ts`.
|
|
17
|
+
*/
|
|
18
|
+
import { type GitFailure } from './failure.ts';
|
|
19
|
+
import { type GitVersion } from './git-version.ts';
|
|
20
|
+
import type { GitVerb } from './verbs.ts';
|
|
21
|
+
/** A `major.minor.patch` release, without the `text` a probed version carries. */
|
|
22
|
+
export type GitRelease = Pick<GitVersion, 'major' | 'minor' | 'patch'>;
|
|
23
|
+
/**
|
|
24
|
+
* The oldest git this package supports: 2.34, the git of Ubuntu 22.04 LTS.
|
|
25
|
+
* Every flag typed-git passes unconditionally is at least this old.
|
|
26
|
+
*/
|
|
27
|
+
export declare const GIT_FLOOR: GitRelease;
|
|
28
|
+
/** One row of {@link GIT_FEATURES}. */
|
|
29
|
+
export interface GitFeatureSpec {
|
|
30
|
+
/** The first git release with the feature. */
|
|
31
|
+
readonly minimum: GitRelease;
|
|
32
|
+
/** The methods that use it. */
|
|
33
|
+
readonly usedBy: readonly string[];
|
|
34
|
+
/**
|
|
35
|
+
* What runs instead on an older git, for a feature whose older form gives
|
|
36
|
+
* the same answer. A feature without one fails as `unsupported-git`.
|
|
37
|
+
*/
|
|
38
|
+
readonly fallback?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Every git feature newer than {@link GIT_FLOOR} that typed-git uses.
|
|
42
|
+
*
|
|
43
|
+
* - `merge-tree --write-tree`: git 2.38 ("git merge-tree" learned a new mode
|
|
44
|
+
* that computes the merge tree, RelNotes/2.38.0). `--name-only` and `-z`
|
|
45
|
+
* arrived with it.
|
|
46
|
+
* - `merge-tree --merge-base`: git 2.40 ("merge-tree" learns a new
|
|
47
|
+
* `--merge-base` option, RelNotes/2.40.0).
|
|
48
|
+
* - `worktree list -z`: git 2.36 (NUL-terminated `--porcelain` output, because
|
|
49
|
+
* paths and lock reasons with unsafe bytes were not C-quoted correctly,
|
|
50
|
+
* RelNotes/2.36.0).
|
|
51
|
+
*/
|
|
52
|
+
export declare const GIT_FEATURES: Readonly<{
|
|
53
|
+
'merge-tree --write-tree': {
|
|
54
|
+
minimum: GitRelease;
|
|
55
|
+
usedBy: string[];
|
|
56
|
+
};
|
|
57
|
+
'merge-tree --merge-base': {
|
|
58
|
+
minimum: GitRelease;
|
|
59
|
+
usedBy: string[];
|
|
60
|
+
};
|
|
61
|
+
'worktree list -z': {
|
|
62
|
+
minimum: GitRelease;
|
|
63
|
+
usedBy: string[];
|
|
64
|
+
fallback: string;
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
/** A feature in {@link GIT_FEATURES}. */
|
|
68
|
+
export type GitFeature = keyof typeof GIT_FEATURES;
|
|
69
|
+
/** What an `unsupported-git` failure carries: the feature, the git it needs, and the git found. */
|
|
70
|
+
export interface UnsupportedGit {
|
|
71
|
+
/** The feature, or `typed-git` when the git is older than {@link GIT_FLOOR}. */
|
|
72
|
+
feature: GitFeature | 'typed-git';
|
|
73
|
+
/** The first git release that has it. */
|
|
74
|
+
needs: GitRelease;
|
|
75
|
+
/** The git that was found. */
|
|
76
|
+
have: GitVersion;
|
|
77
|
+
}
|
|
78
|
+
/** True when `have` has `feature`. */
|
|
79
|
+
export declare function gitSupports(feature: GitFeature, have: GitRelease): boolean;
|
|
80
|
+
/** The classified failure for a git too old for `feature`. */
|
|
81
|
+
export declare function unsupportedGitFailure(feature: GitFeature | 'typed-git', needs: GitRelease, have: GitVersion, argv: string[]): GitFailure;
|
|
82
|
+
/**
|
|
83
|
+
* The form of `verb` that the git at `have` can run: the verb itself when it
|
|
84
|
+
* needs nothing or `have` has its feature, its `fallback` when the feature has
|
|
85
|
+
* one in the table, otherwise a thrown `unsupported-git` failure. Below
|
|
86
|
+
* {@link GIT_FLOOR} a gated verb always throws.
|
|
87
|
+
*
|
|
88
|
+
* `prefix` is the repository binding the client adds, so the failure names
|
|
89
|
+
* the argv that would have run.
|
|
90
|
+
*/
|
|
91
|
+
export declare function versionedVerb<T>(verb: GitVerb<T>, have: GitVersion, prefix?: readonly string[]): GitVerb<T>;
|