@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/dist/sync.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { basename, dirname, resolve } from 'node:path';
|
|
19
19
|
import { spawnRunner, } from '@osdlc/command-seam';
|
|
20
|
+
import { versionedVerb } from "./features.js";
|
|
21
|
+
import { pinnedGitVersion, probeGitVersion } from "./git-version.js";
|
|
20
22
|
import { softSync, triedSync } from "./outcome.js";
|
|
21
23
|
import { parseRemoteUrl } from "./remote-url.js";
|
|
22
24
|
import { SOFT_TABLE } from "./soft.js";
|
|
@@ -29,6 +31,8 @@ export class Git {
|
|
|
29
31
|
boundGitDir;
|
|
30
32
|
workTree;
|
|
31
33
|
env;
|
|
34
|
+
gitVersionOption;
|
|
35
|
+
pinnedVersion;
|
|
32
36
|
tried;
|
|
33
37
|
softened;
|
|
34
38
|
/**
|
|
@@ -54,9 +58,17 @@ export class Git {
|
|
|
54
58
|
* Neither client has a default timeout. This client kills a child whose
|
|
55
59
|
* output on one stream passes 256 MB; `AsyncGit` has no output cap. The
|
|
56
60
|
* `maxOutputBytes` call option sets the cap per call on both.
|
|
61
|
+
*
|
|
62
|
+
* `gitVersion` pins the git version: `'2.55.0'`, or a whole
|
|
63
|
+
* `git version …` line. Version-gated verbs then use it and never run
|
|
64
|
+
* `git --version`, and {@link Git.version} returns it. Set it with a fake
|
|
65
|
+
* runner, so the fake answers only the verbs under test. An unparsable
|
|
66
|
+
* value throws a `RangeError` here.
|
|
57
67
|
*/
|
|
58
68
|
constructor(cwd, opts = {}) {
|
|
59
69
|
this.cwd = cwd;
|
|
70
|
+
this.gitVersionOption = opts.gitVersion;
|
|
71
|
+
this.pinnedVersion = pinnedGitVersion(opts.gitVersion);
|
|
60
72
|
this.runner = opts.runner ?? spawnRunner('git', { absolutePathOnly: true });
|
|
61
73
|
this.boundGitDir = opts.gitDir;
|
|
62
74
|
this.workTree = opts.workTree;
|
|
@@ -64,7 +76,7 @@ export class Git {
|
|
|
64
76
|
}
|
|
65
77
|
/**
|
|
66
78
|
* The same client in a different directory, with the same runner,
|
|
67
|
-
* repository options
|
|
79
|
+
* repository options, client-level `env` and `gitVersion`.
|
|
68
80
|
*/
|
|
69
81
|
at(cwd) {
|
|
70
82
|
return new Git(cwd, {
|
|
@@ -72,6 +84,7 @@ export class Git {
|
|
|
72
84
|
gitDir: this.boundGitDir,
|
|
73
85
|
workTree: this.workTree,
|
|
74
86
|
env: this.env,
|
|
87
|
+
gitVersion: this.gitVersionOption,
|
|
75
88
|
});
|
|
76
89
|
}
|
|
77
90
|
/**
|
|
@@ -141,9 +154,25 @@ export class Git {
|
|
|
141
154
|
run.input = opts.input;
|
|
142
155
|
return run;
|
|
143
156
|
}
|
|
144
|
-
/**
|
|
145
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Run one verb from the table and check its result with `gate`. A verb that
|
|
159
|
+
* `needs` a git feature first gets the form this runner's git can run (see
|
|
160
|
+
* `versionedVerb` in `features.ts`), which probes the version once.
|
|
161
|
+
*/
|
|
162
|
+
exec(gated, opts = {}) {
|
|
146
163
|
const run = this.runOpts(opts);
|
|
164
|
+
let verb = gated;
|
|
165
|
+
if (gated.needs !== undefined) {
|
|
166
|
+
const prefix = repoPrefix(this.boundGitDir, this.workTree);
|
|
167
|
+
// A failed probe names this verb's argv, not `--version`.
|
|
168
|
+
const have = this.pinnedVersion ??
|
|
169
|
+
probeGitVersion(this.runner, {
|
|
170
|
+
env: run.env,
|
|
171
|
+
timeoutMs: run.timeoutMs,
|
|
172
|
+
report: [...prefix, ...gated.argv],
|
|
173
|
+
});
|
|
174
|
+
verb = versionedVerb(gated, have, prefix);
|
|
175
|
+
}
|
|
147
176
|
if (verb.input !== undefined)
|
|
148
177
|
run.input = verb.input;
|
|
149
178
|
// The verb's own entries (the C locale) win over the client's and the call's.
|
|
@@ -154,6 +183,24 @@ export class Git {
|
|
|
154
183
|
return gate(verb, this.runner.run(argv, run), argv);
|
|
155
184
|
}
|
|
156
185
|
// ── queries ───────────────────────────────────────────────────────────────
|
|
186
|
+
/**
|
|
187
|
+
* The git this client's runner runs, from `git --version`. Probed on the
|
|
188
|
+
* first call (or the first version-gated verb) and cached for the runner,
|
|
189
|
+
* so a client that never asks never spawns it. Throws the classified
|
|
190
|
+
* failure when git cannot run (`not-installed`), and an `exit` failure when
|
|
191
|
+
* the output is not a version line. With the `gitVersion` option it is that
|
|
192
|
+
* version, and nothing runs.
|
|
193
|
+
*/
|
|
194
|
+
version(opts = {}) {
|
|
195
|
+
if (this.pinnedVersion !== undefined)
|
|
196
|
+
return this.pinnedVersion;
|
|
197
|
+
const run = this.runOpts(opts);
|
|
198
|
+
return probeGitVersion(this.runner, {
|
|
199
|
+
env: run.env,
|
|
200
|
+
timeoutMs: run.timeoutMs,
|
|
201
|
+
report: ['--version'],
|
|
202
|
+
});
|
|
203
|
+
}
|
|
157
204
|
/** A file's content at a rev (`git show <rev>:<relPath>`), null if absent. */
|
|
158
205
|
showAtRev(rev, relPath, opts = {}) {
|
|
159
206
|
return this.exec(v.showAtRev(rev, relPath), opts);
|
|
@@ -451,6 +498,17 @@ export class Git {
|
|
|
451
498
|
aheadBehind(base, tip, opts = {}) {
|
|
452
499
|
return this.exec(v.aheadBehind(base, tip), opts);
|
|
453
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Commits on `head` (default `HEAD`) that `upstream` lacks, each marked by
|
|
503
|
+
* whether `upstream` has the same patch. See {@link CherryEntry}.
|
|
504
|
+
*/
|
|
505
|
+
cherry(upstream, head, opts = {}) {
|
|
506
|
+
return this.exec(v.cherry(upstream, head), opts);
|
|
507
|
+
}
|
|
508
|
+
/** Write a commit for `tree` and return its sha; no ref moves. Needs a git identity. */
|
|
509
|
+
commitTree(tree, commitOpts, opts = {}) {
|
|
510
|
+
return this.exec(v.commitTree(tree, commitOpts), opts);
|
|
511
|
+
}
|
|
454
512
|
/** Configured remote names (`git remote`); `[]` when there are none. */
|
|
455
513
|
remotes(opts = {}) {
|
|
456
514
|
return this.exec(v.remote(), opts);
|
package/dist/verbs.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* `GitVerb` and `gate` are internal: the package entries do not export them.
|
|
14
14
|
*/
|
|
15
15
|
import { type CommandResult } from '@osdlc/command-seam';
|
|
16
|
+
import type { GitFeature } from './features.ts';
|
|
16
17
|
/**
|
|
17
18
|
* One git invocation: what to run, which exits are answers, and how to read
|
|
18
19
|
* what came back.
|
|
@@ -46,6 +47,20 @@ export interface GitVerb<T> {
|
|
|
46
47
|
* so every failure names the command that ran.
|
|
47
48
|
*/
|
|
48
49
|
parse(result: CommandResult, argv: string[]): T;
|
|
50
|
+
/**
|
|
51
|
+
* The git feature this argv needs, from the table in `./features.ts`. The
|
|
52
|
+
* client probes the git version (once per runner) before it runs a verb
|
|
53
|
+
* that sets this, and runs {@link GitVerb.fallback} or throws the
|
|
54
|
+
* `unsupported-git` failure when the git is too old. A verb without it
|
|
55
|
+
* never probes.
|
|
56
|
+
*/
|
|
57
|
+
needs?: GitFeature | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* The verb to run instead on a git older than `needs` requires. It is used
|
|
60
|
+
* only when the feature's table entry has a `fallback`, so a verb cannot
|
|
61
|
+
* fall back where the table says no fallback exists.
|
|
62
|
+
*/
|
|
63
|
+
fallback?: GitVerb<T> | undefined;
|
|
49
64
|
}
|
|
50
65
|
/**
|
|
51
66
|
* Turn one git result into a value or a thrown failure: a `FailureError`
|
|
@@ -111,7 +126,9 @@ export interface Worktree {
|
|
|
111
126
|
locked: boolean;
|
|
112
127
|
/**
|
|
113
128
|
* The reason given to `git worktree lock --reason`, or null when none was.
|
|
114
|
-
*
|
|
129
|
+
* On git 2.36 or later it is the reason as written, newlines and all (read
|
|
130
|
+
* from `worktree list --porcelain -z`). On older git it is the newline
|
|
131
|
+
* porcelain's text: git C-quotes a reason holding a newline or other
|
|
115
132
|
* special characters, and the quotes stay.
|
|
116
133
|
*/
|
|
117
134
|
lockReason: string | null;
|
|
@@ -289,7 +306,14 @@ export declare function statusEntries(): GitVerb<StatusEntry[]>;
|
|
|
289
306
|
* `heads/<name>` when a tag shares the name.
|
|
290
307
|
*/
|
|
291
308
|
export declare function branches(pattern?: string | undefined): GitVerb<string[]>;
|
|
292
|
-
/**
|
|
309
|
+
/**
|
|
310
|
+
* `git worktree list --porcelain -z`, parsed. Throws outside a repository.
|
|
311
|
+
*
|
|
312
|
+
* `-z` (git 2.36) ends each line with NUL, so a path or lock reason holding
|
|
313
|
+
* a newline reads as written. On an older git the client runs the
|
|
314
|
+
* newline-split form instead (the `worktree list -z` row in `./features.ts`),
|
|
315
|
+
* which breaks on such a path and C-quotes such a reason.
|
|
316
|
+
*/
|
|
293
317
|
export declare function worktrees(): GitVerb<Worktree[]>;
|
|
294
318
|
/**
|
|
295
319
|
* Merge base of two revs, or null when the two histories are unrelated
|
|
@@ -771,6 +795,39 @@ export interface AheadBehind {
|
|
|
771
795
|
/** Commits on `base` that are not on `tip`. */
|
|
772
796
|
behind: number;
|
|
773
797
|
}
|
|
798
|
+
/** One line of `git cherry`: a commit on the head side and whether the upstream has its patch. */
|
|
799
|
+
export interface CherryEntry {
|
|
800
|
+
/** The full sha of the commit that is on the head side only. */
|
|
801
|
+
sha: string;
|
|
802
|
+
/** True for `-`: a commit on the upstream side has the same patch id. False for `+`. */
|
|
803
|
+
equivalent: boolean;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Which commits `head` has that `upstream` lacks, and for each one whether
|
|
807
|
+
* `upstream` carries a commit with the same patch id (`git cherry`). Oldest
|
|
808
|
+
* first. Merge commits are not listed.
|
|
809
|
+
*
|
|
810
|
+
* `absent: []`: an unresolvable rev exits 128 and throws. Empty output is a
|
|
811
|
+
* real answer (`head` has nothing `upstream` lacks), so a caller that needs at
|
|
812
|
+
* least one commit checks the length. A line that is not `+ <sha>` or
|
|
813
|
+
* `- <sha>` throws rather than reading as an entry or being skipped.
|
|
814
|
+
*/
|
|
815
|
+
export declare function cherry(upstream: string, head?: string): GitVerb<CherryEntry[]>;
|
|
816
|
+
/** Options for {@link commitTree}. */
|
|
817
|
+
export interface CommitTreeOptions {
|
|
818
|
+
/** Parent commits, in order (`-p`). None makes a root commit. */
|
|
819
|
+
parents?: string[] | undefined;
|
|
820
|
+
/** The commit message (`-m`). */
|
|
821
|
+
message: string;
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Write a commit object for `tree` and print its sha (`git commit-tree`).
|
|
825
|
+
*
|
|
826
|
+
* It writes an object and no ref, and leaves the index and working tree alone.
|
|
827
|
+
* git needs an author and committer identity; without one it exits 128 and
|
|
828
|
+
* this throws. `absent: []`, and a reply that is not a sha throws.
|
|
829
|
+
*/
|
|
830
|
+
export declare function commitTree(tree: string, opts: CommitTreeOptions): GitVerb<string>;
|
|
774
831
|
/**
|
|
775
832
|
* How far `tip` has diverged from `base`
|
|
776
833
|
* (`git rev-list --left-right --count base...tip`).
|
|
@@ -1391,6 +1448,10 @@ export interface MergeTreeOptions {
|
|
|
1391
1448
|
*
|
|
1392
1449
|
* A name git cannot merge exits 1 exactly like a conflict, so again only
|
|
1393
1450
|
* stdout separates an answer from a refusal.
|
|
1451
|
+
*
|
|
1452
|
+
* Needs git 2.38, or 2.40 with `mergeBase` (the `merge-tree` rows in
|
|
1453
|
+
* `./features.ts`). There is no fallback: on an older git it throws the
|
|
1454
|
+
* `unsupported-git` failure without running git.
|
|
1394
1455
|
*/
|
|
1395
1456
|
export declare function mergeTree(ours: string, theirs: string, opts?: MergeTreeOptions): GitVerb<MergeTreeOutcome>;
|
|
1396
1457
|
/** One `git ls-files -u` row — the same path appears once per present stage. */
|
package/dist/verbs.js
CHANGED
|
@@ -410,54 +410,69 @@ export function branches(pattern) {
|
|
|
410
410
|
argv.push(positional('branches', 'pattern', pattern));
|
|
411
411
|
return { argv, absent: NONE, parse: trimmedLines };
|
|
412
412
|
}
|
|
413
|
-
/**
|
|
413
|
+
/**
|
|
414
|
+
* `git worktree list --porcelain -z`, parsed. Throws outside a repository.
|
|
415
|
+
*
|
|
416
|
+
* `-z` (git 2.36) ends each line with NUL, so a path or lock reason holding
|
|
417
|
+
* a newline reads as written. On an older git the client runs the
|
|
418
|
+
* newline-split form instead (the `worktree list -z` row in `./features.ts`),
|
|
419
|
+
* which breaks on such a path and C-quotes such a reason.
|
|
420
|
+
*/
|
|
414
421
|
export function worktrees() {
|
|
415
422
|
return {
|
|
416
|
-
argv: ['worktree', 'list', '--porcelain'],
|
|
423
|
+
argv: ['worktree', 'list', '--porcelain', '-z'],
|
|
417
424
|
absent: NONE,
|
|
418
|
-
parse(r)
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
path: cur.path,
|
|
425
|
-
head: cur.head ?? null,
|
|
426
|
-
branch: cur.branch ?? null,
|
|
427
|
-
detached: cur.detached ?? false,
|
|
428
|
-
bare: cur.bare ?? false,
|
|
429
|
-
locked: cur.locked ?? false,
|
|
430
|
-
lockReason: cur.lockReason ?? null,
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
for (const line of r.stdout.split('\n')) {
|
|
435
|
-
if (line.startsWith('worktree ')) {
|
|
436
|
-
flush();
|
|
437
|
-
cur = { path: line.slice('worktree '.length) };
|
|
438
|
-
}
|
|
439
|
-
else if (cur !== null && line.startsWith('HEAD ')) {
|
|
440
|
-
cur.head = line.slice('HEAD '.length);
|
|
441
|
-
}
|
|
442
|
-
else if (cur !== null && line.startsWith('branch ')) {
|
|
443
|
-
cur.branch = line.slice('branch '.length).replace(/^refs\/heads\//, '');
|
|
444
|
-
}
|
|
445
|
-
else if (cur !== null && line === 'detached') {
|
|
446
|
-
cur.detached = true;
|
|
447
|
-
}
|
|
448
|
-
else if (cur !== null && line === 'bare') {
|
|
449
|
-
cur.bare = true;
|
|
450
|
-
}
|
|
451
|
-
else if (cur !== null && (line === 'locked' || line.startsWith('locked '))) {
|
|
452
|
-
cur.locked = true;
|
|
453
|
-
cur.lockReason = line.slice('locked '.length) || null;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
flush();
|
|
457
|
-
return out;
|
|
425
|
+
parse: (r) => worktreeRecords(r.stdout.split('\x00')),
|
|
426
|
+
needs: 'worktree list -z',
|
|
427
|
+
fallback: {
|
|
428
|
+
argv: ['worktree', 'list', '--porcelain'],
|
|
429
|
+
absent: NONE,
|
|
430
|
+
parse: (r) => worktreeRecords(r.stdout.split('\n')),
|
|
458
431
|
},
|
|
459
432
|
};
|
|
460
433
|
}
|
|
434
|
+
/** `worktree list --porcelain` lines, however they were split, into rows. */
|
|
435
|
+
function worktreeRecords(lines) {
|
|
436
|
+
const out = [];
|
|
437
|
+
let cur = null;
|
|
438
|
+
const flush = () => {
|
|
439
|
+
if (cur?.path !== undefined) {
|
|
440
|
+
out.push({
|
|
441
|
+
path: cur.path,
|
|
442
|
+
head: cur.head ?? null,
|
|
443
|
+
branch: cur.branch ?? null,
|
|
444
|
+
detached: cur.detached ?? false,
|
|
445
|
+
bare: cur.bare ?? false,
|
|
446
|
+
locked: cur.locked ?? false,
|
|
447
|
+
lockReason: cur.lockReason ?? null,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
for (const line of lines) {
|
|
452
|
+
if (line.startsWith('worktree ')) {
|
|
453
|
+
flush();
|
|
454
|
+
cur = { path: line.slice('worktree '.length) };
|
|
455
|
+
}
|
|
456
|
+
else if (cur !== null && line.startsWith('HEAD ')) {
|
|
457
|
+
cur.head = line.slice('HEAD '.length);
|
|
458
|
+
}
|
|
459
|
+
else if (cur !== null && line.startsWith('branch ')) {
|
|
460
|
+
cur.branch = line.slice('branch '.length).replace(/^refs\/heads\//, '');
|
|
461
|
+
}
|
|
462
|
+
else if (cur !== null && line === 'detached') {
|
|
463
|
+
cur.detached = true;
|
|
464
|
+
}
|
|
465
|
+
else if (cur !== null && line === 'bare') {
|
|
466
|
+
cur.bare = true;
|
|
467
|
+
}
|
|
468
|
+
else if (cur !== null && (line === 'locked' || line.startsWith('locked '))) {
|
|
469
|
+
cur.locked = true;
|
|
470
|
+
cur.lockReason = line.slice('locked '.length) || null;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
flush();
|
|
474
|
+
return out;
|
|
475
|
+
}
|
|
461
476
|
/**
|
|
462
477
|
* Merge base of two revs, or null when the two histories are unrelated
|
|
463
478
|
* (exit 1). A rev that does not resolve exits 128 and throws.
|
|
@@ -1074,6 +1089,61 @@ export function isAncestor(a, b) {
|
|
|
1074
1089
|
parse: (r) => r.exitCode === 0,
|
|
1075
1090
|
};
|
|
1076
1091
|
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Which commits `head` has that `upstream` lacks, and for each one whether
|
|
1094
|
+
* `upstream` carries a commit with the same patch id (`git cherry`). Oldest
|
|
1095
|
+
* first. Merge commits are not listed.
|
|
1096
|
+
*
|
|
1097
|
+
* `absent: []`: an unresolvable rev exits 128 and throws. Empty output is a
|
|
1098
|
+
* real answer (`head` has nothing `upstream` lacks), so a caller that needs at
|
|
1099
|
+
* least one commit checks the length. A line that is not `+ <sha>` or
|
|
1100
|
+
* `- <sha>` throws rather than reading as an entry or being skipped.
|
|
1101
|
+
*/
|
|
1102
|
+
export function cherry(upstream, head) {
|
|
1103
|
+
const argv = ['cherry', positional('cherry', 'upstream', upstream)];
|
|
1104
|
+
if (head !== undefined)
|
|
1105
|
+
argv.push(positional('cherry', 'head', head));
|
|
1106
|
+
return {
|
|
1107
|
+
argv,
|
|
1108
|
+
absent: NONE,
|
|
1109
|
+
parse(r, ranArgv) {
|
|
1110
|
+
const out = [];
|
|
1111
|
+
for (const line of r.stdout.split('\n')) {
|
|
1112
|
+
if (line === '')
|
|
1113
|
+
continue;
|
|
1114
|
+
const m = /^([+-]) ([0-9a-f]{40}|[0-9a-f]{64})$/.exec(line);
|
|
1115
|
+
if (m === null)
|
|
1116
|
+
throw new CommandFailed(ranArgv, r);
|
|
1117
|
+
out.push({ sha: m[2], equivalent: m[1] === '-' });
|
|
1118
|
+
}
|
|
1119
|
+
return out;
|
|
1120
|
+
},
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Write a commit object for `tree` and print its sha (`git commit-tree`).
|
|
1125
|
+
*
|
|
1126
|
+
* It writes an object and no ref, and leaves the index and working tree alone.
|
|
1127
|
+
* git needs an author and committer identity; without one it exits 128 and
|
|
1128
|
+
* this throws. `absent: []`, and a reply that is not a sha throws.
|
|
1129
|
+
*/
|
|
1130
|
+
export function commitTree(tree, opts) {
|
|
1131
|
+
const argv = ['commit-tree', positional('commitTree', 'tree', tree)];
|
|
1132
|
+
for (const parent of opts.parents ?? []) {
|
|
1133
|
+
argv.push('-p', positional('commitTree', 'parent', parent));
|
|
1134
|
+
}
|
|
1135
|
+
argv.push('-m', opts.message);
|
|
1136
|
+
return {
|
|
1137
|
+
argv,
|
|
1138
|
+
absent: NONE,
|
|
1139
|
+
parse(r, ranArgv) {
|
|
1140
|
+
const sha = r.stdout.trim();
|
|
1141
|
+
if (!/^([0-9a-f]{40}|[0-9a-f]{64})$/.test(sha))
|
|
1142
|
+
throw new CommandFailed(ranArgv, r);
|
|
1143
|
+
return sha;
|
|
1144
|
+
},
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1077
1147
|
/**
|
|
1078
1148
|
* How far `tip` has diverged from `base`
|
|
1079
1149
|
* (`git rev-list --left-right --count base...tip`).
|
|
@@ -1811,6 +1881,10 @@ export function rebaseContinue() {
|
|
|
1811
1881
|
*
|
|
1812
1882
|
* A name git cannot merge exits 1 exactly like a conflict, so again only
|
|
1813
1883
|
* stdout separates an answer from a refusal.
|
|
1884
|
+
*
|
|
1885
|
+
* Needs git 2.38, or 2.40 with `mergeBase` (the `merge-tree` rows in
|
|
1886
|
+
* `./features.ts`). There is no fallback: on an older git it throws the
|
|
1887
|
+
* `unsupported-git` failure without running git.
|
|
1814
1888
|
*/
|
|
1815
1889
|
export function mergeTree(ours, theirs, opts = {}) {
|
|
1816
1890
|
const argv = ['merge-tree', '--write-tree', '--name-only', '-z'];
|
|
@@ -1819,6 +1893,7 @@ export function mergeTree(ours, theirs, opts = {}) {
|
|
|
1819
1893
|
argv.push(positional('mergeTree', 'ours', ours), positional('mergeTree', 'theirs', theirs));
|
|
1820
1894
|
return {
|
|
1821
1895
|
argv,
|
|
1896
|
+
needs: opts.mergeBase === undefined ? 'merge-tree --write-tree' : 'merge-tree --merge-base',
|
|
1822
1897
|
absent: [1],
|
|
1823
1898
|
parse(r, ranArgv) {
|
|
1824
1899
|
const fields = r.stdout.split('\x00');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdlc/typed-git",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
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",
|