@osdlc/typed-git 0.5.0 → 0.5.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/CHANGELOG.md +83 -36
- package/LICENSE-APACHE +202 -0
- package/README.md +133 -30
- package/async.ts +109 -32
- package/backend.ts +57 -12
- package/client.ts +18 -8
- package/dist/async.d.ts +59 -23
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +87 -29
- package/dist/backend.d.ts +50 -9
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +25 -3
- package/dist/client.d.ts +10 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +10 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/outcome.d.ts +6 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/remote-url.d.ts +3 -0
- package/dist/remote-url.d.ts.map +1 -1
- package/dist/remote-url.js +3 -0
- package/dist/soft.d.ts +7 -1
- package/dist/soft.d.ts.map +1 -1
- package/dist/soft.js +7 -1
- package/dist/sync.d.ts +74 -24
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +99 -28
- package/dist/testing.d.ts +54 -26
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +11 -4
- package/dist/verbs.d.ts +163 -41
- package/dist/verbs.d.ts.map +1 -1
- package/dist/verbs.js +342 -83
- package/index.ts +2 -2
- package/outcome.ts +13 -5
- package/package.json +11 -6
- package/remote-url.ts +3 -0
- package/soft.ts +7 -1
- package/sync.ts +114 -31
- package/testing.ts +64 -32
- package/verbs.ts +427 -103
- /package/{LICENSE → LICENSE-MIT} +0 -0
package/dist/soft.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Typed against `Git` and `AsyncGit` both, so adding a list-, nullable- or
|
|
6
6
|
* boolean-returning verb to either client is a compile error here until it
|
|
7
7
|
* is declared, and the two clients cannot grow different soft doors.
|
|
8
|
+
* Mutations have no soft form, so `configRemoveSection` is not here.
|
|
8
9
|
*/
|
|
9
10
|
export declare const SOFT_TABLE: {
|
|
10
11
|
readonly showAtRev: "null";
|
|
@@ -14,6 +15,7 @@ export declare const SOFT_TABLE: {
|
|
|
14
15
|
readonly headRef: "null";
|
|
15
16
|
readonly topLevel: "null";
|
|
16
17
|
readonly gitCommonDir: "null";
|
|
18
|
+
readonly gitDir: "null";
|
|
17
19
|
readonly symbolicRef: "null";
|
|
18
20
|
readonly mainCheckout: "null";
|
|
19
21
|
readonly currentBranch: "null";
|
|
@@ -26,6 +28,8 @@ export declare const SOFT_TABLE: {
|
|
|
26
28
|
readonly mergeBase: "null";
|
|
27
29
|
readonly logSubject: "null";
|
|
28
30
|
readonly configGet: "null";
|
|
31
|
+
readonly configGetAll: "empty";
|
|
32
|
+
readonly configGetBool: "null";
|
|
29
33
|
readonly objectExists: "false";
|
|
30
34
|
readonly lsRemote: "empty";
|
|
31
35
|
readonly lsFiles: "empty";
|
|
@@ -40,10 +44,12 @@ export declare const SOFT_TABLE: {
|
|
|
40
44
|
readonly diffTreeNumstat: "empty";
|
|
41
45
|
readonly grep: "empty";
|
|
42
46
|
readonly isAncestor: "false";
|
|
47
|
+
readonly remotes: "empty";
|
|
43
48
|
readonly remote: "empty";
|
|
44
49
|
readonly remoteGetUrl: "null";
|
|
50
|
+
readonly remoteGetUrls: "empty";
|
|
51
|
+
readonly remoteHead: "null";
|
|
45
52
|
readonly remoteOwnerRepo: "null";
|
|
46
|
-
readonly configRemoveSection: "false";
|
|
47
53
|
readonly lsFilesUnmerged: "empty";
|
|
48
54
|
readonly checkIgnoreVerbose: "empty";
|
|
49
55
|
};
|
package/dist/soft.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soft.d.ts","sourceRoot":"","sources":["../soft.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"soft.d.ts","sourceRoot":"","sources":["../soft.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CwC,CAAA"}
|
package/dist/soft.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Typed against `Git` and `AsyncGit` both, so adding a list-, nullable- or
|
|
6
6
|
* boolean-returning verb to either client is a compile error here until it
|
|
7
7
|
* is declared, and the two clients cannot grow different soft doors.
|
|
8
|
+
* Mutations have no soft form, so `configRemoveSection` is not here.
|
|
8
9
|
*/
|
|
9
10
|
export const SOFT_TABLE = {
|
|
10
11
|
showAtRev: 'null',
|
|
@@ -14,6 +15,7 @@ export const SOFT_TABLE = {
|
|
|
14
15
|
headRef: 'null',
|
|
15
16
|
topLevel: 'null',
|
|
16
17
|
gitCommonDir: 'null',
|
|
18
|
+
gitDir: 'null',
|
|
17
19
|
symbolicRef: 'null',
|
|
18
20
|
mainCheckout: 'null',
|
|
19
21
|
currentBranch: 'null',
|
|
@@ -26,6 +28,8 @@ export const SOFT_TABLE = {
|
|
|
26
28
|
mergeBase: 'null',
|
|
27
29
|
logSubject: 'null',
|
|
28
30
|
configGet: 'null',
|
|
31
|
+
configGetAll: 'empty',
|
|
32
|
+
configGetBool: 'null',
|
|
29
33
|
objectExists: 'false',
|
|
30
34
|
lsRemote: 'empty',
|
|
31
35
|
lsFiles: 'empty',
|
|
@@ -40,10 +44,12 @@ export const SOFT_TABLE = {
|
|
|
40
44
|
diffTreeNumstat: 'empty',
|
|
41
45
|
grep: 'empty',
|
|
42
46
|
isAncestor: 'false',
|
|
47
|
+
remotes: 'empty',
|
|
43
48
|
remote: 'empty',
|
|
44
49
|
remoteGetUrl: 'null',
|
|
50
|
+
remoteGetUrls: 'empty',
|
|
51
|
+
remoteHead: 'null',
|
|
45
52
|
remoteOwnerRepo: 'null',
|
|
46
|
-
configRemoveSection: 'false',
|
|
47
53
|
lsFilesUnmerged: 'empty',
|
|
48
54
|
checkIgnoreVerbose: 'empty',
|
|
49
55
|
};
|
package/dist/sync.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { type CommandResult, type CommandRunner } from '@osdlc/command-seam';
|
|
19
19
|
import { type Soft, type TriedSync } from './outcome.ts';
|
|
20
20
|
import { type RemoteCoordinate } from './remote-url.ts';
|
|
21
|
-
import { type AddOptions, type AheadBehind, type CommitOptions, type CheckoutOptions, type CloneOptions, type ConflictSide, type MergeOptions, type MergeOutcome, type MergeTreeOptions, type MergeTreeOutcome, type RebaseOptions, type RebaseOutcome, type TaggedFile, type UnmergedEntry, type ConfigSetOptions, type DiffEntry, type DiffNameOnlyOptions, type DiffStatOptions, type DiffNameStatusOptions, type DiffTreeOptions, type FetchOptions, type ForEachRefOptions, type ForceLease, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type NumstatEntry, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type Worktree, type WorktreeMoveOptions } from './verbs.ts';
|
|
21
|
+
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 ForceLease, type GrepOptions, type InitOptions, type LogOptions, type IgnoreMatch, type LsFilesOptions, type LsRemoteOptions, type LsTreeOptions, type NumstatEntry, type RemoteRef, type CleanOptions, type DiffCheckOptions, type DiffCheckResult, type StatusEntry, type StatusPorcelainOptions, type TreeEntry, type Worktree, type WorktreeMoveOptions } from './verbs.ts';
|
|
22
22
|
/**
|
|
23
23
|
* Per-call concerns that are not part of the operation itself.
|
|
24
24
|
*
|
|
@@ -35,12 +35,19 @@ export interface GitSyncCallOptions {
|
|
|
35
35
|
timeoutMs?: number | undefined;
|
|
36
36
|
/** Entries merged over the parent environment for this call only. */
|
|
37
37
|
env?: Record<string, string> | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Cap on each output stream, in bytes; 256 MB when omitted. Past it the
|
|
40
|
+
* runner kills the child and the call throws `CommandFailed`. command-seam's
|
|
41
|
+
* Bun test capture path (the Bun runtime with `NODE_ENV=test`) does not
|
|
42
|
+
* apply it.
|
|
43
|
+
*/
|
|
44
|
+
maxOutputBytes?: number | undefined;
|
|
38
45
|
}
|
|
39
46
|
/** A typed git client bound to one working directory. */
|
|
40
47
|
export declare class Git {
|
|
41
48
|
readonly cwd: string;
|
|
42
49
|
private readonly runner;
|
|
43
|
-
private readonly
|
|
50
|
+
private readonly boundGitDir;
|
|
44
51
|
private readonly workTree;
|
|
45
52
|
private readonly env;
|
|
46
53
|
private tried;
|
|
@@ -64,7 +71,8 @@ export declare class Git {
|
|
|
64
71
|
* default runner spawns `git`; tests pass a fake `CommandRunner`.
|
|
65
72
|
*
|
|
66
73
|
* Neither client has a default timeout. This client kills a child whose
|
|
67
|
-
* output on one stream passes 256 MB; `AsyncGit` has no output cap.
|
|
74
|
+
* output on one stream passes 256 MB; `AsyncGit` has no output cap. The
|
|
75
|
+
* `maxOutputBytes` call option sets the cap per call on both.
|
|
68
76
|
*/
|
|
69
77
|
constructor(cwd: string, opts?: {
|
|
70
78
|
runner?: CommandRunner | undefined;
|
|
@@ -103,7 +111,8 @@ export declare class Git {
|
|
|
103
111
|
input?: string | undefined;
|
|
104
112
|
}): CommandResult;
|
|
105
113
|
/**
|
|
106
|
-
* Checked passthrough — throws `CommandFailed` on a non-zero exit
|
|
114
|
+
* Checked passthrough — throws `CommandFailed` on a non-zero exit, and on
|
|
115
|
+
* output cut short at the output cap or a timeout, as every verb does.
|
|
107
116
|
*
|
|
108
117
|
* `CommandFailed.message` interpolates stderr only, and several git commands
|
|
109
118
|
* write the sentence that explains the failure to stdout instead — a
|
|
@@ -123,9 +132,13 @@ export declare class Git {
|
|
|
123
132
|
/**
|
|
124
133
|
* Trimmed `git rev-parse <args>` output — the escape hatch for a query no
|
|
125
134
|
* dedicated verb covers. See `revParse` in `verbs.ts`; for a ref, prefer
|
|
126
|
-
* {@link Git.resolveRef}.
|
|
135
|
+
* {@link Git.resolveRef}.
|
|
136
|
+
*
|
|
137
|
+
* Variadic. Call options go last, as an object:
|
|
138
|
+
* `revParse('--show-toplevel', { timeoutMs: 5000 })`. The args are flags by
|
|
139
|
+
* design, so a value that starts with `-` is not refused here.
|
|
127
140
|
*/
|
|
128
|
-
revParse(...args: string[]): string | null;
|
|
141
|
+
revParse(...args: string[] | [...string[], GitSyncCallOptions]): string | null;
|
|
129
142
|
/**
|
|
130
143
|
* The sha `ref` resolves to, or null when it does not
|
|
131
144
|
* (`rev-parse --verify --quiet`). An unreadable store throws.
|
|
@@ -152,6 +165,12 @@ export declare class Git {
|
|
|
152
165
|
* a repo — see `gitCommonDir` in `verbs.ts`.
|
|
153
166
|
*/
|
|
154
167
|
gitCommonDir(opts?: GitSyncCallOptions): string | null;
|
|
168
|
+
/**
|
|
169
|
+
* This worktree's own `.git` dir as an absolute path, or null outside a repo
|
|
170
|
+
* — see `gitDir` in `verbs.ts`. Not the constructor's `gitDir` option, which
|
|
171
|
+
* binds the client to a repository.
|
|
172
|
+
*/
|
|
173
|
+
gitDir(opts?: GitSyncCallOptions): string | null;
|
|
155
174
|
/**
|
|
156
175
|
* What a symbolic ref points at (full refname), or null when it is not one —
|
|
157
176
|
* see `symbolicRef` in `verbs.ts`.
|
|
@@ -187,8 +206,15 @@ export declare class Git {
|
|
|
187
206
|
mergeBase(a: string, b: string, opts?: GitSyncCallOptions): string | null;
|
|
188
207
|
/** Subject line of a ref's HEAD commit (`log -1 --format=%s`), or null. */
|
|
189
208
|
logSubject(ref: string, opts?: GitSyncCallOptions): string | null;
|
|
190
|
-
/** `git config --get <key>`, or null when unset. */
|
|
191
|
-
configGet(key: string, opts?: GitSyncCallOptions): string | null;
|
|
209
|
+
/** `git config --get <key>`, or null when unset. `scope` reads one file only. */
|
|
210
|
+
configGet(key: string, opts?: GitSyncCallOptions & ConfigGetOptions): string | null;
|
|
211
|
+
/** Every value of a multi-valued key, verbatim; `[]` when unset. */
|
|
212
|
+
configGetAll(key: string, opts?: GitSyncCallOptions & ConfigGetOptions): string[];
|
|
213
|
+
/**
|
|
214
|
+
* A key read as a boolean by git, or null when unset. A value git cannot
|
|
215
|
+
* read as a boolean throws.
|
|
216
|
+
*/
|
|
217
|
+
configGetBool(key: string, opts?: GitSyncCallOptions & ConfigGetOptions): boolean | null;
|
|
192
218
|
/** True iff `rev` resolves to an object (`cat-file -e`). */
|
|
193
219
|
objectExists(rev: string, opts?: GitSyncCallOptions): boolean;
|
|
194
220
|
/**
|
|
@@ -214,13 +240,16 @@ export declare class Git {
|
|
|
214
240
|
lsFiles(opts?: GitSyncCallOptions & LsFilesOptions): string[];
|
|
215
241
|
/** Tracked files with their `ls-files -v` tag — see `lsFilesTagged` in `verbs.ts`. */
|
|
216
242
|
lsFilesTagged(opts?: GitSyncCallOptions): TaggedFile[];
|
|
217
|
-
/**
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
|
|
243
|
+
/**
|
|
244
|
+
* The unified diff; `""` when nothing differs. A bad rev, or a cwd outside a
|
|
245
|
+
* repository, throws. See `diffText` in `verbs.ts`.
|
|
246
|
+
*/
|
|
247
|
+
diffText(rev?: string | undefined, opts?: GitSyncCallOptions & DiffTextOptions): string;
|
|
248
|
+
/**
|
|
249
|
+
* One untracked file rendered as an all-added diff. A path git cannot read
|
|
250
|
+
* throws. See `diffAddedFile` in `verbs.ts`.
|
|
251
|
+
*/
|
|
252
|
+
diffAddedFile(relPath: string, opts?: GitSyncCallOptions): string;
|
|
224
253
|
/** `for-each-ref` rows, one line each, in the caller's format. */
|
|
225
254
|
forEachRef(pattern: string | string[], opts?: GitSyncCallOptions & ForEachRefOptions): string[];
|
|
226
255
|
/**
|
|
@@ -275,9 +304,26 @@ export declare class Git {
|
|
|
275
304
|
/** How far `tip` has diverged from `base`. See {@link AheadBehind}. */
|
|
276
305
|
aheadBehind(base: string, tip: string, opts?: GitSyncCallOptions): AheadBehind;
|
|
277
306
|
/** Configured remote names (`git remote`); `[]` when there are none. */
|
|
307
|
+
remotes(opts?: GitSyncCallOptions): string[];
|
|
308
|
+
/**
|
|
309
|
+
* The same as {@link Git.remotes}.
|
|
310
|
+
*
|
|
311
|
+
* @deprecated Use `remotes()`. The name `remote()` reads as one remote, but
|
|
312
|
+
* it returns every remote name. It will be removed at 1.0.
|
|
313
|
+
*/
|
|
278
314
|
remote(opts?: GitSyncCallOptions): string[];
|
|
279
|
-
/**
|
|
280
|
-
|
|
315
|
+
/**
|
|
316
|
+
* A remote's fetch URL (push URL with `push`), or null when no remote by
|
|
317
|
+
* that name exists.
|
|
318
|
+
*/
|
|
319
|
+
remoteGetUrl(name: string, opts?: GitSyncCallOptions & RemoteGetUrlOptions): string | null;
|
|
320
|
+
/** Every URL a remote has (push URLs with `push`); `[]` for an unknown remote. */
|
|
321
|
+
remoteGetUrls(name: string, opts?: GitSyncCallOptions & RemoteGetUrlOptions): string[];
|
|
322
|
+
/**
|
|
323
|
+
* The full refname the remote's HEAD points at, asked over the network; null
|
|
324
|
+
* when the remote names none. See `remoteHead` in `verbs.ts`.
|
|
325
|
+
*/
|
|
326
|
+
remoteHead(remote: string, opts?: GitSyncCallOptions): string | null;
|
|
281
327
|
/**
|
|
282
328
|
* The coordinate (`owner`, `repo`, `host`, `port`) a remote's URL names, or
|
|
283
329
|
* null when no such remote exists or its URL names no project. Any host: see
|
|
@@ -309,11 +355,11 @@ export declare class Git {
|
|
|
309
355
|
*/
|
|
310
356
|
clone(url: string, dest?: string | undefined, opts?: GitSyncCallOptions & CloneOptions): void;
|
|
311
357
|
/**
|
|
312
|
-
* Push a refspec.
|
|
313
|
-
*
|
|
314
|
-
*
|
|
358
|
+
* Push a refspec. A {@link ForceLease} pins `--force-with-lease`, which means
|
|
359
|
+
* "nobody has touched this since I looked". `{forceWithLease: true}` adds the
|
|
360
|
+
* bare flag, which is the unsafe form: it compares against the
|
|
315
361
|
* remote-tracking ref, which a fetch in this same process may have just
|
|
316
|
-
* updated.
|
|
362
|
+
* updated. See `push` in `verbs.ts`.
|
|
317
363
|
*/
|
|
318
364
|
push(remote: string, refspec: string, opts?: GitSyncCallOptions & {
|
|
319
365
|
forceWithLease?: boolean | ForceLease | undefined;
|
|
@@ -326,7 +372,10 @@ export declare class Git {
|
|
|
326
372
|
deleteBranch(name: string, opts?: GitSyncCallOptions & {
|
|
327
373
|
force?: boolean | undefined;
|
|
328
374
|
}): void;
|
|
329
|
-
/**
|
|
375
|
+
/**
|
|
376
|
+
* Remove config section `name`; false when it was absent. See
|
|
377
|
+
* `configRemoveSection` in `verbs.ts`.
|
|
378
|
+
*/
|
|
330
379
|
configRemoveSection(name: string, opts?: GitSyncCallOptions): boolean;
|
|
331
380
|
/** Delete `ref` only while it points at `expected`. See `deleteRef` in `verbs.ts`. */
|
|
332
381
|
deleteRef(ref: string, opts: GitSyncCallOptions & {
|
|
@@ -375,8 +424,9 @@ export declare class Git {
|
|
|
375
424
|
*/
|
|
376
425
|
lsFilesUnmerged(opts?: GitSyncCallOptions): UnmergedEntry[];
|
|
377
426
|
/**
|
|
378
|
-
* Resolve conflicted `paths` to one side wholesale.
|
|
379
|
-
* for a path that is not
|
|
427
|
+
* Resolve conflicted `paths` to one side wholesale. An empty list returns
|
|
428
|
+
* without running git. Silently does nothing for a path that is not
|
|
429
|
+
* conflicted — see `checkoutSide` in `verbs.ts`.
|
|
380
430
|
*/
|
|
381
431
|
checkoutSide(side: ConflictSide, paths: string[], opts?: GitSyncCallOptions): void;
|
|
382
432
|
/** `git checkout [-f] [-b|-B <branch>] <ref>`. */
|
package/dist/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAuB,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGvE,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAEf,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,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,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,IAAI;IAMzE;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,YAAY,GAAG,kBAAuB,GAAG,YAAY;IAI9E,gEAAgE;IAChE,UAAU,CAAC,IAAI,GAAE,kBAAuB,GAAG,IAAI;IAI/C,gFAAgF;IAChF,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,aAAa,GAAG,kBAAuB,GAAG,aAAa;IAIlF,kEAAkE;IAClE,WAAW,CAAC,IAAI,GAAE,kBAAuB,GAAG,IAAI;IAIhD,mEAAmE;IACnE,cAAc,CAAC,IAAI,GAAE,kBAAuB,GAAG,aAAa;IAI5D;;;;OAIG;IACH,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,gBAAgB,GAAG,kBAAuB,GAC/C,gBAAgB;IAInB;;;;OAIG;IACH,eAAe,CAAC,IAAI,GAAE,kBAAuB,GAAG,aAAa,EAAE;IAI/D;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,kBAAuB,GAAG,IAAI;IAKtF,kDAAkD;IAClD,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,eAAe,GAAG,kBAAuB,GAAG,IAAI;CAG7E"}
|
package/dist/sync.js
CHANGED
|
@@ -16,17 +16,17 @@
|
|
|
16
16
|
* general git.
|
|
17
17
|
*/
|
|
18
18
|
import { dirname } from 'node:path';
|
|
19
|
-
import {
|
|
19
|
+
import { resolveRunner, } 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";
|
|
23
23
|
import * as v from "./verbs.js";
|
|
24
|
-
import { gate, mergeEnv, parseRefRows, repoPrefix, splitLines, } from "./verbs.js";
|
|
24
|
+
import { gate, mergeEnv, parseRefRows, repoPrefix, splitLines, splitTrailingOptions, } from "./verbs.js";
|
|
25
25
|
/** A typed git client bound to one working directory. */
|
|
26
26
|
export class Git {
|
|
27
27
|
cwd;
|
|
28
28
|
runner;
|
|
29
|
-
|
|
29
|
+
boundGitDir;
|
|
30
30
|
workTree;
|
|
31
31
|
env;
|
|
32
32
|
tried;
|
|
@@ -50,12 +50,13 @@ export class Git {
|
|
|
50
50
|
* default runner spawns `git`; tests pass a fake `CommandRunner`.
|
|
51
51
|
*
|
|
52
52
|
* Neither client has a default timeout. This client kills a child whose
|
|
53
|
-
* output on one stream passes 256 MB; `AsyncGit` has no output cap.
|
|
53
|
+
* output on one stream passes 256 MB; `AsyncGit` has no output cap. The
|
|
54
|
+
* `maxOutputBytes` call option sets the cap per call on both.
|
|
54
55
|
*/
|
|
55
56
|
constructor(cwd, opts = {}) {
|
|
56
57
|
this.cwd = cwd;
|
|
57
58
|
this.runner = resolveRunner('git', opts.runner);
|
|
58
|
-
this.
|
|
59
|
+
this.boundGitDir = opts.gitDir;
|
|
59
60
|
this.workTree = opts.workTree;
|
|
60
61
|
this.env = opts.env;
|
|
61
62
|
}
|
|
@@ -66,7 +67,7 @@ export class Git {
|
|
|
66
67
|
at(cwd) {
|
|
67
68
|
return new Git(cwd, {
|
|
68
69
|
runner: this.runner,
|
|
69
|
-
gitDir: this.
|
|
70
|
+
gitDir: this.boundGitDir,
|
|
70
71
|
workTree: this.workTree,
|
|
71
72
|
env: this.env,
|
|
72
73
|
});
|
|
@@ -102,7 +103,8 @@ export class Git {
|
|
|
102
103
|
return this.runner.run(this.argv(argv), this.runOpts(opts));
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
105
|
-
* Checked passthrough — throws `CommandFailed` on a non-zero exit
|
|
106
|
+
* Checked passthrough — throws `CommandFailed` on a non-zero exit, and on
|
|
107
|
+
* output cut short at the output cap or a timeout, as every verb does.
|
|
106
108
|
*
|
|
107
109
|
* `CommandFailed.message` interpolates stderr only, and several git commands
|
|
108
110
|
* write the sentence that explains the failure to stdout instead — a
|
|
@@ -110,17 +112,24 @@ export class Git {
|
|
|
110
112
|
* `e.detail`, which reads both.
|
|
111
113
|
*/
|
|
112
114
|
rawChecked(argv, opts = {}) {
|
|
113
|
-
|
|
115
|
+
// Through the gate, like `AsyncGit.rawChecked`: the seam's `runChecked`
|
|
116
|
+
// checks the exit code only, so it would pass cut-short output.
|
|
117
|
+
const verb = { argv, absent: [], parse: (r) => r };
|
|
118
|
+
if (opts.input !== undefined)
|
|
119
|
+
verb.input = opts.input;
|
|
120
|
+
return this.exec(verb, opts);
|
|
114
121
|
}
|
|
115
122
|
/** The verb's argv behind this client's repository binding. */
|
|
116
123
|
argv(argv) {
|
|
117
|
-
const prefix = repoPrefix(this.
|
|
124
|
+
const prefix = repoPrefix(this.boundGitDir, this.workTree);
|
|
118
125
|
return prefix.length === 0 ? argv : [...prefix, ...argv];
|
|
119
126
|
}
|
|
120
127
|
runOpts(opts) {
|
|
121
128
|
const run = { cwd: this.cwd };
|
|
122
129
|
if (opts.timeoutMs !== undefined)
|
|
123
130
|
run.timeoutMs = opts.timeoutMs;
|
|
131
|
+
if (opts.maxOutputBytes !== undefined)
|
|
132
|
+
run.maxOutputBytes = opts.maxOutputBytes;
|
|
124
133
|
// Per-call entries win over the client's.
|
|
125
134
|
const env = mergeEnv(this.env, opts.env);
|
|
126
135
|
if (env !== undefined)
|
|
@@ -134,6 +143,9 @@ export class Git {
|
|
|
134
143
|
const run = this.runOpts(opts);
|
|
135
144
|
if (verb.input !== undefined)
|
|
136
145
|
run.input = verb.input;
|
|
146
|
+
// The verb's own entries (the C locale) win over the client's and the call's.
|
|
147
|
+
if (verb.env !== undefined)
|
|
148
|
+
run.env = { ...run.env, ...verb.env };
|
|
137
149
|
// The prefixed argv is what ran, so it is what a `CommandFailed` reports.
|
|
138
150
|
const argv = this.argv(verb.argv);
|
|
139
151
|
return gate(verb, this.runner.run(argv, run), argv);
|
|
@@ -146,10 +158,15 @@ export class Git {
|
|
|
146
158
|
/**
|
|
147
159
|
* Trimmed `git rev-parse <args>` output — the escape hatch for a query no
|
|
148
160
|
* dedicated verb covers. See `revParse` in `verbs.ts`; for a ref, prefer
|
|
149
|
-
* {@link Git.resolveRef}.
|
|
161
|
+
* {@link Git.resolveRef}.
|
|
162
|
+
*
|
|
163
|
+
* Variadic. Call options go last, as an object:
|
|
164
|
+
* `revParse('--show-toplevel', { timeoutMs: 5000 })`. The args are flags by
|
|
165
|
+
* design, so a value that starts with `-` is not refused here.
|
|
150
166
|
*/
|
|
151
167
|
revParse(...args) {
|
|
152
|
-
|
|
168
|
+
const [argv, opts] = splitTrailingOptions(args);
|
|
169
|
+
return this.exec(v.revParse(...argv), opts);
|
|
153
170
|
}
|
|
154
171
|
/**
|
|
155
172
|
* The sha `ref` resolves to, or null when it does not
|
|
@@ -187,6 +204,14 @@ export class Git {
|
|
|
187
204
|
gitCommonDir(opts = {}) {
|
|
188
205
|
return this.exec(v.gitCommonDir(), opts);
|
|
189
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* This worktree's own `.git` dir as an absolute path, or null outside a repo
|
|
209
|
+
* — see `gitDir` in `verbs.ts`. Not the constructor's `gitDir` option, which
|
|
210
|
+
* binds the client to a repository.
|
|
211
|
+
*/
|
|
212
|
+
gitDir(opts = {}) {
|
|
213
|
+
return this.exec(v.gitDir(), opts);
|
|
214
|
+
}
|
|
190
215
|
/**
|
|
191
216
|
* What a symbolic ref points at (full refname), or null when it is not one —
|
|
192
217
|
* see `symbolicRef` in `verbs.ts`.
|
|
@@ -245,9 +270,20 @@ export class Git {
|
|
|
245
270
|
logSubject(ref, opts = {}) {
|
|
246
271
|
return this.exec(v.logSubject(ref), opts);
|
|
247
272
|
}
|
|
248
|
-
/** `git config --get <key>`, or null when unset. */
|
|
273
|
+
/** `git config --get <key>`, or null when unset. `scope` reads one file only. */
|
|
249
274
|
configGet(key, opts = {}) {
|
|
250
|
-
return this.exec(v.configGet(key), opts);
|
|
275
|
+
return this.exec(v.configGet(key, opts), opts);
|
|
276
|
+
}
|
|
277
|
+
/** Every value of a multi-valued key, verbatim; `[]` when unset. */
|
|
278
|
+
configGetAll(key, opts = {}) {
|
|
279
|
+
return this.exec(v.configGetAll(key, opts), opts);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* A key read as a boolean by git, or null when unset. A value git cannot
|
|
283
|
+
* read as a boolean throws.
|
|
284
|
+
*/
|
|
285
|
+
configGetBool(key, opts = {}) {
|
|
286
|
+
return this.exec(v.configGetBool(key, opts), opts);
|
|
251
287
|
}
|
|
252
288
|
/** True iff `rev` resolves to an object (`cat-file -e`). */
|
|
253
289
|
objectExists(rev, opts = {}) {
|
|
@@ -290,13 +326,19 @@ export class Git {
|
|
|
290
326
|
lsFilesTagged(opts = {}) {
|
|
291
327
|
return this.exec(v.lsFilesTagged(), opts);
|
|
292
328
|
}
|
|
293
|
-
/**
|
|
329
|
+
/**
|
|
330
|
+
* The unified diff; `""` when nothing differs. A bad rev, or a cwd outside a
|
|
331
|
+
* repository, throws. See `diffText` in `verbs.ts`.
|
|
332
|
+
*/
|
|
294
333
|
diffText(rev, opts = {}) {
|
|
295
|
-
return this.exec(v.diffText(rev, opts));
|
|
334
|
+
return this.exec(v.diffText(rev, opts), opts);
|
|
296
335
|
}
|
|
297
|
-
/**
|
|
298
|
-
|
|
299
|
-
|
|
336
|
+
/**
|
|
337
|
+
* One untracked file rendered as an all-added diff. A path git cannot read
|
|
338
|
+
* throws. See `diffAddedFile` in `verbs.ts`.
|
|
339
|
+
*/
|
|
340
|
+
diffAddedFile(relPath, opts = {}) {
|
|
341
|
+
return this.exec(v.diffAddedFile(relPath), opts);
|
|
300
342
|
}
|
|
301
343
|
/** `for-each-ref` rows, one line each, in the caller's format. */
|
|
302
344
|
forEachRef(pattern, opts = {}) {
|
|
@@ -380,12 +422,35 @@ export class Git {
|
|
|
380
422
|
return this.exec(v.aheadBehind(base, tip), opts);
|
|
381
423
|
}
|
|
382
424
|
/** Configured remote names (`git remote`); `[]` when there are none. */
|
|
383
|
-
|
|
425
|
+
remotes(opts = {}) {
|
|
384
426
|
return this.exec(v.remote(), opts);
|
|
385
427
|
}
|
|
386
|
-
/**
|
|
428
|
+
/**
|
|
429
|
+
* The same as {@link Git.remotes}.
|
|
430
|
+
*
|
|
431
|
+
* @deprecated Use `remotes()`. The name `remote()` reads as one remote, but
|
|
432
|
+
* it returns every remote name. It will be removed at 1.0.
|
|
433
|
+
*/
|
|
434
|
+
remote(opts = {}) {
|
|
435
|
+
return this.remotes(opts);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* A remote's fetch URL (push URL with `push`), or null when no remote by
|
|
439
|
+
* that name exists.
|
|
440
|
+
*/
|
|
387
441
|
remoteGetUrl(name, opts = {}) {
|
|
388
|
-
return this.exec(v.remoteGetUrl(name), opts);
|
|
442
|
+
return this.exec(v.remoteGetUrl(name, opts), opts);
|
|
443
|
+
}
|
|
444
|
+
/** Every URL a remote has (push URLs with `push`); `[]` for an unknown remote. */
|
|
445
|
+
remoteGetUrls(name, opts = {}) {
|
|
446
|
+
return this.exec(v.remoteGetUrls(name, opts), opts);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The full refname the remote's HEAD points at, asked over the network; null
|
|
450
|
+
* when the remote names none. See `remoteHead` in `verbs.ts`.
|
|
451
|
+
*/
|
|
452
|
+
remoteHead(remote, opts = {}) {
|
|
453
|
+
return this.exec(v.remoteHead(remote), opts);
|
|
389
454
|
}
|
|
390
455
|
/**
|
|
391
456
|
* The coordinate (`owner`, `repo`, `host`, `port`) a remote's URL names, or
|
|
@@ -434,11 +499,11 @@ export class Git {
|
|
|
434
499
|
this.exec(v.clone(url, dest, opts), opts);
|
|
435
500
|
}
|
|
436
501
|
/**
|
|
437
|
-
* Push a refspec.
|
|
438
|
-
*
|
|
439
|
-
*
|
|
502
|
+
* Push a refspec. A {@link ForceLease} pins `--force-with-lease`, which means
|
|
503
|
+
* "nobody has touched this since I looked". `{forceWithLease: true}` adds the
|
|
504
|
+
* bare flag, which is the unsafe form: it compares against the
|
|
440
505
|
* remote-tracking ref, which a fetch in this same process may have just
|
|
441
|
-
* updated.
|
|
506
|
+
* updated. See `push` in `verbs.ts`.
|
|
442
507
|
*/
|
|
443
508
|
push(remote, refspec, opts = {}) {
|
|
444
509
|
this.exec(v.push(remote, refspec, opts), opts);
|
|
@@ -455,7 +520,10 @@ export class Git {
|
|
|
455
520
|
deleteBranch(name, opts = {}) {
|
|
456
521
|
this.exec(v.deleteBranch(name, opts), opts);
|
|
457
522
|
}
|
|
458
|
-
/**
|
|
523
|
+
/**
|
|
524
|
+
* Remove config section `name`; false when it was absent. See
|
|
525
|
+
* `configRemoveSection` in `verbs.ts`.
|
|
526
|
+
*/
|
|
459
527
|
configRemoveSection(name, opts = {}) {
|
|
460
528
|
return this.exec(v.configRemoveSection(name), opts);
|
|
461
529
|
}
|
|
@@ -525,10 +593,13 @@ export class Git {
|
|
|
525
593
|
return this.exec(v.lsFilesUnmerged(), opts);
|
|
526
594
|
}
|
|
527
595
|
/**
|
|
528
|
-
* Resolve conflicted `paths` to one side wholesale.
|
|
529
|
-
* for a path that is not
|
|
596
|
+
* Resolve conflicted `paths` to one side wholesale. An empty list returns
|
|
597
|
+
* without running git. Silently does nothing for a path that is not
|
|
598
|
+
* conflicted — see `checkoutSide` in `verbs.ts`.
|
|
530
599
|
*/
|
|
531
600
|
checkoutSide(side, paths, opts = {}) {
|
|
601
|
+
if (paths.length === 0)
|
|
602
|
+
return;
|
|
532
603
|
this.exec(v.checkoutSide(side, paths), opts);
|
|
533
604
|
}
|
|
534
605
|
/** `git checkout [-f] [-b|-B <branch>] <ref>`. */
|