just-git 1.2.0 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -206
- package/dist/{hooks-Boa35Qx_.d.ts → hooks-4DvkF2xT.d.ts} +141 -4
- package/dist/index.d.ts +25 -72
- package/dist/index.js +336 -336
- package/dist/repo/index.d.ts +27 -1
- package/dist/repo/index.js +4 -4
- package/dist/server/index.d.ts +54 -116
- package/dist/server/index.js +46 -29
- package/package.json +3 -1
|
@@ -1,30 +1,91 @@
|
|
|
1
|
+
/** File/directory metadata returned by {@link FileSystem.stat} and {@link FileSystem.lstat}. */
|
|
1
2
|
interface FileStat {
|
|
3
|
+
/** True if the path points to a regular file. */
|
|
2
4
|
isFile: boolean;
|
|
5
|
+
/** True if the path points to a directory. */
|
|
3
6
|
isDirectory: boolean;
|
|
7
|
+
/** True if the path is a symbolic link (only meaningful from {@link FileSystem.lstat}). */
|
|
4
8
|
isSymbolicLink: boolean;
|
|
9
|
+
/** Unix file mode (e.g. `0o100644` for a regular file, `0o040755` for a directory). */
|
|
5
10
|
mode: number;
|
|
11
|
+
/** File size in bytes (0 for directories). */
|
|
6
12
|
size: number;
|
|
13
|
+
/** Last modification time. */
|
|
7
14
|
mtime: Date;
|
|
8
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Filesystem interface required by just-git.
|
|
18
|
+
*
|
|
19
|
+
* Implement this to run git operations against any storage backend —
|
|
20
|
+
* in-memory, real disk, IndexedDB, remote, etc. All paths are absolute
|
|
21
|
+
* POSIX-style strings (e.g. `"/repo/src/index.ts"`).
|
|
22
|
+
*
|
|
23
|
+
* The three optional symlink methods (`lstat`, `readlink`, `symlink`) enable
|
|
24
|
+
* symlink support. When omitted, symlinks degrade to plain files containing
|
|
25
|
+
* the target path as content (`core.symlinks=false` behavior).
|
|
26
|
+
*
|
|
27
|
+
* See {@link MemoryFileSystem} for a ready-made in-memory implementation.
|
|
28
|
+
*/
|
|
9
29
|
interface FileSystem {
|
|
30
|
+
/**
|
|
31
|
+
* Read a file's contents as a UTF-8 string.
|
|
32
|
+
* @throws Error if the path doesn't exist or is a directory.
|
|
33
|
+
*/
|
|
10
34
|
readFile(path: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Read a file's contents as raw bytes.
|
|
37
|
+
* @throws Error if the path doesn't exist or is a directory.
|
|
38
|
+
*/
|
|
11
39
|
readFileBuffer(path: string): Promise<Uint8Array>;
|
|
40
|
+
/**
|
|
41
|
+
* Write content to a file, creating it if it doesn't exist and
|
|
42
|
+
* overwriting if it does. Parent directories must already exist.
|
|
43
|
+
*/
|
|
12
44
|
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
45
|
+
/** Check whether a path exists (file, directory, or symlink). */
|
|
13
46
|
exists(path: string): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Get file/directory metadata, following symlinks.
|
|
49
|
+
* @throws Error if the path doesn't exist.
|
|
50
|
+
*/
|
|
14
51
|
stat(path: string): Promise<FileStat>;
|
|
52
|
+
/**
|
|
53
|
+
* Create a directory.
|
|
54
|
+
* @throws Error if the parent doesn't exist (unless `recursive: true`) or the path already exists as a file.
|
|
55
|
+
*/
|
|
15
56
|
mkdir(path: string, options?: {
|
|
16
57
|
recursive?: boolean;
|
|
17
58
|
}): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* List the names of entries in a directory (not full paths).
|
|
61
|
+
* @throws Error if the path doesn't exist or is not a directory.
|
|
62
|
+
*/
|
|
18
63
|
readdir(path: string): Promise<string[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Remove a file or directory.
|
|
66
|
+
* @throws Error if the path doesn't exist (unless `force: true`) or is a non-empty directory (unless `recursive: true`).
|
|
67
|
+
*/
|
|
19
68
|
rm(path: string, options?: {
|
|
20
69
|
recursive?: boolean;
|
|
21
70
|
force?: boolean;
|
|
22
71
|
}): Promise<void>;
|
|
23
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Get file/directory metadata without following symlinks.
|
|
74
|
+
* Falls back to {@link stat} semantics when not implemented.
|
|
75
|
+
* @throws Error if the path doesn't exist.
|
|
76
|
+
*/
|
|
24
77
|
lstat?(path: string): Promise<FileStat>;
|
|
25
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Read the target path of a symbolic link.
|
|
80
|
+
* @throws Error if the path doesn't exist or is not a symlink.
|
|
81
|
+
*/
|
|
26
82
|
readlink?(path: string): Promise<string>;
|
|
27
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Create a symbolic link at `path` pointing to `target`.
|
|
85
|
+
* @param target - The path the symlink should point to.
|
|
86
|
+
* @param path - Where to create the symlink.
|
|
87
|
+
* @throws Error if `path` already exists.
|
|
88
|
+
*/
|
|
28
89
|
symlink?(target: string, path: string): Promise<void>;
|
|
29
90
|
}
|
|
30
91
|
|
|
@@ -91,6 +152,7 @@ interface Index {
|
|
|
91
152
|
version: number;
|
|
92
153
|
entries: IndexEntry[];
|
|
93
154
|
}
|
|
155
|
+
/** A resolved ref name and its target commit hash. */
|
|
94
156
|
interface RefEntry {
|
|
95
157
|
name: string;
|
|
96
158
|
hash: ObjectId;
|
|
@@ -201,6 +263,7 @@ interface TreeDiffEntry {
|
|
|
201
263
|
newMode?: string;
|
|
202
264
|
}
|
|
203
265
|
|
|
266
|
+
/** HTTP authentication credentials for Smart HTTP transport. */
|
|
204
267
|
type HttpAuth = {
|
|
205
268
|
type: "basic";
|
|
206
269
|
username: string;
|
|
@@ -210,16 +273,29 @@ type HttpAuth = {
|
|
|
210
273
|
token: string;
|
|
211
274
|
};
|
|
212
275
|
|
|
276
|
+
/** Result of executing a git command. */
|
|
213
277
|
interface ExecResult {
|
|
214
278
|
stdout: string;
|
|
215
279
|
stderr: string;
|
|
216
280
|
exitCode: number;
|
|
217
281
|
}
|
|
218
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Callback that provides HTTP authentication for remote operations.
|
|
285
|
+
* Called with the remote URL; return credentials or null for anonymous access.
|
|
286
|
+
*/
|
|
219
287
|
type CredentialProvider = (url: string) => HttpAuth | null | Promise<HttpAuth | null>;
|
|
288
|
+
/**
|
|
289
|
+
* Override the author/committer identity for commits.
|
|
290
|
+
*
|
|
291
|
+
* When `locked` is true, this identity always wins — even if the agent
|
|
292
|
+
* sets `GIT_AUTHOR_NAME` or runs `git config user.name`. When unlocked
|
|
293
|
+
* (default), acts as a fallback when env vars and git config are absent.
|
|
294
|
+
*/
|
|
220
295
|
interface IdentityOverride {
|
|
221
296
|
name: string;
|
|
222
297
|
email: string;
|
|
298
|
+
/** When true, this identity cannot be overridden by env vars or git config. */
|
|
223
299
|
locked?: boolean;
|
|
224
300
|
}
|
|
225
301
|
/**
|
|
@@ -237,7 +313,12 @@ interface ConfigOverrides {
|
|
|
237
313
|
locked?: Record<string, string>;
|
|
238
314
|
defaults?: Record<string, string>;
|
|
239
315
|
}
|
|
316
|
+
/** Custom fetch function signature for HTTP transport. */
|
|
240
317
|
type FetchFunction = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
318
|
+
/**
|
|
319
|
+
* Controls which remote URLs the git instance may access over HTTP.
|
|
320
|
+
* Set to `false` on {@link GitOptions.network} to block all HTTP access.
|
|
321
|
+
*/
|
|
241
322
|
interface NetworkPolicy {
|
|
242
323
|
/**
|
|
243
324
|
* Allowed URL patterns. Can be:
|
|
@@ -248,20 +329,28 @@ interface NetworkPolicy {
|
|
|
248
329
|
/** Custom fetch function for HTTP transport. Falls back to globalThis.fetch. */
|
|
249
330
|
fetch?: FetchFunction;
|
|
250
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Returned from pre-hooks to block an operation.
|
|
334
|
+
* The optional `message` is surfaced as stderr.
|
|
335
|
+
*/
|
|
251
336
|
interface Rejection {
|
|
252
337
|
reject: true;
|
|
253
338
|
message?: string;
|
|
254
339
|
}
|
|
340
|
+
/** Type guard for {@link Rejection}. */
|
|
255
341
|
declare function isRejection(value: unknown): value is Rejection;
|
|
342
|
+
/** Fired before a commit is created. Return a {@link Rejection} to block. */
|
|
256
343
|
interface PreCommitEvent {
|
|
257
344
|
readonly repo: GitRepo;
|
|
258
345
|
readonly index: Index;
|
|
259
346
|
readonly treeHash: ObjectId;
|
|
260
347
|
}
|
|
348
|
+
/** Fired after `preCommit` passes. Mutate `message` to rewrite the commit message. */
|
|
261
349
|
interface CommitMsgEvent {
|
|
262
350
|
readonly repo: GitRepo;
|
|
263
351
|
message: string;
|
|
264
352
|
}
|
|
353
|
+
/** Fired before a merge commit. Mutate `message` to rewrite the merge message. */
|
|
265
354
|
interface MergeMsgEvent {
|
|
266
355
|
readonly repo: GitRepo;
|
|
267
356
|
message: string;
|
|
@@ -269,6 +358,7 @@ interface MergeMsgEvent {
|
|
|
269
358
|
readonly headHash: ObjectId;
|
|
270
359
|
readonly theirsHash: ObjectId;
|
|
271
360
|
}
|
|
361
|
+
/** Fired after a commit is successfully created. */
|
|
272
362
|
interface PostCommitEvent {
|
|
273
363
|
readonly repo: GitRepo;
|
|
274
364
|
readonly hash: ObjectId;
|
|
@@ -277,6 +367,7 @@ interface PostCommitEvent {
|
|
|
277
367
|
readonly parents: readonly ObjectId[];
|
|
278
368
|
readonly author: Identity;
|
|
279
369
|
}
|
|
370
|
+
/** Fired before a three-way merge commit is written. Return a {@link Rejection} to block. */
|
|
280
371
|
interface PreMergeCommitEvent {
|
|
281
372
|
readonly repo: GitRepo;
|
|
282
373
|
readonly mergeMessage: string;
|
|
@@ -284,6 +375,7 @@ interface PreMergeCommitEvent {
|
|
|
284
375
|
readonly headHash: ObjectId;
|
|
285
376
|
readonly theirsHash: ObjectId;
|
|
286
377
|
}
|
|
378
|
+
/** Fired after a merge completes (fast-forward or three-way). */
|
|
287
379
|
interface PostMergeEvent {
|
|
288
380
|
readonly repo: GitRepo;
|
|
289
381
|
readonly headHash: ObjectId;
|
|
@@ -291,12 +383,14 @@ interface PostMergeEvent {
|
|
|
291
383
|
readonly strategy: "fast-forward" | "three-way";
|
|
292
384
|
readonly commitHash: ObjectId | null;
|
|
293
385
|
}
|
|
386
|
+
/** Fired after a branch checkout or detached HEAD checkout completes. */
|
|
294
387
|
interface PostCheckoutEvent {
|
|
295
388
|
readonly repo: GitRepo;
|
|
296
389
|
readonly prevHead: ObjectId | null;
|
|
297
390
|
readonly newHead: ObjectId;
|
|
298
391
|
readonly isBranchCheckout: boolean;
|
|
299
392
|
}
|
|
393
|
+
/** Fired before objects are transferred during `git push`. Return a {@link Rejection} to block. */
|
|
300
394
|
interface PrePushEvent {
|
|
301
395
|
readonly repo: GitRepo;
|
|
302
396
|
readonly remote: string;
|
|
@@ -310,17 +404,21 @@ interface PrePushEvent {
|
|
|
310
404
|
delete: boolean;
|
|
311
405
|
}>;
|
|
312
406
|
}
|
|
407
|
+
/** Fired after a push completes. Same payload as {@link PrePushEvent}. */
|
|
313
408
|
type PostPushEvent = PrePushEvent;
|
|
409
|
+
/** Fired before a rebase begins. Return a {@link Rejection} to block. */
|
|
314
410
|
interface PreRebaseEvent {
|
|
315
411
|
readonly repo: GitRepo;
|
|
316
412
|
readonly upstream: string;
|
|
317
413
|
readonly branch: string | null;
|
|
318
414
|
}
|
|
415
|
+
/** Fired before a checkout or switch. Return a {@link Rejection} to block. */
|
|
319
416
|
interface PreCheckoutEvent {
|
|
320
417
|
readonly repo: GitRepo;
|
|
321
418
|
readonly target: string;
|
|
322
419
|
readonly mode: "switch" | "detach" | "create-branch" | "paths";
|
|
323
420
|
}
|
|
421
|
+
/** Fired before a fetch begins. Return a {@link Rejection} to block. */
|
|
324
422
|
interface PreFetchEvent {
|
|
325
423
|
readonly repo: GitRepo;
|
|
326
424
|
readonly remote: string;
|
|
@@ -329,12 +427,14 @@ interface PreFetchEvent {
|
|
|
329
427
|
readonly prune: boolean;
|
|
330
428
|
readonly tags: boolean;
|
|
331
429
|
}
|
|
430
|
+
/** Fired after a fetch completes. */
|
|
332
431
|
interface PostFetchEvent {
|
|
333
432
|
readonly repo: GitRepo;
|
|
334
433
|
readonly remote: string;
|
|
335
434
|
readonly url: string;
|
|
336
435
|
readonly refsUpdated: number;
|
|
337
436
|
}
|
|
437
|
+
/** Fired before a clone begins. Return a {@link Rejection} to block. */
|
|
338
438
|
interface PreCloneEvent {
|
|
339
439
|
readonly repo?: GitRepo;
|
|
340
440
|
readonly repository: string;
|
|
@@ -342,6 +442,7 @@ interface PreCloneEvent {
|
|
|
342
442
|
readonly bare: boolean;
|
|
343
443
|
readonly branch: string | null;
|
|
344
444
|
}
|
|
445
|
+
/** Fired after a clone completes. */
|
|
345
446
|
interface PostCloneEvent {
|
|
346
447
|
readonly repo: GitRepo;
|
|
347
448
|
readonly repository: string;
|
|
@@ -349,11 +450,13 @@ interface PostCloneEvent {
|
|
|
349
450
|
readonly bare: boolean;
|
|
350
451
|
readonly branch: string | null;
|
|
351
452
|
}
|
|
453
|
+
/** Fired before a pull begins. Return a {@link Rejection} to block. */
|
|
352
454
|
interface PrePullEvent {
|
|
353
455
|
readonly repo: GitRepo;
|
|
354
456
|
readonly remote: string;
|
|
355
457
|
readonly branch: string | null;
|
|
356
458
|
}
|
|
459
|
+
/** Fired after a pull completes. */
|
|
357
460
|
interface PostPullEvent {
|
|
358
461
|
readonly repo: GitRepo;
|
|
359
462
|
readonly remote: string;
|
|
@@ -361,16 +464,19 @@ interface PostPullEvent {
|
|
|
361
464
|
readonly strategy: "up-to-date" | "fast-forward" | "three-way" | "rebase";
|
|
362
465
|
readonly commitHash: ObjectId | null;
|
|
363
466
|
}
|
|
467
|
+
/** Fired before a reset. Return a {@link Rejection} to block. */
|
|
364
468
|
interface PreResetEvent {
|
|
365
469
|
readonly repo: GitRepo;
|
|
366
470
|
readonly mode: "soft" | "mixed" | "hard" | "paths";
|
|
367
471
|
readonly target: string | null;
|
|
368
472
|
}
|
|
473
|
+
/** Fired after a reset completes. */
|
|
369
474
|
interface PostResetEvent {
|
|
370
475
|
readonly repo: GitRepo;
|
|
371
476
|
readonly mode: "soft" | "mixed" | "hard" | "paths";
|
|
372
477
|
readonly targetHash: ObjectId | null;
|
|
373
478
|
}
|
|
479
|
+
/** Fired before `git clean`. Return a {@link Rejection} to block. */
|
|
374
480
|
interface PreCleanEvent {
|
|
375
481
|
readonly repo: GitRepo;
|
|
376
482
|
readonly dryRun: boolean;
|
|
@@ -379,11 +485,13 @@ interface PreCleanEvent {
|
|
|
379
485
|
readonly removeIgnored: boolean;
|
|
380
486
|
readonly onlyIgnored: boolean;
|
|
381
487
|
}
|
|
488
|
+
/** Fired after `git clean` completes. */
|
|
382
489
|
interface PostCleanEvent {
|
|
383
490
|
readonly repo: GitRepo;
|
|
384
491
|
readonly removed: readonly string[];
|
|
385
492
|
readonly dryRun: boolean;
|
|
386
493
|
}
|
|
494
|
+
/** Fired before `git rm`. Return a {@link Rejection} to block. */
|
|
387
495
|
interface PreRmEvent {
|
|
388
496
|
readonly repo: GitRepo;
|
|
389
497
|
readonly paths: readonly string[];
|
|
@@ -391,60 +499,71 @@ interface PreRmEvent {
|
|
|
391
499
|
readonly recursive: boolean;
|
|
392
500
|
readonly force: boolean;
|
|
393
501
|
}
|
|
502
|
+
/** Fired after `git rm` completes. */
|
|
394
503
|
interface PostRmEvent {
|
|
395
504
|
readonly repo: GitRepo;
|
|
396
505
|
readonly removedPaths: readonly string[];
|
|
397
506
|
readonly cached: boolean;
|
|
398
507
|
}
|
|
508
|
+
/** Fired before a cherry-pick. Return a {@link Rejection} to block. */
|
|
399
509
|
interface PreCherryPickEvent {
|
|
400
510
|
readonly repo: GitRepo;
|
|
401
511
|
readonly mode: "pick" | "continue" | "abort";
|
|
402
512
|
readonly commit: string | null;
|
|
403
513
|
}
|
|
514
|
+
/** Fired after a cherry-pick completes. */
|
|
404
515
|
interface PostCherryPickEvent {
|
|
405
516
|
readonly repo: GitRepo;
|
|
406
517
|
readonly mode: "pick" | "continue" | "abort";
|
|
407
518
|
readonly commitHash: ObjectId | null;
|
|
408
519
|
readonly hadConflicts: boolean;
|
|
409
520
|
}
|
|
521
|
+
/** Fired before a revert. Return a {@link Rejection} to block. */
|
|
410
522
|
interface PreRevertEvent {
|
|
411
523
|
readonly repo: GitRepo;
|
|
412
524
|
readonly mode: "revert" | "continue" | "abort";
|
|
413
525
|
readonly commit: string | null;
|
|
414
526
|
}
|
|
527
|
+
/** Fired after a revert completes. */
|
|
415
528
|
interface PostRevertEvent {
|
|
416
529
|
readonly repo: GitRepo;
|
|
417
530
|
readonly mode: "revert" | "continue" | "abort";
|
|
418
531
|
readonly commitHash: ObjectId | null;
|
|
419
532
|
readonly hadConflicts: boolean;
|
|
420
533
|
}
|
|
534
|
+
/** Fired before a stash operation. Return a {@link Rejection} to block. */
|
|
421
535
|
interface PreStashEvent {
|
|
422
536
|
readonly repo: GitRepo;
|
|
423
537
|
readonly action: "push" | "pop" | "apply" | "list" | "drop" | "show" | "clear";
|
|
424
538
|
readonly ref: string | null;
|
|
425
539
|
}
|
|
540
|
+
/** Fired after a stash operation completes. */
|
|
426
541
|
interface PostStashEvent {
|
|
427
542
|
readonly repo: GitRepo;
|
|
428
543
|
readonly action: "push" | "pop" | "apply" | "list" | "drop" | "show" | "clear";
|
|
429
544
|
readonly ok: boolean;
|
|
430
545
|
}
|
|
546
|
+
/** Fired whenever a ref is created or updated. */
|
|
431
547
|
interface RefUpdateEvent {
|
|
432
548
|
readonly repo: GitRepo;
|
|
433
549
|
readonly ref: string;
|
|
434
550
|
readonly oldHash: ObjectId | null;
|
|
435
551
|
readonly newHash: ObjectId;
|
|
436
552
|
}
|
|
553
|
+
/** Fired whenever a ref is deleted. */
|
|
437
554
|
interface RefDeleteEvent {
|
|
438
555
|
readonly repo: GitRepo;
|
|
439
556
|
readonly ref: string;
|
|
440
557
|
readonly oldHash: ObjectId | null;
|
|
441
558
|
}
|
|
559
|
+
/** Fired whenever a git object (blob, tree, commit, tag) is written to the store. */
|
|
442
560
|
interface ObjectWriteEvent {
|
|
443
561
|
readonly repo: GitRepo;
|
|
444
562
|
readonly type: ObjectType;
|
|
445
563
|
readonly hash: ObjectId;
|
|
446
564
|
}
|
|
447
565
|
|
|
566
|
+
/** Fired before any git subcommand executes. Return a {@link Rejection} to block. */
|
|
448
567
|
interface BeforeCommandEvent {
|
|
449
568
|
readonly command: string;
|
|
450
569
|
readonly args: string[];
|
|
@@ -452,6 +571,7 @@ interface BeforeCommandEvent {
|
|
|
452
571
|
readonly cwd: string;
|
|
453
572
|
readonly env: Map<string, string>;
|
|
454
573
|
}
|
|
574
|
+
/** Fired after any git subcommand completes. */
|
|
455
575
|
interface AfterCommandEvent {
|
|
456
576
|
readonly command: string;
|
|
457
577
|
readonly args: string[];
|
|
@@ -459,6 +579,16 @@ interface AfterCommandEvent {
|
|
|
459
579
|
}
|
|
460
580
|
type PreHookReturn = void | Rejection | Promise<void | Rejection>;
|
|
461
581
|
type PostHookReturn = void | Promise<void>;
|
|
582
|
+
/**
|
|
583
|
+
* Hook callbacks for intercepting git operations.
|
|
584
|
+
*
|
|
585
|
+
* Pre-hooks can return a {@link Rejection} to block the operation.
|
|
586
|
+
* Post-hooks are fire-and-forget. Low-level events (`onRefUpdate`,
|
|
587
|
+
* `onRefDelete`, `onObjectWrite`) fire synchronously on every
|
|
588
|
+
* ref/object write.
|
|
589
|
+
*
|
|
590
|
+
* Use {@link composeGitHooks} to combine multiple hook sets.
|
|
591
|
+
*/
|
|
462
592
|
interface GitHooks {
|
|
463
593
|
preCommit?: (event: PreCommitEvent) => PreHookReturn;
|
|
464
594
|
commitMsg?: (event: CommitMsgEvent) => PreHookReturn;
|
|
@@ -495,6 +625,13 @@ interface GitHooks {
|
|
|
495
625
|
beforeCommand?: (event: BeforeCommandEvent) => PreHookReturn;
|
|
496
626
|
afterCommand?: (event: AfterCommandEvent) => PostHookReturn;
|
|
497
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* Combine multiple {@link GitHooks} objects into one.
|
|
630
|
+
*
|
|
631
|
+
* Pre-hooks chain in order, short-circuiting on the first {@link Rejection}.
|
|
632
|
+
* Post-hooks and low-level events chain in order, individually try/caught.
|
|
633
|
+
* Mutable-message hooks (`commitMsg`, `mergeMsg`) pass the mutated message through.
|
|
634
|
+
*/
|
|
498
635
|
declare function composeGitHooks(...hookSets: (GitHooks | undefined)[]): GitHooks;
|
|
499
636
|
|
|
500
|
-
export {
|
|
637
|
+
export { type Identity as $, type AfterCommandEvent as A, type BeforeCommandEvent as B, type CredentialProvider as C, type PrePullEvent as D, type ExecResult as E, type FileSystem as F, type GitHooks as G, type HttpAuth as H, type IdentityOverride as I, type PrePushEvent as J, type PreRebaseEvent as K, type PreResetEvent as L, type MergeMsgEvent as M, type NetworkPolicy as N, type ObjectStore as O, type PostCheckoutEvent as P, type PreRevertEvent as Q, type RemoteResolver as R, type PreRmEvent as S, type PreStashEvent as T, type RefDeleteEvent as U, type RefEntry as V, type RefUpdateEvent as W, type Rejection as X, composeGitHooks as Y, isRejection as Z, type ObjectId as _, type RefStore as a, type TreeDiffEntry as a0, type Commit as a1, type ObjectType as a2, type RawObject as a3, type Ref as a4, type ConfigOverrides as b, type FileStat as c, type GitContext as d, type CommitMsgEvent as e, type GitRepo as f, type ObjectWriteEvent as g, type PostCherryPickEvent as h, type PostCleanEvent as i, type PostCloneEvent as j, type PostCommitEvent as k, type PostFetchEvent as l, type PostMergeEvent as m, type PostPullEvent as n, type PostPushEvent as o, type PostResetEvent as p, type PostRevertEvent as q, type PostRmEvent as r, type PostStashEvent as s, type PreCheckoutEvent as t, type PreCherryPickEvent as u, type PreCleanEvent as v, type PreCloneEvent as w, type PreCommitEvent as x, type PreFetchEvent as y, type PreMergeCommitEvent as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,53 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AfterCommandEvent, B as BeforeCommandEvent,
|
|
3
|
-
|
|
4
|
-
/** Depth value that represents "full history" (used by --unshallow). */
|
|
5
|
-
declare const INFINITE_DEPTH = 2147483647;
|
|
6
|
-
/** Shallow boundary delta: what to add/remove from `.git/shallow`. */
|
|
7
|
-
interface ShallowUpdate {
|
|
8
|
-
/** Commits to add to the shallow boundary. */
|
|
9
|
-
shallow: ObjectId[];
|
|
10
|
-
/** Commits to remove from the shallow boundary (now have full parents). */
|
|
11
|
-
unshallow: ObjectId[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Read the set of shallow boundary commit hashes from `.git/shallow`.
|
|
15
|
-
* Returns an empty set if the file doesn't exist or is empty.
|
|
16
|
-
*/
|
|
17
|
-
declare function readShallowCommits(ctx: GitContext): Promise<Set<ObjectId>>;
|
|
18
|
-
/**
|
|
19
|
-
* Write the shallow boundary set to `.git/shallow`.
|
|
20
|
-
* Removes the file if the set is empty (repo is no longer shallow).
|
|
21
|
-
*/
|
|
22
|
-
declare function writeShallowCommits(ctx: GitContext, hashes: Set<ObjectId>): Promise<void>;
|
|
23
|
-
/** Check whether a repo is shallow (has a non-empty `.git/shallow` file). */
|
|
24
|
-
declare function isShallowRepo(ctx: GitContext): Promise<boolean>;
|
|
25
|
-
/**
|
|
26
|
-
* Merge a `ShallowUpdate` into the current `.git/shallow` file.
|
|
27
|
-
* Adds new shallow commits, removes unshallowed ones, persists the result.
|
|
28
|
-
*/
|
|
29
|
-
declare function applyShallowUpdates(ctx: GitContext, updates: ShallowUpdate, existing?: Set<ObjectId>): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Compute the shallow boundary for a depth-limited fetch.
|
|
32
|
-
*
|
|
33
|
-
* BFS from `wants` up to `depth` levels of commit parents. Commits
|
|
34
|
-
* at exactly depth N (whose parents would exceed the limit) become
|
|
35
|
-
* the new shallow boundary. Any commit in `clientShallows` that is
|
|
36
|
-
* now within the traversal depth gets unshallowed.
|
|
37
|
-
*
|
|
38
|
-
* The returned `shallow` set is the new boundary — commits whose
|
|
39
|
-
* parents the client should NOT expect to have. The `unshallow` set
|
|
40
|
-
* is commits that were previously shallow but are now within depth.
|
|
41
|
-
*/
|
|
42
|
-
declare function computeShallowBoundary(repo: GitRepo, wants: ObjectId[], depth: number, clientShallows: Set<ObjectId>): Promise<ShallowUpdate>;
|
|
43
|
-
|
|
44
|
-
/** Options for shallow/depth-limited fetches. */
|
|
45
|
-
interface ShallowFetchOptions {
|
|
46
|
-
/** Maximum commit depth from the wanted refs. */
|
|
47
|
-
depth?: number;
|
|
48
|
-
/** Commits currently in the client's `.git/shallow` file. */
|
|
49
|
-
existingShallows?: Set<ObjectId>;
|
|
50
|
-
}
|
|
1
|
+
import { F as FileSystem, G as GitHooks, C as CredentialProvider, I as IdentityOverride, N as NetworkPolicy, R as RemoteResolver, O as ObjectStore, a as RefStore, b as ConfigOverrides, E as ExecResult, c as FileStat, d as GitContext } from './hooks-4DvkF2xT.js';
|
|
2
|
+
export { A as AfterCommandEvent, B as BeforeCommandEvent, e as CommitMsgEvent, f as GitRepo, H as HttpAuth, M as MergeMsgEvent, g as ObjectWriteEvent, P as PostCheckoutEvent, h as PostCherryPickEvent, i as PostCleanEvent, j as PostCloneEvent, k as PostCommitEvent, l as PostFetchEvent, m as PostMergeEvent, n as PostPullEvent, o as PostPushEvent, p as PostResetEvent, q as PostRevertEvent, r as PostRmEvent, s as PostStashEvent, t as PreCheckoutEvent, u as PreCherryPickEvent, v as PreCleanEvent, w as PreCloneEvent, x as PreCommitEvent, y as PreFetchEvent, z as PreMergeCommitEvent, D as PrePullEvent, J as PrePushEvent, K as PreRebaseEvent, L as PreResetEvent, Q as PreRevertEvent, S as PreRmEvent, T as PreStashEvent, U as RefDeleteEvent, V as RefEntry, W as RefUpdateEvent, X as Rejection, Y as composeGitHooks, Z as isRejection } from './hooks-4DvkF2xT.js';
|
|
51
3
|
|
|
52
4
|
/** Options for subcommand execution (mirrors just-bash's CommandExecOptions). */
|
|
53
5
|
interface CommandExecOptions {
|
|
@@ -70,7 +22,15 @@ interface CommandContext {
|
|
|
70
22
|
exec?: (command: string, options: CommandExecOptions) => Promise<ExecResult>;
|
|
71
23
|
signal?: AbortSignal;
|
|
72
24
|
}
|
|
25
|
+
/** Git subcommand name. Used with {@link GitOptions.disabled} to block specific commands. */
|
|
73
26
|
type GitCommandName = "init" | "clone" | "fetch" | "pull" | "push" | "add" | "blame" | "commit" | "status" | "log" | "branch" | "tag" | "checkout" | "diff" | "reset" | "merge" | "cherry-pick" | "revert" | "rebase" | "mv" | "rm" | "remote" | "config" | "show" | "stash" | "rev-parse" | "ls-files" | "clean" | "switch" | "restore" | "reflog" | "repack" | "gc" | "bisect";
|
|
27
|
+
/**
|
|
28
|
+
* Configuration for a {@link Git} instance.
|
|
29
|
+
*
|
|
30
|
+
* Controls hooks, identity, credentials, network access, command
|
|
31
|
+
* restrictions, and config overrides for all commands run through
|
|
32
|
+
* this instance.
|
|
33
|
+
*/
|
|
74
34
|
interface GitOptions {
|
|
75
35
|
hooks?: GitHooks;
|
|
76
36
|
credentials?: CredentialProvider;
|
|
@@ -102,21 +62,6 @@ interface GitOptions {
|
|
|
102
62
|
*/
|
|
103
63
|
config?: ConfigOverrides;
|
|
104
64
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Bundle of operator-level extensions threaded into command handlers
|
|
107
|
-
* via closures and merged onto GitContext after discovery.
|
|
108
|
-
*/
|
|
109
|
-
interface GitExtensions {
|
|
110
|
-
hooks?: GitHooks;
|
|
111
|
-
credentialProvider?: CredentialProvider;
|
|
112
|
-
identityOverride?: IdentityOverride;
|
|
113
|
-
fetchFn?: FetchFunction;
|
|
114
|
-
networkPolicy?: NetworkPolicy | false;
|
|
115
|
-
resolveRemote?: RemoteResolver;
|
|
116
|
-
objectStore?: ObjectStore;
|
|
117
|
-
refStore?: RefStore;
|
|
118
|
-
configOverrides?: ConfigOverrides;
|
|
119
|
-
}
|
|
120
65
|
/** Simplified context for {@link Git.exec}. */
|
|
121
66
|
interface ExecContext {
|
|
122
67
|
fs: FileSystem;
|
|
@@ -124,6 +69,19 @@ interface ExecContext {
|
|
|
124
69
|
env?: Record<string, string>;
|
|
125
70
|
stdin?: string;
|
|
126
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Git command handler. Runs git subcommands against a virtual filesystem.
|
|
74
|
+
*
|
|
75
|
+
* Create via {@link createGit}. Use as a standalone executor with
|
|
76
|
+
* {@link Git.exec}, or pass directly into just-bash's `customCommands`
|
|
77
|
+
* to make `git` available inside a virtual shell.
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* const git = createGit();
|
|
81
|
+
* const fs = new MemoryFileSystem();
|
|
82
|
+
* await git.exec("init", { fs, cwd: "/repo" });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
127
85
|
declare class Git {
|
|
128
86
|
readonly name = "git";
|
|
129
87
|
private blocked;
|
|
@@ -146,12 +104,7 @@ declare class Git {
|
|
|
146
104
|
exec: (command: string, ctx: ExecContext) => Promise<ExecResult>;
|
|
147
105
|
execute: (args: string[], ctx: CommandContext) => Promise<ExecResult>;
|
|
148
106
|
}
|
|
149
|
-
/**
|
|
150
|
-
* Tokenize a command string with basic shell quoting.
|
|
151
|
-
* Supports single quotes, double quotes (with backslash escapes),
|
|
152
|
-
* and whitespace splitting. Strips a leading "git" token if present.
|
|
153
|
-
*/
|
|
154
|
-
declare function tokenizeCommand(input: string): string[];
|
|
107
|
+
/** Create a new {@link Git} command handler with the given options. */
|
|
155
108
|
declare function createGit(options?: GitOptions): Git;
|
|
156
109
|
|
|
157
110
|
/**
|
|
@@ -194,4 +147,4 @@ declare class MemoryFileSystem implements FileSystem {
|
|
|
194
147
|
*/
|
|
195
148
|
declare function findRepo(fs: FileSystem, startPath: string): Promise<GitContext | null>;
|
|
196
149
|
|
|
197
|
-
export {
|
|
150
|
+
export { ConfigOverrides, CredentialProvider, type ExecContext, ExecResult, FileStat, FileSystem, Git, type GitCommandName, GitContext, GitHooks, type GitOptions, IdentityOverride, MemoryFileSystem, NetworkPolicy, ObjectStore, RefStore, RemoteResolver, createGit, findRepo };
|