isomorphic-git 1.32.1 → 1.32.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/index.d.cts ADDED
@@ -0,0 +1,4664 @@
1
+ export const __esModule: boolean;
2
+ export default index;
3
+ export type TreeEntry = {
4
+ /**
5
+ * - the 6 digit hexadecimal mode
6
+ */
7
+ mode: string;
8
+ /**
9
+ * - the name of the file or directory
10
+ */
11
+ path: string;
12
+ /**
13
+ * - the SHA-1 object id of the blob or tree
14
+ */
15
+ oid: string;
16
+ /**
17
+ * - the type of object
18
+ */
19
+ type: "commit" | "blob" | "tree";
20
+ };
21
+ /**
22
+ * - The object returned has the following schema:
23
+ */
24
+ export type ReadTreeResult = {
25
+ /**
26
+ * - SHA-1 object id of this tree
27
+ */
28
+ oid: string;
29
+ /**
30
+ * - the parsed tree object
31
+ */
32
+ tree: TreeObject;
33
+ };
34
+ /**
35
+ * - The object returned has the following schema:
36
+ */
37
+ export type FetchResult = {
38
+ /**
39
+ * - The branch that is cloned if no branch is specified
40
+ */
41
+ defaultBranch: string | null;
42
+ /**
43
+ * - The SHA-1 object id of the fetched head commit
44
+ */
45
+ fetchHead: string | null;
46
+ /**
47
+ * - a textual description of the branch that was fetched
48
+ */
49
+ fetchHeadDescription: string | null;
50
+ /**
51
+ * - The HTTP response headers returned by the git server
52
+ */
53
+ headers?: {
54
+ [x: string]: string;
55
+ } | undefined;
56
+ /**
57
+ * - A list of branches that were pruned, if you provided the `prune` parameter
58
+ */
59
+ pruned?: string[] | undefined;
60
+ };
61
+ /**
62
+ * - Returns an object with a schema like this:
63
+ */
64
+ export type MergeResult = {
65
+ /**
66
+ * - The SHA-1 object id that is now at the head of the branch. Absent only if `dryRun` was specified and `mergeCommit` is true.
67
+ */
68
+ oid?: string | undefined;
69
+ /**
70
+ * - True if the branch was already merged so no changes were made
71
+ */
72
+ alreadyMerged?: boolean | undefined;
73
+ /**
74
+ * - True if it was a fast-forward merge
75
+ */
76
+ fastForward?: boolean | undefined;
77
+ /**
78
+ * - True if merge resulted in a merge commit
79
+ */
80
+ mergeCommit?: boolean | undefined;
81
+ /**
82
+ * - The SHA-1 object id of the tree resulting from a merge commit
83
+ */
84
+ tree?: string | undefined;
85
+ };
86
+ /**
87
+ * - The object returned has the following schema:
88
+ */
89
+ export type GetRemoteInfoResult = {
90
+ /**
91
+ * - The list of capabilities returned by the server (part of the Git protocol)
92
+ */
93
+ capabilities: string[];
94
+ refs?: any;
95
+ /**
96
+ * - The default branch of the remote
97
+ */
98
+ HEAD?: string | undefined;
99
+ /**
100
+ * - The branches on the remote
101
+ */
102
+ heads?: {
103
+ [x: string]: string;
104
+ } | undefined;
105
+ /**
106
+ * - The special branches representing pull requests (non-standard)
107
+ */
108
+ pull?: {
109
+ [x: string]: string;
110
+ } | undefined;
111
+ /**
112
+ * - The tags on the remote
113
+ */
114
+ tags?: {
115
+ [x: string]: string;
116
+ } | undefined;
117
+ };
118
+ /**
119
+ * - This object has the following schema:
120
+ */
121
+ export type GetRemoteInfo2Result = {
122
+ /**
123
+ * - Git protocol version the server supports
124
+ */
125
+ protocolVersion: 1 | 2;
126
+ /**
127
+ * - An object of capabilities represented as keys and values
128
+ */
129
+ capabilities: {
130
+ [x: string]: string | true;
131
+ };
132
+ /**
133
+ * - Server refs (they get returned by protocol version 1 whether you want them or not)
134
+ */
135
+ refs?: ServerRef[] | undefined;
136
+ };
137
+ /**
138
+ * - The object returned has the following schema:
139
+ */
140
+ export type HashBlobResult = {
141
+ /**
142
+ * - The SHA-1 object id
143
+ */
144
+ oid: string;
145
+ /**
146
+ * - The type of the object
147
+ */
148
+ type: "blob";
149
+ /**
150
+ * - The wrapped git object (the thing that is hashed)
151
+ */
152
+ object: Uint8Array;
153
+ /**
154
+ * - The format of the object
155
+ */
156
+ format: "wrapped";
157
+ };
158
+ /**
159
+ * - This object has the following schema:
160
+ */
161
+ export type ServerRef = {
162
+ /**
163
+ * - The name of the ref
164
+ */
165
+ ref: string;
166
+ /**
167
+ * - The SHA-1 object id the ref points to
168
+ */
169
+ oid: string;
170
+ /**
171
+ * - The target ref pointed to by a symbolic ref
172
+ */
173
+ target?: string | undefined;
174
+ /**
175
+ * - If the oid is the SHA-1 object id of an annotated tag, this is the SHA-1 object id that the annotated tag points to
176
+ */
177
+ peeled?: string | undefined;
178
+ };
179
+ /**
180
+ * The packObjects command returns an object with two properties:
181
+ */
182
+ export type PackObjectsResult = {
183
+ /**
184
+ * - The suggested filename for the packfile if you want to save it to disk somewhere. It includes the packfile SHA.
185
+ */
186
+ filename: string;
187
+ /**
188
+ * - The packfile contents. Not present if `write` parameter was true, in which case the packfile was written straight to disk.
189
+ */
190
+ packfile?: Uint8Array<ArrayBuffer> | undefined;
191
+ };
192
+ /**
193
+ * - The object returned has the following schema:
194
+ */
195
+ export type ReadBlobResult = {
196
+ oid: string;
197
+ blob: Uint8Array;
198
+ };
199
+ export type DeflatedObject = {
200
+ oid: string;
201
+ type: "deflated";
202
+ format: "deflated";
203
+ object: Uint8Array;
204
+ source?: string | undefined;
205
+ };
206
+ export type WrappedObject = {
207
+ oid: string;
208
+ type: "wrapped";
209
+ format: "wrapped";
210
+ object: Uint8Array;
211
+ source?: string | undefined;
212
+ };
213
+ export type RawObject = {
214
+ oid: string;
215
+ type: "blob" | "commit" | "tree" | "tag";
216
+ format: "content";
217
+ object: Uint8Array;
218
+ source?: string | undefined;
219
+ };
220
+ export type ParsedBlobObject = {
221
+ oid: string;
222
+ type: "blob";
223
+ format: "parsed";
224
+ object: string;
225
+ source?: string | undefined;
226
+ };
227
+ export type ParsedCommitObject = {
228
+ oid: string;
229
+ type: "commit";
230
+ format: "parsed";
231
+ object: CommitObject;
232
+ source?: string | undefined;
233
+ };
234
+ export type ParsedTreeObject = {
235
+ oid: string;
236
+ type: "tree";
237
+ format: "parsed";
238
+ object: TreeObject;
239
+ source?: string | undefined;
240
+ };
241
+ export type ParsedTagObject = {
242
+ oid: string;
243
+ type: "tag";
244
+ format: "parsed";
245
+ object: TagObject;
246
+ source?: string | undefined;
247
+ };
248
+ export type ParsedObject = ParsedBlobObject | ParsedCommitObject | ParsedTreeObject | ParsedTagObject;
249
+ export type ReadObjectResult = DeflatedObject | WrappedObject | RawObject | ParsedObject;
250
+ /**
251
+ * - The object returned has the following schema:
252
+ */
253
+ export type ReadTagResult = {
254
+ /**
255
+ * - SHA-1 object id of this tag
256
+ */
257
+ oid: string;
258
+ /**
259
+ * - the parsed tag object
260
+ */
261
+ tag: TagObject;
262
+ /**
263
+ * - PGP signing payload
264
+ */
265
+ payload: string;
266
+ };
267
+ export type WalkerMap = (filename: string, entries: Array<WalkerEntry | null>) => Promise<any>;
268
+ export type WalkerReduce = (parent: any, children: any[]) => Promise<any>;
269
+ export type WalkerIterateCallback = (entries: WalkerEntry[]) => Promise<any[]>;
270
+ export type WalkerIterate = (walk: WalkerIterateCallback, children: IterableIterator<WalkerEntry[]>) => Promise<any[]>;
271
+ export type GitProgressEvent = {
272
+ phase: string;
273
+ loaded: number;
274
+ total: number;
275
+ };
276
+ export type ProgressCallback = (progress: GitProgressEvent) => void | Promise<void>;
277
+ export type GitHttpRequest = {
278
+ /**
279
+ * - The URL to request
280
+ */
281
+ url: string;
282
+ /**
283
+ * - The HTTP method to use
284
+ */
285
+ method?: string | undefined;
286
+ /**
287
+ * - Headers to include in the HTTP request
288
+ */
289
+ headers?: {
290
+ [x: string]: string;
291
+ } | undefined;
292
+ /**
293
+ * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
294
+ */
295
+ agent?: any;
296
+ /**
297
+ * - An async iterator of Uint8Arrays that make up the body of POST requests
298
+ */
299
+ body?: AsyncIterableIterator<Uint8Array>;
300
+ /**
301
+ * - Reserved for future use (emitting `GitProgressEvent`s)
302
+ */
303
+ onProgress?: ProgressCallback | undefined;
304
+ /**
305
+ * - Reserved for future use (canceling a request)
306
+ */
307
+ signal?: object;
308
+ };
309
+ export type GitHttpResponse = {
310
+ /**
311
+ * - The final URL that was fetched after any redirects
312
+ */
313
+ url: string;
314
+ /**
315
+ * - The HTTP method that was used
316
+ */
317
+ method?: string | undefined;
318
+ /**
319
+ * - HTTP response headers
320
+ */
321
+ headers?: {
322
+ [x: string]: string;
323
+ } | undefined;
324
+ /**
325
+ * - An async iterator of Uint8Arrays that make up the body of the response
326
+ */
327
+ body?: AsyncIterableIterator<Uint8Array>;
328
+ /**
329
+ * - The HTTP status code
330
+ */
331
+ statusCode: number;
332
+ /**
333
+ * - The HTTP status message
334
+ */
335
+ statusMessage: string;
336
+ };
337
+ export type HttpFetch = (request: GitHttpRequest) => Promise<GitHttpResponse>;
338
+ export type HttpClient = {
339
+ request: HttpFetch;
340
+ };
341
+ /**
342
+ * A git commit object.
343
+ */
344
+ export type CommitObject = {
345
+ /**
346
+ * Commit message
347
+ */
348
+ message: string;
349
+ /**
350
+ * SHA-1 object id of corresponding file tree
351
+ */
352
+ tree: string;
353
+ /**
354
+ * an array of zero or more SHA-1 object ids
355
+ */
356
+ parent: string[];
357
+ author: {
358
+ name: string;
359
+ email: string;
360
+ timestamp: number;
361
+ timezoneOffset: number;
362
+ };
363
+ committer: {
364
+ name: string;
365
+ email: string;
366
+ timestamp: number;
367
+ timezoneOffset: number;
368
+ };
369
+ /**
370
+ * PGP signature (if present)
371
+ */
372
+ gpgsig?: string | undefined;
373
+ };
374
+ /**
375
+ * A git tree object. Trees represent a directory snapshot.
376
+ */
377
+ export type TreeObject = TreeEntry[];
378
+ /**
379
+ * A git annotated tag object.
380
+ */
381
+ export type TagObject = {
382
+ /**
383
+ * SHA-1 object id of object being tagged
384
+ */
385
+ object: string;
386
+ /**
387
+ * the type of the object being tagged
388
+ */
389
+ type: "blob" | "tree" | "commit" | "tag";
390
+ /**
391
+ * the tag name
392
+ */
393
+ tag: string;
394
+ tagger: {
395
+ name: string;
396
+ email: string;
397
+ timestamp: number;
398
+ timezoneOffset: number;
399
+ };
400
+ /**
401
+ * tag message
402
+ */
403
+ message: string;
404
+ /**
405
+ * PGP signature (if present)
406
+ */
407
+ gpgsig?: string | undefined;
408
+ };
409
+ export type ReadCommitResult = {
410
+ /**
411
+ * - SHA-1 object id of this commit
412
+ */
413
+ oid: string;
414
+ /**
415
+ * - the parsed commit object
416
+ */
417
+ commit: CommitObject;
418
+ /**
419
+ * - PGP signing payload
420
+ */
421
+ payload: string;
422
+ };
423
+ export type Walker = {
424
+ /**
425
+ * ('GitWalkerSymbol')
426
+ */
427
+ Symbol: Symbol;
428
+ };
429
+ /**
430
+ * Normalized subset of filesystem `stat` data:
431
+ */
432
+ export type Stat = {
433
+ ctimeSeconds: number;
434
+ ctimeNanoseconds: number;
435
+ mtimeSeconds: number;
436
+ mtimeNanoseconds: number;
437
+ dev: number;
438
+ ino: number;
439
+ mode: number;
440
+ uid: number;
441
+ gid: number;
442
+ size: number;
443
+ };
444
+ /**
445
+ * The `WalkerEntry` is an interface that abstracts computing many common tree / blob stats.
446
+ */
447
+ export type WalkerEntry = {
448
+ type: () => Promise<"tree" | "blob" | "special" | "commit">;
449
+ mode: () => Promise<number>;
450
+ oid: () => Promise<string>;
451
+ content: () => Promise<Uint8Array | void>;
452
+ stat: () => Promise<Stat>;
453
+ };
454
+ export type CallbackFsClient = {
455
+ /**
456
+ * - https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback
457
+ */
458
+ readFile: Function;
459
+ /**
460
+ * - https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback
461
+ */
462
+ writeFile: Function;
463
+ /**
464
+ * - https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback
465
+ */
466
+ unlink: Function;
467
+ /**
468
+ * - https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback
469
+ */
470
+ readdir: Function;
471
+ /**
472
+ * - https://nodejs.org/api/fs.html#fs_fs_mkdir_path_mode_callback
473
+ */
474
+ mkdir: Function;
475
+ /**
476
+ * - https://nodejs.org/api/fs.html#fs_fs_rmdir_path_callback
477
+ */
478
+ rmdir: Function;
479
+ /**
480
+ * - https://nodejs.org/api/fs.html#fs_fs_stat_path_options_callback
481
+ */
482
+ stat: Function;
483
+ /**
484
+ * - https://nodejs.org/api/fs.html#fs_fs_lstat_path_options_callback
485
+ */
486
+ lstat: Function;
487
+ /**
488
+ * - https://nodejs.org/api/fs.html#fs_fs_readlink_path_options_callback
489
+ */
490
+ readlink?: Function | undefined;
491
+ /**
492
+ * - https://nodejs.org/api/fs.html#fs_fs_symlink_target_path_type_callback
493
+ */
494
+ symlink?: Function | undefined;
495
+ /**
496
+ * - https://nodejs.org/api/fs.html#fs_fs_chmod_path_mode_callback
497
+ */
498
+ chmod?: Function | undefined;
499
+ };
500
+ export type PromiseFsClient = {
501
+ promises: {
502
+ readFile: Function;
503
+ writeFile: Function;
504
+ unlink: Function;
505
+ readdir: Function;
506
+ mkdir: Function;
507
+ rmdir: Function;
508
+ stat: Function;
509
+ lstat: Function;
510
+ readlink?: Function | undefined;
511
+ symlink?: Function | undefined;
512
+ chmod?: Function | undefined;
513
+ };
514
+ };
515
+ export type FsClient = CallbackFsClient | PromiseFsClient;
516
+ export type MessageCallback = (message: string) => void | Promise<void>;
517
+ export type GitAuth = {
518
+ username?: string | undefined;
519
+ password?: string | undefined;
520
+ headers?: {
521
+ [x: string]: string;
522
+ } | undefined;
523
+ /**
524
+ * Tells git to throw a `UserCanceledError` (instead of an `HttpError`).
525
+ */
526
+ cancel?: boolean | undefined;
527
+ };
528
+ export type AuthCallback = (url: string, auth: GitAuth) => GitAuth | void | Promise<GitAuth | void>;
529
+ export type AuthFailureCallback = (url: string, auth: GitAuth) => GitAuth | void | Promise<GitAuth | void>;
530
+ export type AuthSuccessCallback = (url: string, auth: GitAuth) => void | Promise<void>;
531
+ export type SignParams = {
532
+ /**
533
+ * - a plaintext message
534
+ */
535
+ payload: string;
536
+ /**
537
+ * - an 'ASCII armor' encoded PGP key (technically can actually contain _multiple_ keys)
538
+ */
539
+ secretKey: string;
540
+ };
541
+ export type SignCallback = (args: SignParams) => {
542
+ signature: string;
543
+ } | Promise<{
544
+ signature: string;
545
+ }>;
546
+ export type MergeDriverParams = {
547
+ branches: Array<string>;
548
+ contents: Array<string>;
549
+ path: string;
550
+ };
551
+ export type MergeDriverCallback = (args: MergeDriverParams) => {
552
+ cleanMerge: boolean;
553
+ mergedText: string;
554
+ } | Promise<{
555
+ cleanMerge: boolean;
556
+ mergedText: string;
557
+ }>;
558
+ export type RefUpdateStatus = {
559
+ ok: boolean;
560
+ error: string;
561
+ };
562
+ export type PushResult = {
563
+ ok: boolean;
564
+ error: string | null;
565
+ refs: {
566
+ [x: string]: RefUpdateStatus;
567
+ };
568
+ headers?: {
569
+ [x: string]: string;
570
+ } | undefined;
571
+ };
572
+ export type HeadStatus = 0 | 1;
573
+ export type WorkdirStatus = 0 | 1 | 2;
574
+ export type StageStatus = 0 | 1 | 2 | 3;
575
+ export type StatusRow = [string, HeadStatus, WorkdirStatus, StageStatus];
576
+ /**
577
+ * the type of stash ops
578
+ */
579
+ export type StashOp = "push" | "pop" | "apply" | "drop" | "list" | "clear";
580
+ /**
581
+ * - when compare WORDIR to HEAD, 'remove' could mean 'untracked'
582
+ */
583
+ export type StashChangeType = "equal" | "modify" | "add" | "remove" | "unknown";
584
+ export type ClientRef = {
585
+ /**
586
+ * The name of the ref
587
+ */
588
+ ref: string;
589
+ /**
590
+ * The SHA-1 object id the ref points to
591
+ */
592
+ oid: string;
593
+ };
594
+ export type PrePushParams = {
595
+ /**
596
+ * The expanded name of target remote
597
+ */
598
+ remote: string;
599
+ /**
600
+ * The URL address of target remote
601
+ */
602
+ url: string;
603
+ /**
604
+ * The ref which the client wants to push to the remote
605
+ */
606
+ localRef: ClientRef;
607
+ /**
608
+ * The ref which is known by the remote
609
+ */
610
+ remoteRef: ClientRef;
611
+ };
612
+ export type PrePushCallback = (args: PrePushParams) => boolean | Promise<boolean>;
613
+ export type PostCheckoutParams = {
614
+ /**
615
+ * The SHA-1 object id of HEAD before checkout
616
+ */
617
+ previousHead: string;
618
+ /**
619
+ * The SHA-1 object id of HEAD after checkout
620
+ */
621
+ newHead: string;
622
+ /**
623
+ * flag determining whether a branch or a set of files was checked
624
+ */
625
+ type: "branch" | "file";
626
+ };
627
+ export type PostCheckoutCallback = (args: PostCheckoutParams) => void | Promise<void>;
628
+ export var Errors: Readonly<{
629
+ __proto__: null;
630
+ AlreadyExistsError: typeof AlreadyExistsError;
631
+ AmbiguousError: typeof AmbiguousError;
632
+ CheckoutConflictError: typeof CheckoutConflictError;
633
+ CommitNotFetchedError: typeof CommitNotFetchedError;
634
+ EmptyServerResponseError: typeof EmptyServerResponseError;
635
+ FastForwardError: typeof FastForwardError;
636
+ GitPushError: typeof GitPushError;
637
+ HttpError: typeof HttpError;
638
+ InternalError: typeof InternalError;
639
+ InvalidFilepathError: typeof InvalidFilepathError;
640
+ InvalidOidError: typeof InvalidOidError;
641
+ InvalidRefNameError: typeof InvalidRefNameError;
642
+ MaxDepthError: typeof MaxDepthError;
643
+ MergeNotSupportedError: typeof MergeNotSupportedError;
644
+ MergeConflictError: typeof MergeConflictError;
645
+ MissingNameError: typeof MissingNameError;
646
+ MissingParameterError: typeof MissingParameterError;
647
+ MultipleGitError: typeof MultipleGitError;
648
+ NoRefspecError: typeof NoRefspecError;
649
+ NotFoundError: typeof NotFoundError;
650
+ ObjectTypeError: typeof ObjectTypeError;
651
+ ParseError: typeof ParseError;
652
+ PushRejectedError: typeof PushRejectedError;
653
+ RemoteCapabilityError: typeof RemoteCapabilityError;
654
+ SmartHttpError: typeof SmartHttpError;
655
+ UnknownTransportError: typeof UnknownTransportError;
656
+ UnsafeFilepathError: typeof UnsafeFilepathError;
657
+ UrlParseError: typeof UrlParseError;
658
+ UserCanceledError: typeof UserCanceledError;
659
+ UnmergedPathsError: typeof UnmergedPathsError;
660
+ IndexResetError: typeof IndexResetError;
661
+ NoCommitError: typeof NoCommitError;
662
+ }>;
663
+ /**
664
+ * @returns {Walker}
665
+ */
666
+ export function STAGE(): Walker;
667
+ /**
668
+ * @param {object} args
669
+ * @param {string} [args.ref='HEAD']
670
+ * @returns {Walker}
671
+ */
672
+ export function TREE({ ref }?: {
673
+ ref?: string | undefined;
674
+ }): Walker;
675
+ /**
676
+ * @returns {Walker}
677
+ */
678
+ export function WORKDIR(): Walker;
679
+ /**
680
+ * Abort a merge in progress.
681
+ *
682
+ * Based on the behavior of git reset --merge, i.e. "Resets the index and updates the files in the working tree that are different between <commit> and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between <commit> and the index has unstaged changes, reset is aborted."
683
+ *
684
+ * Essentially, abortMerge will reset any files affected by merge conflicts to their last known good version at HEAD.
685
+ * Any unstaged changes are saved and any staged changes are reset as well.
686
+ *
687
+ * NOTE: The behavior of this command differs slightly from canonical git in that an error will be thrown if a file exists in the index and nowhere else.
688
+ * Canonical git will reset the file and continue aborting the merge in this case.
689
+ *
690
+ * **WARNING:** Running git merge with non-trivial uncommitted changes is discouraged: while possible, it may leave you in a state that is hard to back out of in the case of a conflict.
691
+ * If there were uncommitted changes when the merge started (and especially if those changes were further modified after the merge was started), `git.abortMerge` will in some cases be unable to reconstruct the original (pre-merge) changes.
692
+ *
693
+ * @param {object} args
694
+ * @param {FsClient} args.fs - a file system implementation
695
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
696
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
697
+ * @param {string} [args.commit='HEAD'] - commit to reset the index and worktree to, defaults to HEAD
698
+ * @param {object} [args.cache] - a [cache](cache.md) object
699
+ *
700
+ * @returns {Promise<void>} Resolves successfully once the git index has been updated
701
+ *
702
+ */
703
+ export function abortMerge({ fs: _fs, dir, gitdir, commit, cache, }: {
704
+ fs: FsClient;
705
+ dir: string;
706
+ gitdir?: string | undefined;
707
+ commit?: string | undefined;
708
+ cache?: object;
709
+ }): Promise<void>;
710
+ /**
711
+ * Add a file to the git index (aka staging area)
712
+ *
713
+ * @param {object} args
714
+ * @param {FsClient} args.fs - a file system implementation
715
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
716
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
717
+ * @param {string|string[]} args.filepath - The path to the file to add to the index
718
+ * @param {object} [args.cache] - a [cache](cache.md) object
719
+ * @param {boolean} [args.force=false] - add to index even if matches gitignore. Think `git add --force`
720
+ * @param {boolean} [args.parallel=false] - process each input file in parallel. Parallel processing will result in more memory consumption but less process time
721
+ *
722
+ * @returns {Promise<void>} Resolves successfully once the git index has been updated
723
+ *
724
+ * @example
725
+ * await fs.promises.writeFile('/tutorial/README.md', `# TEST`)
726
+ * await git.add({ fs, dir: '/tutorial', filepath: 'README.md' })
727
+ * console.log('done')
728
+ *
729
+ */
730
+ export function add({ fs: _fs, dir, gitdir, filepath, cache, force, parallel, }: {
731
+ fs: FsClient;
732
+ dir: string;
733
+ gitdir?: string | undefined;
734
+ filepath: string | string[];
735
+ cache?: object;
736
+ force?: boolean | undefined;
737
+ parallel?: boolean | undefined;
738
+ }): Promise<void>;
739
+ /**
740
+ * Add or update an object note
741
+ *
742
+ * @param {object} args
743
+ * @param {FsClient} args.fs - a file system implementation
744
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
745
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
746
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
747
+ * @param {string} [args.ref] - The notes ref to look under
748
+ * @param {string} args.oid - The SHA-1 object id of the object to add the note to.
749
+ * @param {string|Uint8Array} args.note - The note to add
750
+ * @param {boolean} [args.force] - Over-write note if it already exists.
751
+ * @param {Object} [args.author] - The details about the author.
752
+ * @param {string} [args.author.name] - Default is `user.name` config.
753
+ * @param {string} [args.author.email] - Default is `user.email` config.
754
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
755
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
756
+ * @param {Object} [args.committer = author] - The details about the note committer, in the same format as the author parameter. If not specified, the author details are used.
757
+ * @param {string} [args.committer.name] - Default is `user.name` config.
758
+ * @param {string} [args.committer.email] - Default is `user.email` config.
759
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
760
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
761
+ * @param {string} [args.signingKey] - Sign the note commit using this private PGP key.
762
+ * @param {object} [args.cache] - a [cache](cache.md) object
763
+ *
764
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the commit object for the added note.
765
+ */
766
+ export function addNote({ fs: _fs, onSign, dir, gitdir, ref, oid, note, force, author: _author, committer: _committer, signingKey, cache, }: {
767
+ fs: FsClient;
768
+ onSign?: SignCallback | undefined;
769
+ dir?: string | undefined;
770
+ gitdir?: string | undefined;
771
+ ref?: string | undefined;
772
+ oid: string;
773
+ note: string | Uint8Array;
774
+ force?: boolean | undefined;
775
+ author?: {
776
+ name?: string | undefined;
777
+ email?: string | undefined;
778
+ timestamp?: number | undefined;
779
+ timezoneOffset?: number | undefined;
780
+ } | undefined;
781
+ committer?: {
782
+ name?: string | undefined;
783
+ email?: string | undefined;
784
+ timestamp?: number | undefined;
785
+ timezoneOffset?: number | undefined;
786
+ } | undefined;
787
+ signingKey?: string | undefined;
788
+ cache?: object;
789
+ }): Promise<string>;
790
+ /**
791
+ * Add or update a remote
792
+ *
793
+ * @param {object} args
794
+ * @param {FsClient} args.fs - a file system implementation
795
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
796
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
797
+ * @param {string} args.remote - The name of the remote
798
+ * @param {string} args.url - The URL of the remote
799
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a remote named `remote` already exists, overwrite the existing remote.
800
+ *
801
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
802
+ *
803
+ * @example
804
+ * await git.addRemote({
805
+ * fs,
806
+ * dir: '/tutorial',
807
+ * remote: 'upstream',
808
+ * url: 'https://github.com/isomorphic-git/isomorphic-git'
809
+ * })
810
+ * console.log('done')
811
+ *
812
+ */
813
+ export function addRemote({ fs, dir, gitdir, remote, url, force, }: {
814
+ fs: FsClient;
815
+ dir?: string | undefined;
816
+ gitdir?: string | undefined;
817
+ remote: string;
818
+ url: string;
819
+ force?: boolean | undefined;
820
+ }): Promise<void>;
821
+ /**
822
+ * Create an annotated tag.
823
+ *
824
+ * @param {object} args
825
+ * @param {FsClient} args.fs - a file system implementation
826
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
827
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
828
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
829
+ * @param {string} args.ref - What to name the tag
830
+ * @param {string} [args.message = ref] - The tag message to use.
831
+ * @param {string} [args.object = 'HEAD'] - The SHA-1 object id the tag points to. (Will resolve to a SHA-1 object id if value is a ref.) By default, the commit object which is referred by the current `HEAD` is used.
832
+ * @param {object} [args.tagger] - The details about the tagger.
833
+ * @param {string} [args.tagger.name] - Default is `user.name` config.
834
+ * @param {string} [args.tagger.email] - Default is `user.email` config.
835
+ * @param {number} [args.tagger.timestamp=Math.floor(Date.now()/1000)] - Set the tagger timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
836
+ * @param {number} [args.tagger.timezoneOffset] - Set the tagger timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
837
+ * @param {string} [args.gpgsig] - The gpgsig attached to the tag object. (Mutually exclusive with the `signingKey` option.)
838
+ * @param {string} [args.signingKey] - Sign the tag object using this private PGP key. (Mutually exclusive with the `gpgsig` option.)
839
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag. Note that this option does not modify the original tag object itself.
840
+ * @param {object} [args.cache] - a [cache](cache.md) object
841
+ *
842
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
843
+ *
844
+ * @example
845
+ * await git.annotatedTag({
846
+ * fs,
847
+ * dir: '/tutorial',
848
+ * ref: 'test-tag',
849
+ * message: 'This commit is awesome',
850
+ * tagger: {
851
+ * name: 'Mr. Test',
852
+ * email: 'mrtest@example.com'
853
+ * }
854
+ * })
855
+ * console.log('done')
856
+ *
857
+ */
858
+ export function annotatedTag({ fs: _fs, onSign, dir, gitdir, ref, tagger: _tagger, message, gpgsig, object, signingKey, force, cache, }: {
859
+ fs: FsClient;
860
+ onSign?: SignCallback | undefined;
861
+ dir?: string | undefined;
862
+ gitdir?: string | undefined;
863
+ ref: string;
864
+ message?: string | undefined;
865
+ object?: string | undefined;
866
+ tagger?: {
867
+ name?: string | undefined;
868
+ email?: string | undefined;
869
+ timestamp?: number | undefined;
870
+ timezoneOffset?: number | undefined;
871
+ } | undefined;
872
+ gpgsig?: string | undefined;
873
+ signingKey?: string | undefined;
874
+ force?: boolean | undefined;
875
+ cache?: object;
876
+ }): Promise<void>;
877
+ /**
878
+ * Create a branch
879
+ *
880
+ * @param {object} args
881
+ * @param {FsClient} args.fs - a file system implementation
882
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
883
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
884
+ * @param {string} args.ref - What to name the branch
885
+ * @param {string} [args.object = 'HEAD'] - What oid to use as the start point. Accepts a symbolic ref.
886
+ * @param {boolean} [args.checkout = false] - Update `HEAD` to point at the newly created branch
887
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a branched named `ref` already exists, overwrite the existing branch.
888
+ *
889
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
890
+ *
891
+ * @example
892
+ * await git.branch({ fs, dir: '/tutorial', ref: 'develop' })
893
+ * console.log('done')
894
+ *
895
+ */
896
+ export function branch({ fs, dir, gitdir, ref, object, checkout, force, }: {
897
+ fs: FsClient;
898
+ dir?: string | undefined;
899
+ gitdir?: string | undefined;
900
+ ref: string;
901
+ object?: string | undefined;
902
+ checkout?: boolean | undefined;
903
+ force?: boolean | undefined;
904
+ }): Promise<void>;
905
+ /**
906
+ * Checkout a branch
907
+ *
908
+ * If the branch already exists it will check out that branch. Otherwise, it will create a new remote tracking branch set to track the remote branch of that name.
909
+ *
910
+ * @param {object} args
911
+ * @param {FsClient} args.fs - a file system implementation
912
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
913
+ * @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback
914
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
915
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
916
+ * @param {string} [args.ref = 'HEAD'] - Source to checkout files from
917
+ * @param {string[]} [args.filepaths] - Limit the checkout to the given files and directories
918
+ * @param {string} [args.remote = 'origin'] - Which remote repository to use
919
+ * @param {boolean} [args.noCheckout = false] - If true, will update HEAD but won't update the working directory
920
+ * @param {boolean} [args.noUpdateHead] - If true, will update the working directory but won't update HEAD. Defaults to `false` when `ref` is provided, and `true` if `ref` is not provided.
921
+ * @param {boolean} [args.dryRun = false] - If true, simulates a checkout so you can test whether it would succeed.
922
+ * @param {boolean} [args.force = false] - If true, conflicts will be ignored and files will be overwritten regardless of local changes.
923
+ * @param {boolean} [args.track = true] - If false, will not set the remote branch tracking information. Defaults to true.
924
+ * @param {object} [args.cache] - a [cache](cache.md) object
925
+ * @param {boolean} [args.nonBlocking = false] - If true, will use non-blocking file system operations to allow for better performance in certain environments (For example, in Browsers)
926
+ * @param {number} [args.batchSize = 100] - If args.nonBlocking is true, batchSize is the number of files to process at a time avoid blocking the executing thread. The default value of 100 is a good starting point.
927
+ *
928
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
929
+ *
930
+ * @example
931
+ * // switch to the main branch
932
+ * await git.checkout({
933
+ * fs,
934
+ * dir: '/tutorial',
935
+ * ref: 'main'
936
+ * })
937
+ * console.log('done')
938
+ *
939
+ * @example
940
+ * // restore the 'docs' and 'src/docs' folders to the way they were, overwriting any changes
941
+ * await git.checkout({
942
+ * fs,
943
+ * dir: '/tutorial',
944
+ * force: true,
945
+ * filepaths: ['docs', 'src/docs']
946
+ * })
947
+ * console.log('done')
948
+ *
949
+ * @example
950
+ * // restore the 'docs' and 'src/docs' folders to the way they are in the 'develop' branch, overwriting any changes
951
+ * await git.checkout({
952
+ * fs,
953
+ * dir: '/tutorial',
954
+ * ref: 'develop',
955
+ * noUpdateHead: true,
956
+ * force: true,
957
+ * filepaths: ['docs', 'src/docs']
958
+ * })
959
+ * console.log('done')
960
+ */
961
+ export function checkout({ fs, onProgress, onPostCheckout, dir, gitdir, remote, ref: _ref, filepaths, noCheckout, noUpdateHead, dryRun, force, track, cache, nonBlocking, batchSize, }: {
962
+ fs: FsClient;
963
+ onProgress?: ProgressCallback | undefined;
964
+ onPostCheckout?: PostCheckoutCallback | undefined;
965
+ dir: string;
966
+ gitdir?: string | undefined;
967
+ ref?: string | undefined;
968
+ filepaths?: string[] | undefined;
969
+ remote?: string | undefined;
970
+ noCheckout?: boolean | undefined;
971
+ noUpdateHead?: boolean | undefined;
972
+ dryRun?: boolean | undefined;
973
+ force?: boolean | undefined;
974
+ track?: boolean | undefined;
975
+ cache?: object;
976
+ nonBlocking?: boolean | undefined;
977
+ batchSize?: number | undefined;
978
+ }): Promise<void>;
979
+ /**
980
+ * Clone a repository
981
+ *
982
+ * @param {object} args
983
+ * @param {FsClient} args.fs - a file system implementation
984
+ * @param {HttpClient} args.http - an HTTP client
985
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
986
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
987
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
988
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
989
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
990
+ * @param {PostCheckoutCallback} [args.onPostCheckout] - optional post-checkout hook callback
991
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
992
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
993
+ * @param {string} args.url - The URL of the remote repository
994
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Value is stored in the git config file for that repo.
995
+ * @param {string} [args.ref] - Which branch to checkout. By default this is the designated "main branch" of the repository.
996
+ * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
997
+ * @param {boolean} [args.noCheckout = false] - If true, clone will only fetch the repo, not check out a branch. Skipping checkout can save a lot of time normally spent writing files to disk.
998
+ * @param {boolean} [args.noTags = false] - By default clone will fetch all tags. `noTags` disables that behavior.
999
+ * @param {string} [args.remote = 'origin'] - What to name the remote that is created.
1000
+ * @param {number} [args.depth] - Integer. Determines how much of the git repository's history to retrieve
1001
+ * @param {Date} [args.since] - Only fetch commits created after the given date. Mutually exclusive with `depth`.
1002
+ * @param {string[]} [args.exclude = []] - A list of branches or tags. Instructs the remote server not to send us any commits reachable from these refs.
1003
+ * @param {boolean} [args.relative = false] - Changes the meaning of `depth` to be measured from the current shallow depth rather than from the branch tip.
1004
+ * @param {Object<string, string>} [args.headers = {}] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1005
+ * @param {object} [args.cache] - a [cache](cache.md) object
1006
+ * @param {boolean} [args.nonBlocking = false] - if true, checkout will happen non-blockingly (useful for long-running operations blocking the thread in browser environments)
1007
+ * @param {number} [args.batchSize = 100] - If args.nonBlocking is true, batchSize is the number of files to process at a time avoid blocking the executing thread. The default value of 100 is a good starting point.
1008
+ *
1009
+ * @returns {Promise<void>} Resolves successfully when clone completes
1010
+ *
1011
+ * @example
1012
+ * await git.clone({
1013
+ * fs,
1014
+ * http,
1015
+ * dir: '/tutorial',
1016
+ * corsProxy: 'https://cors.isomorphic-git.org',
1017
+ * url: 'https://github.com/isomorphic-git/isomorphic-git',
1018
+ * singleBranch: true,
1019
+ * depth: 1
1020
+ * })
1021
+ * console.log('done')
1022
+ *
1023
+ */
1024
+ export function clone({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, onPostCheckout, dir, gitdir, url, corsProxy, ref, remote, depth, since, exclude, relative, singleBranch, noCheckout, noTags, headers, cache, nonBlocking, batchSize, }: {
1025
+ fs: FsClient;
1026
+ http: HttpClient;
1027
+ onProgress?: ProgressCallback | undefined;
1028
+ onMessage?: MessageCallback | undefined;
1029
+ onAuth?: AuthCallback | undefined;
1030
+ onAuthFailure?: AuthFailureCallback | undefined;
1031
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1032
+ onPostCheckout?: PostCheckoutCallback | undefined;
1033
+ dir: string;
1034
+ gitdir?: string | undefined;
1035
+ url: string;
1036
+ corsProxy?: string | undefined;
1037
+ ref?: string | undefined;
1038
+ singleBranch?: boolean | undefined;
1039
+ noCheckout?: boolean | undefined;
1040
+ noTags?: boolean | undefined;
1041
+ remote?: string | undefined;
1042
+ depth?: number | undefined;
1043
+ since?: Date | undefined;
1044
+ exclude?: string[] | undefined;
1045
+ relative?: boolean | undefined;
1046
+ headers?: {
1047
+ [x: string]: string;
1048
+ } | undefined;
1049
+ cache?: object;
1050
+ nonBlocking?: boolean | undefined;
1051
+ batchSize?: number | undefined;
1052
+ }): Promise<void>;
1053
+ /**
1054
+ * Create a new commit
1055
+ *
1056
+ * @param {Object} args
1057
+ * @param {FsClient} args.fs - a file system implementation
1058
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
1059
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1060
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1061
+ * @param {string} [args.message] - The commit message to use. Required, unless `amend === true`
1062
+ * @param {Object} [args.author] - The details about the author.
1063
+ * @param {string} [args.author.name] - Default is `user.name` config.
1064
+ * @param {string} [args.author.email] - Default is `user.email` config.
1065
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
1066
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
1067
+ * @param {Object} [args.committer = author] - The details about the commit committer, in the same format as the author parameter. If not specified, the author details are used.
1068
+ * @param {string} [args.committer.name] - Default is `user.name` config.
1069
+ * @param {string} [args.committer.email] - Default is `user.email` config.
1070
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
1071
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
1072
+ * @param {string} [args.signingKey] - Sign the tag object using this private PGP key.
1073
+ * @param {boolean} [args.amend = false] - If true, replaces the last commit pointed to by `ref` with a new commit.
1074
+ * @param {boolean} [args.dryRun = false] - If true, simulates making a commit so you can test whether it would succeed. Implies `noUpdateBranch`.
1075
+ * @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.
1076
+ * @param {string} [args.ref] - The fully expanded name of the branch to commit to. Default is the current branch pointed to by HEAD. (TODO: fix it so it can expand branch names without throwing if the branch doesn't exist yet.)
1077
+ * @param {string[]} [args.parent] - The SHA-1 object ids of the commits to use as parents. If not specified, the commit pointed to by `ref` is used.
1078
+ * @param {string} [args.tree] - The SHA-1 object id of the tree to use. If not specified, a new tree object is created from the current git index.
1079
+ * @param {object} [args.cache] - a [cache](cache.md) object
1080
+ *
1081
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly created commit.
1082
+ *
1083
+ * @example
1084
+ * let sha = await git.commit({
1085
+ * fs,
1086
+ * dir: '/tutorial',
1087
+ * author: {
1088
+ * name: 'Mr. Test',
1089
+ * email: 'mrtest@example.com',
1090
+ * },
1091
+ * message: 'Added the a.txt file'
1092
+ * })
1093
+ * console.log(sha)
1094
+ *
1095
+ */
1096
+ export function commit({ fs: _fs, onSign, dir, gitdir, message, author, committer, signingKey, amend, dryRun, noUpdateBranch, ref, parent, tree, cache, }: {
1097
+ fs: FsClient;
1098
+ onSign?: SignCallback | undefined;
1099
+ dir?: string | undefined;
1100
+ gitdir?: string | undefined;
1101
+ message?: string | undefined;
1102
+ author?: {
1103
+ name?: string | undefined;
1104
+ email?: string | undefined;
1105
+ timestamp?: number | undefined;
1106
+ timezoneOffset?: number | undefined;
1107
+ } | undefined;
1108
+ committer?: {
1109
+ name?: string | undefined;
1110
+ email?: string | undefined;
1111
+ timestamp?: number | undefined;
1112
+ timezoneOffset?: number | undefined;
1113
+ } | undefined;
1114
+ signingKey?: string | undefined;
1115
+ amend?: boolean | undefined;
1116
+ dryRun?: boolean | undefined;
1117
+ noUpdateBranch?: boolean | undefined;
1118
+ ref?: string | undefined;
1119
+ parent?: string[] | undefined;
1120
+ tree?: string | undefined;
1121
+ cache?: object;
1122
+ }): Promise<string>;
1123
+ /**
1124
+ * Get the name of the branch currently pointed to by .git/HEAD
1125
+ *
1126
+ * @param {Object} args
1127
+ * @param {FsClient} args.fs - a file system implementation
1128
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1129
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1130
+ * @param {boolean} [args.fullname = false] - Return the full path (e.g. "refs/heads/main") instead of the abbreviated form.
1131
+ * @param {boolean} [args.test = false] - If the current branch doesn't actually exist (such as right after git init) then return `undefined`.
1132
+ *
1133
+ * @returns {Promise<string|void>} The name of the current branch or undefined if the HEAD is detached.
1134
+ *
1135
+ * @example
1136
+ * // Get the current branch name
1137
+ * let branch = await git.currentBranch({
1138
+ * fs,
1139
+ * dir: '/tutorial',
1140
+ * fullname: false
1141
+ * })
1142
+ * console.log(branch)
1143
+ *
1144
+ */
1145
+ export function currentBranch({ fs, dir, gitdir, fullname, test, }: {
1146
+ fs: FsClient;
1147
+ dir?: string | undefined;
1148
+ gitdir?: string | undefined;
1149
+ fullname?: boolean | undefined;
1150
+ test?: boolean | undefined;
1151
+ }): Promise<string | void>;
1152
+ declare namespace index {
1153
+ export { Errors };
1154
+ export { STAGE };
1155
+ export { TREE };
1156
+ export { WORKDIR };
1157
+ export { add };
1158
+ export { abortMerge };
1159
+ export { addNote };
1160
+ export { addRemote };
1161
+ export { annotatedTag };
1162
+ export { branch };
1163
+ export { checkout };
1164
+ export { clone };
1165
+ export { commit };
1166
+ export { getConfig };
1167
+ export { getConfigAll };
1168
+ export { setConfig };
1169
+ export { currentBranch };
1170
+ export { deleteBranch };
1171
+ export { deleteRef };
1172
+ export { deleteRemote };
1173
+ export { deleteTag };
1174
+ export { expandOid };
1175
+ export { expandRef };
1176
+ export { fastForward };
1177
+ export { fetch };
1178
+ export { findMergeBase };
1179
+ export { findRoot };
1180
+ export { getRemoteInfo };
1181
+ export { getRemoteInfo2 };
1182
+ export { hashBlob };
1183
+ export { indexPack };
1184
+ export { init };
1185
+ export { isDescendent };
1186
+ export { isIgnored };
1187
+ export { listBranches };
1188
+ export { listFiles };
1189
+ export { listNotes };
1190
+ export { listRefs };
1191
+ export { listRemotes };
1192
+ export { listServerRefs };
1193
+ export { listTags };
1194
+ export { log };
1195
+ export { merge };
1196
+ export { packObjects };
1197
+ export { pull };
1198
+ export { push };
1199
+ export { readBlob };
1200
+ export { readCommit };
1201
+ export { readNote };
1202
+ export { readObject };
1203
+ export { readTag };
1204
+ export { readTree };
1205
+ export { remove };
1206
+ export { removeNote };
1207
+ export { renameBranch };
1208
+ export { resetIndex };
1209
+ export { updateIndex$1 as updateIndex };
1210
+ export { resolveRef };
1211
+ export { status };
1212
+ export { statusMatrix };
1213
+ export { tag };
1214
+ export { version };
1215
+ export { walk };
1216
+ export { writeBlob };
1217
+ export { writeCommit };
1218
+ export { writeObject };
1219
+ export { writeRef };
1220
+ export { writeTag };
1221
+ export { writeTree };
1222
+ export { stash };
1223
+ }
1224
+ /**
1225
+ * Delete a local branch
1226
+ *
1227
+ * > Note: This only deletes loose branches - it should be fixed in the future to delete packed branches as well.
1228
+ *
1229
+ * @param {Object} args
1230
+ * @param {FsClient} args.fs - a file system implementation
1231
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1232
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1233
+ * @param {string} args.ref - The branch to delete
1234
+ *
1235
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1236
+ *
1237
+ * @example
1238
+ * await git.deleteBranch({ fs, dir: '/tutorial', ref: 'local-branch' })
1239
+ * console.log('done')
1240
+ *
1241
+ */
1242
+ export function deleteBranch({ fs, dir, gitdir, ref, }: {
1243
+ fs: FsClient;
1244
+ dir?: string | undefined;
1245
+ gitdir?: string | undefined;
1246
+ ref: string;
1247
+ }): Promise<void>;
1248
+ /**
1249
+ * Delete a local ref
1250
+ *
1251
+ * @param {Object} args
1252
+ * @param {FsClient} args.fs - a file system implementation
1253
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1254
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1255
+ * @param {string} args.ref - The ref to delete
1256
+ *
1257
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1258
+ *
1259
+ * @example
1260
+ * await git.deleteRef({ fs, dir: '/tutorial', ref: 'refs/tags/test-tag' })
1261
+ * console.log('done')
1262
+ *
1263
+ */
1264
+ export function deleteRef({ fs, dir, gitdir, ref }: {
1265
+ fs: FsClient;
1266
+ dir?: string | undefined;
1267
+ gitdir?: string | undefined;
1268
+ ref: string;
1269
+ }): Promise<void>;
1270
+ /**
1271
+ * Removes the local config entry for a given remote
1272
+ *
1273
+ * @param {Object} args
1274
+ * @param {FsClient} args.fs - a file system implementation
1275
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1276
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1277
+ * @param {string} args.remote - The name of the remote to delete
1278
+ *
1279
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1280
+ *
1281
+ * @example
1282
+ * await git.deleteRemote({ fs, dir: '/tutorial', remote: 'upstream' })
1283
+ * console.log('done')
1284
+ *
1285
+ */
1286
+ export function deleteRemote({ fs, dir, gitdir, remote, }: {
1287
+ fs: FsClient;
1288
+ dir?: string | undefined;
1289
+ gitdir?: string | undefined;
1290
+ remote: string;
1291
+ }): Promise<void>;
1292
+ /**
1293
+ * Delete a local tag ref
1294
+ *
1295
+ * @param {Object} args
1296
+ * @param {FsClient} args.fs - a file system implementation
1297
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1298
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1299
+ * @param {string} args.ref - The tag to delete
1300
+ *
1301
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1302
+ *
1303
+ * @example
1304
+ * await git.deleteTag({ fs, dir: '/tutorial', ref: 'test-tag' })
1305
+ * console.log('done')
1306
+ *
1307
+ */
1308
+ export function deleteTag({ fs, dir, gitdir, ref }: {
1309
+ fs: FsClient;
1310
+ dir?: string | undefined;
1311
+ gitdir?: string | undefined;
1312
+ ref: string;
1313
+ }): Promise<void>;
1314
+ /**
1315
+ * Expand and resolve a short oid into a full oid
1316
+ *
1317
+ * @param {Object} args
1318
+ * @param {FsClient} args.fs - a file system implementation
1319
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1320
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1321
+ * @param {string} args.oid - The shortened oid prefix to expand (like "0414d2a")
1322
+ * @param {object} [args.cache] - a [cache](cache.md) object
1323
+ *
1324
+ * @returns {Promise<string>} Resolves successfully with the full oid (like "0414d2a286d7bbc7a4a326a61c1f9f888a8ab87f")
1325
+ *
1326
+ * @example
1327
+ * let oid = await git.expandOid({ fs, dir: '/tutorial', oid: '0414d2a'})
1328
+ * console.log(oid)
1329
+ *
1330
+ */
1331
+ export function expandOid({ fs, dir, gitdir, oid, cache, }: {
1332
+ fs: FsClient;
1333
+ dir?: string | undefined;
1334
+ gitdir?: string | undefined;
1335
+ oid: string;
1336
+ cache?: object;
1337
+ }): Promise<string>;
1338
+ /**
1339
+ * Expand an abbreviated ref to its full name
1340
+ *
1341
+ * @param {Object} args
1342
+ * @param {FsClient} args.fs - a file system implementation
1343
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1344
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1345
+ * @param {string} args.ref - The ref to expand (like "v1.0.0")
1346
+ *
1347
+ * @returns {Promise<string>} Resolves successfully with a full ref name ("refs/tags/v1.0.0")
1348
+ *
1349
+ * @example
1350
+ * let fullRef = await git.expandRef({ fs, dir: '/tutorial', ref: 'main'})
1351
+ * console.log(fullRef)
1352
+ *
1353
+ */
1354
+ export function expandRef({ fs, dir, gitdir, ref }: {
1355
+ fs: FsClient;
1356
+ dir?: string | undefined;
1357
+ gitdir?: string | undefined;
1358
+ ref: string;
1359
+ }): Promise<string>;
1360
+ /**
1361
+ * Like `pull`, but hard-coded with `fastForward: true` so there is no need for an `author` parameter.
1362
+ *
1363
+ * @param {object} args
1364
+ * @param {FsClient} args.fs - a file system client
1365
+ * @param {HttpClient} args.http - an HTTP client
1366
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
1367
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
1368
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1369
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1370
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1371
+ * @param {string} args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1372
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1373
+ * @param {string} [args.ref] - Which branch to merge into. By default this is the currently checked out branch.
1374
+ * @param {string} [args.url] - (Added in 1.1.0) The URL of the remote repository. The default is the value set in the git config for that remote.
1375
+ * @param {string} [args.remote] - (Added in 1.1.0) If URL is not specified, determines which remote to use.
1376
+ * @param {string} [args.remoteRef] - (Added in 1.1.0) The name of the branch on the remote to fetch. By default this is the configured remote tracking branch.
1377
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
1378
+ * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
1379
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1380
+ * @param {object} [args.cache] - a [cache](cache.md) object
1381
+ *
1382
+ * @returns {Promise<void>} Resolves successfully when pull operation completes
1383
+ *
1384
+ * @example
1385
+ * await git.fastForward({
1386
+ * fs,
1387
+ * http,
1388
+ * dir: '/tutorial',
1389
+ * ref: 'main',
1390
+ * singleBranch: true
1391
+ * })
1392
+ * console.log('done')
1393
+ *
1394
+ */
1395
+ export function fastForward({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, dir, gitdir, ref, url, remote, remoteRef, corsProxy, singleBranch, headers, cache, }: {
1396
+ fs: FsClient;
1397
+ http: HttpClient;
1398
+ onProgress?: ProgressCallback | undefined;
1399
+ onMessage?: MessageCallback | undefined;
1400
+ onAuth?: AuthCallback | undefined;
1401
+ onAuthFailure?: AuthFailureCallback | undefined;
1402
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1403
+ dir: string;
1404
+ gitdir?: string | undefined;
1405
+ ref?: string | undefined;
1406
+ url?: string | undefined;
1407
+ remote?: string | undefined;
1408
+ remoteRef?: string | undefined;
1409
+ corsProxy?: string | undefined;
1410
+ singleBranch?: boolean | undefined;
1411
+ headers?: {
1412
+ [x: string]: string;
1413
+ } | undefined;
1414
+ cache?: object;
1415
+ }): Promise<void>;
1416
+ /**
1417
+ *
1418
+ * @typedef {object} FetchResult - The object returned has the following schema:
1419
+ * @property {string | null} defaultBranch - The branch that is cloned if no branch is specified
1420
+ * @property {string | null} fetchHead - The SHA-1 object id of the fetched head commit
1421
+ * @property {string | null} fetchHeadDescription - a textual description of the branch that was fetched
1422
+ * @property {Object<string, string>} [headers] - The HTTP response headers returned by the git server
1423
+ * @property {string[]} [pruned] - A list of branches that were pruned, if you provided the `prune` parameter
1424
+ *
1425
+ */
1426
+ /**
1427
+ * Fetch commits from a remote repository
1428
+ *
1429
+ * @param {object} args
1430
+ * @param {FsClient} args.fs - a file system client
1431
+ * @param {HttpClient} args.http - an HTTP client
1432
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
1433
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
1434
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1435
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1436
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1437
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1438
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1439
+ * @param {string} [args.url] - The URL of the remote repository. The default is the value set in the git config for that remote.
1440
+ * @param {string} [args.remote] - If URL is not specified, determines which remote to use.
1441
+ * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
1442
+ * @param {string} [args.ref] - Which branch to fetch if `singleBranch` is true. By default this is the current branch or the remote's default branch.
1443
+ * @param {string} [args.remoteRef] - The name of the branch on the remote to fetch if `singleBranch` is true. By default this is the configured remote tracking branch.
1444
+ * @param {boolean} [args.tags = false] - Also fetch tags
1445
+ * @param {number} [args.depth] - Integer. Determines how much of the git repository's history to retrieve
1446
+ * @param {boolean} [args.relative = false] - Changes the meaning of `depth` to be measured from the current shallow depth rather than from the branch tip.
1447
+ * @param {Date} [args.since] - Only fetch commits created after the given date. Mutually exclusive with `depth`.
1448
+ * @param {string[]} [args.exclude = []] - A list of branches or tags. Instructs the remote server not to send us any commits reachable from these refs.
1449
+ * @param {boolean} [args.prune = false] - Delete local remote-tracking branches that are not present on the remote
1450
+ * @param {boolean} [args.pruneTags = false] - Prune local tags that don’t exist on the remote, and force-update those tags that differ
1451
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
1452
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1453
+ * @param {object} [args.cache] - a [cache](cache.md) object
1454
+ *
1455
+ * @returns {Promise<FetchResult>} Resolves successfully when fetch completes
1456
+ * @see FetchResult
1457
+ *
1458
+ * @example
1459
+ * let result = await git.fetch({
1460
+ * fs,
1461
+ * http,
1462
+ * dir: '/tutorial',
1463
+ * corsProxy: 'https://cors.isomorphic-git.org',
1464
+ * url: 'https://github.com/isomorphic-git/isomorphic-git',
1465
+ * ref: 'main',
1466
+ * depth: 1,
1467
+ * singleBranch: true,
1468
+ * tags: false
1469
+ * })
1470
+ * console.log(result)
1471
+ *
1472
+ */
1473
+ export function fetch({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, dir, gitdir, ref, remote, remoteRef, url, corsProxy, depth, since, exclude, relative, tags, singleBranch, headers, prune, pruneTags, cache, }: {
1474
+ fs: FsClient;
1475
+ http: HttpClient;
1476
+ onProgress?: ProgressCallback | undefined;
1477
+ onMessage?: MessageCallback | undefined;
1478
+ onAuth?: AuthCallback | undefined;
1479
+ onAuthFailure?: AuthFailureCallback | undefined;
1480
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1481
+ dir?: string | undefined;
1482
+ gitdir?: string | undefined;
1483
+ url?: string | undefined;
1484
+ remote?: string | undefined;
1485
+ singleBranch?: boolean | undefined;
1486
+ ref?: string | undefined;
1487
+ remoteRef?: string | undefined;
1488
+ tags?: boolean | undefined;
1489
+ depth?: number | undefined;
1490
+ relative?: boolean | undefined;
1491
+ since?: Date | undefined;
1492
+ exclude?: string[] | undefined;
1493
+ prune?: boolean | undefined;
1494
+ pruneTags?: boolean | undefined;
1495
+ corsProxy?: string | undefined;
1496
+ headers?: {
1497
+ [x: string]: string;
1498
+ } | undefined;
1499
+ cache?: object;
1500
+ }): Promise<FetchResult>;
1501
+ /**
1502
+ * Find the merge base for a set of commits
1503
+ *
1504
+ * @param {object} args
1505
+ * @param {FsClient} args.fs - a file system client
1506
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1507
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1508
+ * @param {string[]} args.oids - Which commits
1509
+ * @param {object} [args.cache] - a [cache](cache.md) object
1510
+ *
1511
+ */
1512
+ export function findMergeBase({ fs, dir, gitdir, oids, cache, }: {
1513
+ fs: FsClient;
1514
+ dir?: string | undefined;
1515
+ gitdir?: string | undefined;
1516
+ oids: string[];
1517
+ cache?: object;
1518
+ }): Promise<any[]>;
1519
+ /**
1520
+ * Find the root git directory
1521
+ *
1522
+ * Starting at `filepath`, walks upward until it finds a directory that contains a subdirectory called '.git'.
1523
+ *
1524
+ * @param {Object} args
1525
+ * @param {FsClient} args.fs - a file system client
1526
+ * @param {string} args.filepath - The file directory to start searching in.
1527
+ *
1528
+ * @returns {Promise<string>} Resolves successfully with a root git directory path
1529
+ * @throws {NotFoundError}
1530
+ *
1531
+ * @example
1532
+ * let gitroot = await git.findRoot({
1533
+ * fs,
1534
+ * filepath: '/tutorial/src/utils'
1535
+ * })
1536
+ * console.log(gitroot)
1537
+ *
1538
+ */
1539
+ export function findRoot({ fs, filepath }: {
1540
+ fs: FsClient;
1541
+ filepath: string;
1542
+ }): Promise<string>;
1543
+ /**
1544
+ * Read an entry from the git config files.
1545
+ *
1546
+ * *Caveats:*
1547
+ * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.
1548
+ * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.
1549
+ *
1550
+ * @param {Object} args
1551
+ * @param {FsClient} args.fs - a file system implementation
1552
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1553
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1554
+ * @param {string} args.path - The key of the git config entry
1555
+ *
1556
+ * @returns {Promise<any>} Resolves with the config value
1557
+ *
1558
+ * @example
1559
+ * // Read config value
1560
+ * let value = await git.getConfig({
1561
+ * fs,
1562
+ * dir: '/tutorial',
1563
+ * path: 'remote.origin.url'
1564
+ * })
1565
+ * console.log(value)
1566
+ *
1567
+ */
1568
+ export function getConfig({ fs, dir, gitdir, path }: {
1569
+ fs: FsClient;
1570
+ dir?: string | undefined;
1571
+ gitdir?: string | undefined;
1572
+ path: string;
1573
+ }): Promise<any>;
1574
+ /**
1575
+ * Read a multi-valued entry from the git config files.
1576
+ *
1577
+ * *Caveats:*
1578
+ * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.
1579
+ * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.
1580
+ *
1581
+ * @param {Object} args
1582
+ * @param {FsClient} args.fs - a file system implementation
1583
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1584
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1585
+ * @param {string} args.path - The key of the git config entry
1586
+ *
1587
+ * @returns {Promise<Array<any>>} Resolves with the config value
1588
+ *
1589
+ */
1590
+ export function getConfigAll({ fs, dir, gitdir, path, }: {
1591
+ fs: FsClient;
1592
+ dir?: string | undefined;
1593
+ gitdir?: string | undefined;
1594
+ path: string;
1595
+ }): Promise<Array<any>>;
1596
+ /**
1597
+ *
1598
+ * @typedef {Object} GetRemoteInfoResult - The object returned has the following schema:
1599
+ * @property {string[]} capabilities - The list of capabilities returned by the server (part of the Git protocol)
1600
+ * @property {Object} [refs]
1601
+ * @property {string} [HEAD] - The default branch of the remote
1602
+ * @property {Object<string, string>} [refs.heads] - The branches on the remote
1603
+ * @property {Object<string, string>} [refs.pull] - The special branches representing pull requests (non-standard)
1604
+ * @property {Object<string, string>} [refs.tags] - The tags on the remote
1605
+ *
1606
+ */
1607
+ /**
1608
+ * List a remote servers branches, tags, and capabilities.
1609
+ *
1610
+ * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.
1611
+ * It just communicates to a remote git server, using the first step of the `git-upload-pack` handshake, but stopping short of fetching the packfile.
1612
+ *
1613
+ * @param {object} args
1614
+ * @param {HttpClient} args.http - an HTTP client
1615
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1616
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1617
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1618
+ * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.
1619
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
1620
+ * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.
1621
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1622
+ *
1623
+ * @returns {Promise<GetRemoteInfoResult>} Resolves successfully with an object listing the branches, tags, and capabilities of the remote.
1624
+ * @see GetRemoteInfoResult
1625
+ *
1626
+ * @example
1627
+ * let info = await git.getRemoteInfo({
1628
+ * http,
1629
+ * url:
1630
+ * "https://cors.isomorphic-git.org/github.com/isomorphic-git/isomorphic-git.git"
1631
+ * });
1632
+ * console.log(info);
1633
+ *
1634
+ */
1635
+ export function getRemoteInfo({ http, onAuth, onAuthSuccess, onAuthFailure, corsProxy, url, headers, forPush, }: {
1636
+ http: HttpClient;
1637
+ onAuth?: AuthCallback | undefined;
1638
+ onAuthFailure?: AuthFailureCallback | undefined;
1639
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1640
+ url: string;
1641
+ corsProxy?: string | undefined;
1642
+ forPush?: boolean | undefined;
1643
+ headers?: {
1644
+ [x: string]: string;
1645
+ } | undefined;
1646
+ }): Promise<GetRemoteInfoResult>;
1647
+ /**
1648
+ * @typedef {Object} GetRemoteInfo2Result - This object has the following schema:
1649
+ * @property {1 | 2} protocolVersion - Git protocol version the server supports
1650
+ * @property {Object<string, string | true>} capabilities - An object of capabilities represented as keys and values
1651
+ * @property {ServerRef[]} [refs] - Server refs (they get returned by protocol version 1 whether you want them or not)
1652
+ */
1653
+ /**
1654
+ * List a remote server's capabilities.
1655
+ *
1656
+ * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.
1657
+ * It just communicates to a remote git server, determining what protocol version, commands, and features it supports.
1658
+ *
1659
+ * > The successor to [`getRemoteInfo`](./getRemoteInfo.md), this command supports Git Wire Protocol Version 2.
1660
+ * > Therefore its return type is more complicated as either:
1661
+ * >
1662
+ * > - v1 capabilities (and refs) or
1663
+ * > - v2 capabilities (and no refs)
1664
+ * >
1665
+ * > are returned.
1666
+ * > If you just care about refs, use [`listServerRefs`](./listServerRefs.md)
1667
+ *
1668
+ * @param {object} args
1669
+ * @param {HttpClient} args.http - an HTTP client
1670
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
1671
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
1672
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
1673
+ * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.
1674
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
1675
+ * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.
1676
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
1677
+ * @param {1 | 2} [args.protocolVersion = 2] - Which version of the Git Protocol to use.
1678
+ *
1679
+ * @returns {Promise<GetRemoteInfo2Result>} Resolves successfully with an object listing the capabilities of the remote.
1680
+ * @see GetRemoteInfo2Result
1681
+ * @see ServerRef
1682
+ *
1683
+ * @example
1684
+ * let info = await git.getRemoteInfo2({
1685
+ * http,
1686
+ * corsProxy: "https://cors.isomorphic-git.org",
1687
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git"
1688
+ * });
1689
+ * console.log(info);
1690
+ *
1691
+ */
1692
+ export function getRemoteInfo2({ http, onAuth, onAuthSuccess, onAuthFailure, corsProxy, url, headers, forPush, protocolVersion, }: {
1693
+ http: HttpClient;
1694
+ onAuth?: AuthCallback | undefined;
1695
+ onAuthFailure?: AuthFailureCallback | undefined;
1696
+ onAuthSuccess?: AuthSuccessCallback | undefined;
1697
+ url: string;
1698
+ corsProxy?: string | undefined;
1699
+ forPush?: boolean | undefined;
1700
+ headers?: {
1701
+ [x: string]: string;
1702
+ } | undefined;
1703
+ protocolVersion?: 2 | 1 | undefined;
1704
+ }): Promise<GetRemoteInfo2Result>;
1705
+ /**
1706
+ *
1707
+ * @typedef {object} HashBlobResult - The object returned has the following schema:
1708
+ * @property {string} oid - The SHA-1 object id
1709
+ * @property {'blob'} type - The type of the object
1710
+ * @property {Uint8Array} object - The wrapped git object (the thing that is hashed)
1711
+ * @property {'wrapped'} format - The format of the object
1712
+ *
1713
+ */
1714
+ /**
1715
+ * Compute what the SHA-1 object id of a file would be
1716
+ *
1717
+ * @param {object} args
1718
+ * @param {Uint8Array|string} args.object - The object to write. If `object` is a String then it will be converted to a Uint8Array using UTF-8 encoding.
1719
+ *
1720
+ * @returns {Promise<HashBlobResult>} Resolves successfully with the SHA-1 object id and the wrapped object Uint8Array.
1721
+ * @see HashBlobResult
1722
+ *
1723
+ * @example
1724
+ * let { oid, type, object, format } = await git.hashBlob({
1725
+ * object: 'Hello world!',
1726
+ * })
1727
+ *
1728
+ * console.log('oid', oid)
1729
+ * console.log('type', type)
1730
+ * console.log('object', object)
1731
+ * console.log('format', format)
1732
+ *
1733
+ */
1734
+ export function hashBlob({ object }: {
1735
+ object: Uint8Array | string;
1736
+ }): Promise<HashBlobResult>;
1737
+ /**
1738
+ * Create the .idx file for a given .pack file
1739
+ *
1740
+ * @param {object} args
1741
+ * @param {FsClient} args.fs - a file system client
1742
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
1743
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
1744
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1745
+ * @param {string} args.filepath - The path to the .pack file to index
1746
+ * @param {object} [args.cache] - a [cache](cache.md) object
1747
+ *
1748
+ * @returns {Promise<{oids: string[]}>} Resolves with a list of the SHA-1 object ids contained in the packfile
1749
+ *
1750
+ * @example
1751
+ * let packfiles = await fs.promises.readdir('/tutorial/.git/objects/pack')
1752
+ * packfiles = packfiles.filter(name => name.endsWith('.pack'))
1753
+ * console.log('packfiles', packfiles)
1754
+ *
1755
+ * const { oids } = await git.indexPack({
1756
+ * fs,
1757
+ * dir: '/tutorial',
1758
+ * filepath: `.git/objects/pack/${packfiles[0]}`,
1759
+ * async onProgress (evt) {
1760
+ * console.log(`${evt.phase}: ${evt.loaded} / ${evt.total}`)
1761
+ * }
1762
+ * })
1763
+ * console.log(oids)
1764
+ *
1765
+ */
1766
+ export function indexPack({ fs, onProgress, dir, gitdir, filepath, cache, }: {
1767
+ fs: FsClient;
1768
+ onProgress?: ProgressCallback | undefined;
1769
+ dir: string;
1770
+ gitdir?: string | undefined;
1771
+ filepath: string;
1772
+ cache?: object;
1773
+ }): Promise<{
1774
+ oids: string[];
1775
+ }>;
1776
+ /**
1777
+ * Initialize a new repository
1778
+ *
1779
+ * @param {object} args
1780
+ * @param {FsClient} args.fs - a file system client
1781
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1782
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1783
+ * @param {boolean} [args.bare = false] - Initialize a bare repository
1784
+ * @param {string} [args.defaultBranch = 'master'] - The name of the default branch (might be changed to a required argument in 2.0.0)
1785
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
1786
+ *
1787
+ * @example
1788
+ * await git.init({ fs, dir: '/tutorial' })
1789
+ * console.log('done')
1790
+ *
1791
+ */
1792
+ export function init({ fs, bare, dir, gitdir, defaultBranch, }: {
1793
+ fs: FsClient;
1794
+ dir?: string | undefined;
1795
+ gitdir?: string | undefined;
1796
+ bare?: boolean | undefined;
1797
+ defaultBranch?: string | undefined;
1798
+ }): Promise<void>;
1799
+ /**
1800
+ * Check whether a git commit is descended from another
1801
+ *
1802
+ * @param {object} args
1803
+ * @param {FsClient} args.fs - a file system client
1804
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1805
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1806
+ * @param {string} args.oid - The descendent commit
1807
+ * @param {string} args.ancestor - The (proposed) ancestor commit
1808
+ * @param {number} [args.depth = -1] - Maximum depth to search before giving up. -1 means no maximum depth.
1809
+ * @param {object} [args.cache] - a [cache](cache.md) object
1810
+ *
1811
+ * @returns {Promise<boolean>} Resolves to true if `oid` is a descendent of `ancestor`
1812
+ *
1813
+ * @example
1814
+ * let oid = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })
1815
+ * let ancestor = await git.resolveRef({ fs, dir: '/tutorial', ref: 'v0.20.0' })
1816
+ * console.log(oid, ancestor)
1817
+ * await git.isDescendent({ fs, dir: '/tutorial', oid, ancestor, depth: -1 })
1818
+ *
1819
+ */
1820
+ export function isDescendent({ fs, dir, gitdir, oid, ancestor, depth, cache, }: {
1821
+ fs: FsClient;
1822
+ dir?: string | undefined;
1823
+ gitdir?: string | undefined;
1824
+ oid: string;
1825
+ ancestor: string;
1826
+ depth?: number | undefined;
1827
+ cache?: object;
1828
+ }): Promise<boolean>;
1829
+ /**
1830
+ * Test whether a filepath should be ignored (because of .gitignore or .git/exclude)
1831
+ *
1832
+ * @param {object} args
1833
+ * @param {FsClient} args.fs - a file system client
1834
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
1835
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1836
+ * @param {string} args.filepath - The filepath to test
1837
+ *
1838
+ * @returns {Promise<boolean>} Resolves to true if the file should be ignored
1839
+ *
1840
+ * @example
1841
+ * await git.isIgnored({ fs, dir: '/tutorial', filepath: 'docs/add.md' })
1842
+ *
1843
+ */
1844
+ export function isIgnored({ fs, dir, gitdir, filepath, }: {
1845
+ fs: FsClient;
1846
+ dir: string;
1847
+ gitdir?: string | undefined;
1848
+ filepath: string;
1849
+ }): Promise<boolean>;
1850
+ /**
1851
+ * List branches
1852
+ *
1853
+ * By default it lists local branches. If a 'remote' is specified, it lists the remote's branches. When listing remote branches, the HEAD branch is not filtered out, so it may be included in the list of results.
1854
+ *
1855
+ * Note that specifying a remote does not actually contact the server and update the list of branches.
1856
+ * If you want an up-to-date list, first do a `fetch` to that remote.
1857
+ * (Which branch you fetch doesn't matter - the list of branches available on the remote is updated during the fetch handshake.)
1858
+ *
1859
+ * Also note, that a branch is a reference to a commit. If you initialize a new repository it has no commits, so the
1860
+ * `listBranches` function will return an empty list, until you create the first commit.
1861
+ *
1862
+ * @param {object} args
1863
+ * @param {FsClient} args.fs - a file system client
1864
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1865
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1866
+ * @param {string} [args.remote] - Instead of the branches in `refs/heads`, list the branches in `refs/remotes/${remote}`.
1867
+ *
1868
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of branch names
1869
+ *
1870
+ * @example
1871
+ * let branches = await git.listBranches({ fs, dir: '/tutorial' })
1872
+ * console.log(branches)
1873
+ * let remoteBranches = await git.listBranches({ fs, dir: '/tutorial', remote: 'origin' })
1874
+ * console.log(remoteBranches)
1875
+ *
1876
+ */
1877
+ export function listBranches({ fs, dir, gitdir, remote, }: {
1878
+ fs: FsClient;
1879
+ dir?: string | undefined;
1880
+ gitdir?: string | undefined;
1881
+ remote?: string | undefined;
1882
+ }): Promise<Array<string>>;
1883
+ /**
1884
+ * List all the files in the git index or a commit
1885
+ *
1886
+ * > Note: This function is efficient for listing the files in the staging area, but listing all the files in a commit requires recursively walking through the git object store.
1887
+ * > If you do not require a complete list of every file, better performance can be achieved by using [walk](./walk) and ignoring subdirectories you don't care about.
1888
+ *
1889
+ * @param {object} args
1890
+ * @param {FsClient} args.fs - a file system client
1891
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1892
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1893
+ * @param {string} [args.ref] - Return a list of all the files in the commit at `ref` instead of the files currently in the git index (aka staging area)
1894
+ * @param {object} [args.cache] - a [cache](cache.md) object
1895
+ *
1896
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of filepaths
1897
+ *
1898
+ * @example
1899
+ * // All the files in the previous commit
1900
+ * let files = await git.listFiles({ fs, dir: '/tutorial', ref: 'HEAD' })
1901
+ * console.log(files)
1902
+ * // All the files in the current staging area
1903
+ * files = await git.listFiles({ fs, dir: '/tutorial' })
1904
+ * console.log(files)
1905
+ *
1906
+ */
1907
+ export function listFiles({ fs, dir, gitdir, ref, cache, }: {
1908
+ fs: FsClient;
1909
+ dir?: string | undefined;
1910
+ gitdir?: string | undefined;
1911
+ ref?: string | undefined;
1912
+ cache?: object;
1913
+ }): Promise<Array<string>>;
1914
+ /**
1915
+ * List all the object notes
1916
+ *
1917
+ * @param {object} args
1918
+ * @param {FsClient} args.fs - a file system client
1919
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1920
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1921
+ * @param {string} [args.ref] - The notes ref to look under
1922
+ * @param {object} [args.cache] - a [cache](cache.md) object
1923
+ *
1924
+ * @returns {Promise<Array<{target: string, note: string}>>} Resolves successfully with an array of entries containing SHA-1 object ids of the note and the object the note targets
1925
+ */
1926
+ export function listNotes({ fs, dir, gitdir, ref, cache, }: {
1927
+ fs: FsClient;
1928
+ dir?: string | undefined;
1929
+ gitdir?: string | undefined;
1930
+ ref?: string | undefined;
1931
+ cache?: object;
1932
+ }): Promise<Array<{
1933
+ target: string;
1934
+ note: string;
1935
+ }>>;
1936
+ /**
1937
+ * List refs
1938
+ *
1939
+ * @param {object} args
1940
+ * @param {FsClient} args.fs - a file system client
1941
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1942
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1943
+ * @param {string} [args.filepath] - [required] The refs path to list
1944
+ *
1945
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of ref names below the supplied `filepath`
1946
+ *
1947
+ * @example
1948
+ * let refs = await git.listRefs({ fs, dir: '/tutorial', filepath: 'refs/heads' })
1949
+ * console.log(refs)
1950
+ *
1951
+ */
1952
+ export function listRefs({ fs, dir, gitdir, filepath, }: {
1953
+ fs: FsClient;
1954
+ dir?: string | undefined;
1955
+ gitdir?: string | undefined;
1956
+ filepath?: string | undefined;
1957
+ }): Promise<Array<string>>;
1958
+ /**
1959
+ * List remotes
1960
+ *
1961
+ * @param {object} args
1962
+ * @param {FsClient} args.fs - a file system client
1963
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
1964
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
1965
+ *
1966
+ * @returns {Promise<Array<{remote: string, url: string}>>} Resolves successfully with an array of `{remote, url}` objects
1967
+ *
1968
+ * @example
1969
+ * let remotes = await git.listRemotes({ fs, dir: '/tutorial' })
1970
+ * console.log(remotes)
1971
+ *
1972
+ */
1973
+ export function listRemotes({ fs, dir, gitdir }: {
1974
+ fs: FsClient;
1975
+ dir?: string | undefined;
1976
+ gitdir?: string | undefined;
1977
+ }): Promise<Array<{
1978
+ remote: string;
1979
+ url: string;
1980
+ }>>;
1981
+ /**
1982
+ * Fetch a list of refs (branches, tags, etc) from a server.
1983
+ *
1984
+ * This is a rare command that doesn't require an `fs`, `dir`, or even `gitdir` argument.
1985
+ * It just requires an `http` argument.
1986
+ *
1987
+ * ### About `protocolVersion`
1988
+ *
1989
+ * There's a rather fun trade-off between Git Protocol Version 1 and Git Protocol Version 2.
1990
+ * Version 2 actually requires 2 HTTP requests instead of 1, making it similar to fetch or push in that regard.
1991
+ * However, version 2 supports server-side filtering by prefix, whereas that filtering is done client-side in version 1.
1992
+ * Which protocol is most efficient therefore depends on the number of refs on the remote, the latency of the server, and speed of the network connection.
1993
+ * For an small repos (or fast Internet connections), the requirement to make two trips to the server makes protocol 2 slower.
1994
+ * But for large repos (or slow Internet connections), the decreased payload size of the second request makes up for the additional request.
1995
+ *
1996
+ * Hard numbers vary by situation, but here's some numbers from my machine:
1997
+ *
1998
+ * Using isomorphic-git in a browser, with a CORS proxy, listing only the branches (refs/heads) of https://github.com/isomorphic-git/isomorphic-git
1999
+ * - Protocol Version 1 took ~300ms and transferred 84 KB.
2000
+ * - Protocol Version 2 took ~500ms and transferred 4.1 KB.
2001
+ *
2002
+ * Using isomorphic-git in a browser, with a CORS proxy, listing only the branches (refs/heads) of https://gitlab.com/gitlab-org/gitlab
2003
+ * - Protocol Version 1 took ~4900ms and transferred 9.41 MB.
2004
+ * - Protocol Version 2 took ~1280ms and transferred 433 KB.
2005
+ *
2006
+ * Finally, there is a fun quirk regarding the `symrefs` parameter.
2007
+ * Protocol Version 1 will generally only return the `HEAD` symref and not others.
2008
+ * Historically, this meant that servers don't use symbolic refs except for `HEAD`, which is used to point at the "default branch".
2009
+ * However Protocol Version 2 can return *all* the symbolic refs on the server.
2010
+ * So if you are running your own git server, you could take advantage of that I guess.
2011
+ *
2012
+ * #### TL;DR
2013
+ * If you are _not_ taking advantage of `prefix` I would recommend `protocolVersion: 1`.
2014
+ * Otherwise, I recommend to use the default which is `protocolVersion: 2`.
2015
+ *
2016
+ * @param {object} args
2017
+ * @param {HttpClient} args.http - an HTTP client
2018
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
2019
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
2020
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
2021
+ * @param {string} args.url - The URL of the remote repository. Will be gotten from gitconfig if absent.
2022
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
2023
+ * @param {boolean} [args.forPush = false] - By default, the command queries the 'fetch' capabilities. If true, it will ask for the 'push' capabilities.
2024
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
2025
+ * @param {1 | 2} [args.protocolVersion = 2] - Which version of the Git Protocol to use.
2026
+ * @param {string} [args.prefix] - Only list refs that start with this prefix
2027
+ * @param {boolean} [args.symrefs = false] - Include symbolic ref targets
2028
+ * @param {boolean} [args.peelTags = false] - Include annotated tag peeled targets
2029
+ *
2030
+ * @returns {Promise<ServerRef[]>} Resolves successfully with an array of ServerRef objects
2031
+ * @see ServerRef
2032
+ *
2033
+ * @example
2034
+ * // List all the branches on a repo
2035
+ * let refs = await git.listServerRefs({
2036
+ * http,
2037
+ * corsProxy: "https://cors.isomorphic-git.org",
2038
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git",
2039
+ * prefix: "refs/heads/",
2040
+ * });
2041
+ * console.log(refs);
2042
+ *
2043
+ * @example
2044
+ * // Get the default branch on a repo
2045
+ * let refs = await git.listServerRefs({
2046
+ * http,
2047
+ * corsProxy: "https://cors.isomorphic-git.org",
2048
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git",
2049
+ * prefix: "HEAD",
2050
+ * symrefs: true,
2051
+ * });
2052
+ * console.log(refs);
2053
+ *
2054
+ * @example
2055
+ * // List all the tags on a repo
2056
+ * let refs = await git.listServerRefs({
2057
+ * http,
2058
+ * corsProxy: "https://cors.isomorphic-git.org",
2059
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git",
2060
+ * prefix: "refs/tags/",
2061
+ * peelTags: true,
2062
+ * });
2063
+ * console.log(refs);
2064
+ *
2065
+ * @example
2066
+ * // List all the pull requests on a repo
2067
+ * let refs = await git.listServerRefs({
2068
+ * http,
2069
+ * corsProxy: "https://cors.isomorphic-git.org",
2070
+ * url: "https://github.com/isomorphic-git/isomorphic-git.git",
2071
+ * prefix: "refs/pull/",
2072
+ * });
2073
+ * console.log(refs);
2074
+ *
2075
+ */
2076
+ export function listServerRefs({ http, onAuth, onAuthSuccess, onAuthFailure, corsProxy, url, headers, forPush, protocolVersion, prefix, symrefs, peelTags, }: {
2077
+ http: HttpClient;
2078
+ onAuth?: AuthCallback | undefined;
2079
+ onAuthFailure?: AuthFailureCallback | undefined;
2080
+ onAuthSuccess?: AuthSuccessCallback | undefined;
2081
+ url: string;
2082
+ corsProxy?: string | undefined;
2083
+ forPush?: boolean | undefined;
2084
+ headers?: {
2085
+ [x: string]: string;
2086
+ } | undefined;
2087
+ protocolVersion?: 2 | 1 | undefined;
2088
+ prefix?: string | undefined;
2089
+ symrefs?: boolean | undefined;
2090
+ peelTags?: boolean | undefined;
2091
+ }): Promise<ServerRef[]>;
2092
+ /**
2093
+ * List tags
2094
+ *
2095
+ * @param {object} args
2096
+ * @param {FsClient} args.fs - a file system client
2097
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2098
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2099
+ *
2100
+ * @returns {Promise<Array<string>>} Resolves successfully with an array of tag names
2101
+ *
2102
+ * @example
2103
+ * let tags = await git.listTags({ fs, dir: '/tutorial' })
2104
+ * console.log(tags)
2105
+ *
2106
+ */
2107
+ export function listTags({ fs, dir, gitdir }: {
2108
+ fs: FsClient;
2109
+ dir?: string | undefined;
2110
+ gitdir?: string | undefined;
2111
+ }): Promise<Array<string>>;
2112
+ /**
2113
+ * Get commit descriptions from the git history
2114
+ *
2115
+ * @param {object} args
2116
+ * @param {FsClient} args.fs - a file system client
2117
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2118
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2119
+ * @param {string=} args.filepath optional get the commit for the filepath only
2120
+ * @param {string} [args.ref = 'HEAD'] - The commit to begin walking backwards through the history from
2121
+ * @param {number=} [args.depth] - Limit the number of commits returned. No limit by default.
2122
+ * @param {Date} [args.since] - Return history newer than the given date. Can be combined with `depth` to get whichever is shorter.
2123
+ * @param {boolean=} [args.force=false] do not throw error if filepath is not exist (works only for a single file). defaults to false
2124
+ * @param {boolean=} [args.follow=false] Continue listing the history of a file beyond renames (works only for a single file). defaults to false
2125
+ * @param {object} [args.cache] - a [cache](cache.md) object
2126
+ *
2127
+ * @returns {Promise<Array<ReadCommitResult>>} Resolves to an array of ReadCommitResult objects
2128
+ * @see ReadCommitResult
2129
+ * @see CommitObject
2130
+ *
2131
+ * @example
2132
+ * let commits = await git.log({
2133
+ * fs,
2134
+ * dir: '/tutorial',
2135
+ * depth: 5,
2136
+ * ref: 'main'
2137
+ * })
2138
+ * console.log(commits)
2139
+ *
2140
+ */
2141
+ export function log({ fs, dir, gitdir, filepath, ref, depth, since, force, follow, cache, }: {
2142
+ fs: FsClient;
2143
+ dir?: string | undefined;
2144
+ gitdir?: string | undefined;
2145
+ filepath?: string | undefined;
2146
+ ref?: string | undefined;
2147
+ depth?: number | undefined;
2148
+ since?: Date | undefined;
2149
+ force?: boolean | undefined;
2150
+ follow?: boolean | undefined;
2151
+ cache?: object;
2152
+ }): Promise<Array<ReadCommitResult>>;
2153
+ /**
2154
+ *
2155
+ * @typedef {Object} MergeResult - Returns an object with a schema like this:
2156
+ * @property {string} [oid] - The SHA-1 object id that is now at the head of the branch. Absent only if `dryRun` was specified and `mergeCommit` is true.
2157
+ * @property {boolean} [alreadyMerged] - True if the branch was already merged so no changes were made
2158
+ * @property {boolean} [fastForward] - True if it was a fast-forward merge
2159
+ * @property {boolean} [mergeCommit] - True if merge resulted in a merge commit
2160
+ * @property {string} [tree] - The SHA-1 object id of the tree resulting from a merge commit
2161
+ *
2162
+ */
2163
+ /**
2164
+ * Merge two branches
2165
+ *
2166
+ * Currently it will fail if multiple candidate merge bases are found. (It doesn't yet implement the recursive merge strategy.)
2167
+ *
2168
+ * Currently it does not support selecting alternative merge strategies.
2169
+ *
2170
+ * Currently it is not possible to abort an incomplete merge. To restore the worktree to a clean state, you will need to checkout an earlier commit.
2171
+ *
2172
+ * Currently it does not directly support the behavior of `git merge --continue`. To complete a merge after manual conflict resolution, you will need to add and commit the files manually, and specify the appropriate parent commits.
2173
+ *
2174
+ * ## Manually resolving merge conflicts
2175
+ * By default, if isomorphic-git encounters a merge conflict it cannot resolve using the builtin diff3 algorithm or provided merge driver, it will abort and throw a `MergeNotSupportedError`.
2176
+ * This leaves the index and working tree untouched.
2177
+ *
2178
+ * When `abortOnConflict` is set to `false`, and a merge conflict cannot be automatically resolved, a `MergeConflictError` is thrown and the results of the incomplete merge will be written to the working directory.
2179
+ * This includes conflict markers in files with unresolved merge conflicts.
2180
+ *
2181
+ * To complete the merge, edit the conflicting files as you see fit, and then add and commit the resolved merge.
2182
+ *
2183
+ * For a proper merge commit, be sure to specify the branches or commits you are merging in the `parent` argument to `git.commit`.
2184
+ * For example, say we are merging the branch `feature` into the branch `main` and there is a conflict we want to resolve manually.
2185
+ * The flow would look like this:
2186
+ *
2187
+ * ```
2188
+ * await git.merge({
2189
+ * fs,
2190
+ * dir,
2191
+ * ours: 'main',
2192
+ * theirs: 'feature',
2193
+ * abortOnConflict: false,
2194
+ * }).catch(e => {
2195
+ * if (e instanceof Errors.MergeConflictError) {
2196
+ * console.log(
2197
+ * 'Automatic merge failed for the following files: '
2198
+ * + `${e.data}. `
2199
+ * + 'Resolve these conflicts and then commit your changes.'
2200
+ * )
2201
+ * } else throw e
2202
+ * })
2203
+ *
2204
+ * // This is the where we manually edit the files that have been written to the working directory
2205
+ * // ...
2206
+ * // Files have been edited and we are ready to commit
2207
+ *
2208
+ * await git.add({
2209
+ * fs,
2210
+ * dir,
2211
+ * filepath: '.',
2212
+ * })
2213
+ *
2214
+ * await git.commit({
2215
+ * fs,
2216
+ * dir,
2217
+ * ref: 'main',
2218
+ * message: "Merge branch 'feature' into main",
2219
+ * parent: ['main', 'feature'], // Be sure to specify the parents when creating a merge commit
2220
+ * })
2221
+ * ```
2222
+ *
2223
+ * @param {object} args
2224
+ * @param {FsClient} args.fs - a file system client
2225
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
2226
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2227
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2228
+ * @param {string} [args.ours] - The branch receiving the merge. If undefined, defaults to the current branch.
2229
+ * @param {string} args.theirs - The branch to be merged
2230
+ * @param {boolean} [args.fastForward = true] - If false, create a merge commit in all cases.
2231
+ * @param {boolean} [args.fastForwardOnly = false] - If true, then non-fast-forward merges will throw an Error instead of performing a merge.
2232
+ * @param {boolean} [args.dryRun = false] - If true, simulates a merge so you can test whether it would succeed.
2233
+ * @param {boolean} [args.noUpdateBranch = false] - If true, does not update the branch pointer after creating the commit.
2234
+ * @param {boolean} [args.abortOnConflict = true] - If true, merges with conflicts will not update the worktree or index.
2235
+ * @param {string} [args.message] - Overrides the default auto-generated merge commit message
2236
+ * @param {Object} [args.author] - passed to [commit](commit.md) when creating a merge commit
2237
+ * @param {string} [args.author.name] - Default is `user.name` config.
2238
+ * @param {string} [args.author.email] - Default is `user.email` config.
2239
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2240
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2241
+ * @param {Object} [args.committer] - passed to [commit](commit.md) when creating a merge commit
2242
+ * @param {string} [args.committer.name] - Default is `user.name` config.
2243
+ * @param {string} [args.committer.email] - Default is `user.email` config.
2244
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2245
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2246
+ * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
2247
+ * @param {object} [args.cache] - a [cache](cache.md) object
2248
+ * @param {MergeDriverCallback} [args.mergeDriver] - a [merge driver](mergeDriver.md) implementation
2249
+ * @param {boolean} [args.allowUnrelatedHistories = false] - If true, allows merging histories of two branches that started their lives independently.
2250
+ *
2251
+ * @returns {Promise<MergeResult>} Resolves to a description of the merge operation
2252
+ * @see MergeResult
2253
+ *
2254
+ * @example
2255
+ * let m = await git.merge({
2256
+ * fs,
2257
+ * dir: '/tutorial',
2258
+ * ours: 'main',
2259
+ * theirs: 'remotes/origin/main'
2260
+ * })
2261
+ * console.log(m)
2262
+ *
2263
+ */
2264
+ export function merge({ fs: _fs, onSign, dir, gitdir, ours, theirs, fastForward, fastForwardOnly, dryRun, noUpdateBranch, abortOnConflict, message, author: _author, committer: _committer, signingKey, cache, mergeDriver, allowUnrelatedHistories, }: {
2265
+ fs: FsClient;
2266
+ onSign?: SignCallback | undefined;
2267
+ dir?: string | undefined;
2268
+ gitdir?: string | undefined;
2269
+ ours?: string | undefined;
2270
+ theirs: string;
2271
+ fastForward?: boolean | undefined;
2272
+ fastForwardOnly?: boolean | undefined;
2273
+ dryRun?: boolean | undefined;
2274
+ noUpdateBranch?: boolean | undefined;
2275
+ abortOnConflict?: boolean | undefined;
2276
+ message?: string | undefined;
2277
+ author?: {
2278
+ name?: string | undefined;
2279
+ email?: string | undefined;
2280
+ timestamp?: number | undefined;
2281
+ timezoneOffset?: number | undefined;
2282
+ } | undefined;
2283
+ committer?: {
2284
+ name?: string | undefined;
2285
+ email?: string | undefined;
2286
+ timestamp?: number | undefined;
2287
+ timezoneOffset?: number | undefined;
2288
+ } | undefined;
2289
+ signingKey?: string | undefined;
2290
+ cache?: object;
2291
+ mergeDriver?: MergeDriverCallback | undefined;
2292
+ allowUnrelatedHistories?: boolean | undefined;
2293
+ }): Promise<MergeResult>;
2294
+ /**
2295
+ *
2296
+ * @typedef {Object} PackObjectsResult The packObjects command returns an object with two properties:
2297
+ * @property {string} filename - The suggested filename for the packfile if you want to save it to disk somewhere. It includes the packfile SHA.
2298
+ * @property {Uint8Array} [packfile] - The packfile contents. Not present if `write` parameter was true, in which case the packfile was written straight to disk.
2299
+ */
2300
+ /**
2301
+ * Create a packfile from an array of SHA-1 object ids
2302
+ *
2303
+ * @param {object} args
2304
+ * @param {FsClient} args.fs - a file system client
2305
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2306
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2307
+ * @param {string[]} args.oids - An array of SHA-1 object ids to be included in the packfile
2308
+ * @param {boolean} [args.write = false] - Whether to save the packfile to disk or not
2309
+ * @param {object} [args.cache] - a [cache](cache.md) object
2310
+ *
2311
+ * @returns {Promise<PackObjectsResult>} Resolves successfully when the packfile is ready with the filename and buffer
2312
+ * @see PackObjectsResult
2313
+ *
2314
+ * @example
2315
+ * // Create a packfile containing only an empty tree
2316
+ * let { packfile } = await git.packObjects({
2317
+ * fs,
2318
+ * dir: '/tutorial',
2319
+ * oids: ['4b825dc642cb6eb9a060e54bf8d69288fbee4904']
2320
+ * })
2321
+ * console.log(packfile)
2322
+ *
2323
+ */
2324
+ export function packObjects({ fs, dir, gitdir, oids, write, cache, }: {
2325
+ fs: FsClient;
2326
+ dir?: string | undefined;
2327
+ gitdir?: string | undefined;
2328
+ oids: string[];
2329
+ write?: boolean | undefined;
2330
+ cache?: object;
2331
+ }): Promise<PackObjectsResult>;
2332
+ /**
2333
+ * Fetch and merge commits from a remote repository
2334
+ *
2335
+ * @param {object} args
2336
+ * @param {FsClient} args.fs - a file system client
2337
+ * @param {HttpClient} args.http - an HTTP client
2338
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
2339
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
2340
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
2341
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
2342
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
2343
+ * @param {string} args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2344
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2345
+ * @param {string} [args.ref] - Which branch to merge into. By default this is the currently checked out branch.
2346
+ * @param {string} [args.url] - (Added in 1.1.0) The URL of the remote repository. The default is the value set in the git config for that remote.
2347
+ * @param {string} [args.remote] - (Added in 1.1.0) If URL is not specified, determines which remote to use.
2348
+ * @param {string} [args.remoteRef] - (Added in 1.1.0) The name of the branch on the remote to fetch. By default this is the configured remote tracking branch.
2349
+ * @param {boolean} [args.prune = false] - Delete local remote-tracking branches that are not present on the remote
2350
+ * @param {boolean} [args.pruneTags = false] - Prune local tags that don’t exist on the remote, and force-update those tags that differ
2351
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
2352
+ * @param {boolean} [args.singleBranch = false] - Instead of the default behavior of fetching all the branches, only fetch a single branch.
2353
+ * @param {boolean} [args.fastForward = true] - If false, only create merge commits.
2354
+ * @param {boolean} [args.fastForwardOnly = false] - Only perform simple fast-forward merges. (Don't create merge commits.)
2355
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
2356
+ * @param {Object} [args.author] - The details about the author.
2357
+ * @param {string} [args.author.name] - Default is `user.name` config.
2358
+ * @param {string} [args.author.email] - Default is `user.email` config.
2359
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2360
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2361
+ * @param {Object} [args.committer = author] - The details about the commit committer, in the same format as the author parameter. If not specified, the author details are used.
2362
+ * @param {string} [args.committer.name] - Default is `user.name` config.
2363
+ * @param {string} [args.committer.email] - Default is `user.email` config.
2364
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2365
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2366
+ * @param {string} [args.signingKey] - passed to [commit](commit.md) when creating a merge commit
2367
+ * @param {object} [args.cache] - a [cache](cache.md) object
2368
+ *
2369
+ * @returns {Promise<void>} Resolves successfully when pull operation completes
2370
+ *
2371
+ * @example
2372
+ * await git.pull({
2373
+ * fs,
2374
+ * http,
2375
+ * dir: '/tutorial',
2376
+ * ref: 'main',
2377
+ * singleBranch: true
2378
+ * })
2379
+ * console.log('done')
2380
+ *
2381
+ */
2382
+ export function pull({ fs: _fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, dir, gitdir, ref, url, remote, remoteRef, prune, pruneTags, fastForward, fastForwardOnly, corsProxy, singleBranch, headers, author: _author, committer: _committer, signingKey, cache, }: {
2383
+ fs: FsClient;
2384
+ http: HttpClient;
2385
+ onProgress?: ProgressCallback | undefined;
2386
+ onMessage?: MessageCallback | undefined;
2387
+ onAuth?: AuthCallback | undefined;
2388
+ onAuthFailure?: AuthFailureCallback | undefined;
2389
+ onAuthSuccess?: AuthSuccessCallback | undefined;
2390
+ dir: string;
2391
+ gitdir?: string | undefined;
2392
+ ref?: string | undefined;
2393
+ url?: string | undefined;
2394
+ remote?: string | undefined;
2395
+ remoteRef?: string | undefined;
2396
+ prune?: boolean | undefined;
2397
+ pruneTags?: boolean | undefined;
2398
+ corsProxy?: string | undefined;
2399
+ singleBranch?: boolean | undefined;
2400
+ fastForward?: boolean | undefined;
2401
+ fastForwardOnly?: boolean | undefined;
2402
+ headers?: {
2403
+ [x: string]: string;
2404
+ } | undefined;
2405
+ author?: {
2406
+ name?: string | undefined;
2407
+ email?: string | undefined;
2408
+ timestamp?: number | undefined;
2409
+ timezoneOffset?: number | undefined;
2410
+ } | undefined;
2411
+ committer?: {
2412
+ name?: string | undefined;
2413
+ email?: string | undefined;
2414
+ timestamp?: number | undefined;
2415
+ timezoneOffset?: number | undefined;
2416
+ } | undefined;
2417
+ signingKey?: string | undefined;
2418
+ cache?: object;
2419
+ }): Promise<void>;
2420
+ /**
2421
+ * Push a branch or tag
2422
+ *
2423
+ * The push command returns an object that describes the result of the attempted push operation.
2424
+ * *Notes:* If there were no errors, then there will be no `errors` property. There can be a mix of `ok` messages and `errors` messages.
2425
+ *
2426
+ * | param | type [= default] | description |
2427
+ * | ------ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2428
+ * | ok | Array\<string\> | The first item is "unpack" if the overall operation was successful. The remaining items are the names of refs that were updated successfully. |
2429
+ * | errors | Array\<string\> | If the overall operation threw and error, the first item will be "unpack {Overall error message}". The remaining items are individual refs that failed to be updated in the format "{ref name} {error message}". |
2430
+ *
2431
+ * @param {object} args
2432
+ * @param {FsClient} args.fs - a file system client
2433
+ * @param {HttpClient} args.http - an HTTP client
2434
+ * @param {ProgressCallback} [args.onProgress] - optional progress event callback
2435
+ * @param {MessageCallback} [args.onMessage] - optional message event callback
2436
+ * @param {AuthCallback} [args.onAuth] - optional auth fill callback
2437
+ * @param {AuthFailureCallback} [args.onAuthFailure] - optional auth rejected callback
2438
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - optional auth approved callback
2439
+ * @param {PrePushCallback} [args.onPrePush] - optional pre-push hook callback
2440
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2441
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2442
+ * @param {string} [args.ref] - Which branch or tag to push. By default this is the currently checked out branch.
2443
+ * @param {string} [args.url] - The URL of the remote repository. The default is the value set in the git config for that remote.
2444
+ * @param {string} [args.remote] - If URL is not specified, determines which remote to use.
2445
+ * @param {string} [args.remoteRef] - The name of the receiving branch on the remote. By default this is the configured remote tracking branch.
2446
+ * @param {boolean} [args.force = false] - If true, behaves the same as `git push --force`
2447
+ * @param {boolean} [args.delete = false] - If true, delete the remote ref
2448
+ * @param {string} [args.corsProxy] - Optional [CORS proxy](https://www.npmjs.com/%40isomorphic-git/cors-proxy). Overrides value in repo config.
2449
+ * @param {Object<string, string>} [args.headers] - Additional headers to include in HTTP requests, similar to git's `extraHeader` config
2450
+ * @param {object} [args.cache] - a [cache](cache.md) object
2451
+ *
2452
+ * @returns {Promise<PushResult>} Resolves successfully when push completes with a detailed description of the operation from the server.
2453
+ * @see PushResult
2454
+ * @see RefUpdateStatus
2455
+ *
2456
+ * @example
2457
+ * let pushResult = await git.push({
2458
+ * fs,
2459
+ * http,
2460
+ * dir: '/tutorial',
2461
+ * remote: 'origin',
2462
+ * ref: 'main',
2463
+ * onAuth: () => ({ username: process.env.GITHUB_TOKEN }),
2464
+ * })
2465
+ * console.log(pushResult)
2466
+ *
2467
+ */
2468
+ export function push({ fs, http, onProgress, onMessage, onAuth, onAuthSuccess, onAuthFailure, onPrePush, dir, gitdir, ref, remoteRef, remote, url, force, delete: _delete, corsProxy, headers, cache, }: {
2469
+ fs: FsClient;
2470
+ http: HttpClient;
2471
+ onProgress?: ProgressCallback | undefined;
2472
+ onMessage?: MessageCallback | undefined;
2473
+ onAuth?: AuthCallback | undefined;
2474
+ onAuthFailure?: AuthFailureCallback | undefined;
2475
+ onAuthSuccess?: AuthSuccessCallback | undefined;
2476
+ onPrePush?: PrePushCallback | undefined;
2477
+ dir?: string | undefined;
2478
+ gitdir?: string | undefined;
2479
+ ref?: string | undefined;
2480
+ url?: string | undefined;
2481
+ remote?: string | undefined;
2482
+ remoteRef?: string | undefined;
2483
+ force?: boolean | undefined;
2484
+ delete?: boolean | undefined;
2485
+ corsProxy?: string | undefined;
2486
+ headers?: {
2487
+ [x: string]: string;
2488
+ } | undefined;
2489
+ cache?: object;
2490
+ }): Promise<PushResult>;
2491
+ /**
2492
+ *
2493
+ * @typedef {Object} ReadBlobResult - The object returned has the following schema:
2494
+ * @property {string} oid
2495
+ * @property {Uint8Array} blob
2496
+ *
2497
+ */
2498
+ /**
2499
+ * Read a blob object directly
2500
+ *
2501
+ * @param {object} args
2502
+ * @param {FsClient} args.fs - a file system client
2503
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2504
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2505
+ * @param {string} args.oid - The SHA-1 object id to get. Annotated tags, commits, and trees are peeled.
2506
+ * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the blob object at that filepath.
2507
+ * @param {object} [args.cache] - a [cache](cache.md) object
2508
+ *
2509
+ * @returns {Promise<ReadBlobResult>} Resolves successfully with a blob object description
2510
+ * @see ReadBlobResult
2511
+ *
2512
+ * @example
2513
+ * // Get the contents of 'README.md' in the main branch.
2514
+ * let commitOid = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })
2515
+ * console.log(commitOid)
2516
+ * let { blob } = await git.readBlob({
2517
+ * fs,
2518
+ * dir: '/tutorial',
2519
+ * oid: commitOid,
2520
+ * filepath: 'README.md'
2521
+ * })
2522
+ * console.log(Buffer.from(blob).toString('utf8'))
2523
+ *
2524
+ */
2525
+ export function readBlob({ fs, dir, gitdir, oid, filepath, cache, }: {
2526
+ fs: FsClient;
2527
+ dir?: string | undefined;
2528
+ gitdir?: string | undefined;
2529
+ oid: string;
2530
+ filepath?: string | undefined;
2531
+ cache?: object;
2532
+ }): Promise<ReadBlobResult>;
2533
+ /**
2534
+ * Read a commit object directly
2535
+ *
2536
+ * @param {object} args
2537
+ * @param {FsClient} args.fs - a file system client
2538
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2539
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2540
+ * @param {string} args.oid - The SHA-1 object id to get. Annotated tags are peeled.
2541
+ * @param {object} [args.cache] - a [cache](cache.md) object
2542
+ *
2543
+ * @returns {Promise<ReadCommitResult>} Resolves successfully with a git commit object
2544
+ * @see ReadCommitResult
2545
+ * @see CommitObject
2546
+ *
2547
+ * @example
2548
+ * // Read a commit object
2549
+ * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })
2550
+ * console.log(sha)
2551
+ * let commit = await git.readCommit({ fs, dir: '/tutorial', oid: sha })
2552
+ * console.log(commit)
2553
+ *
2554
+ */
2555
+ export function readCommit({ fs, dir, gitdir, oid, cache, }: {
2556
+ fs: FsClient;
2557
+ dir?: string | undefined;
2558
+ gitdir?: string | undefined;
2559
+ oid: string;
2560
+ cache?: object;
2561
+ }): Promise<ReadCommitResult>;
2562
+ /**
2563
+ * Read the contents of a note
2564
+ *
2565
+ * @param {object} args
2566
+ * @param {FsClient} args.fs - a file system client
2567
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2568
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2569
+ * @param {string} [args.ref] - The notes ref to look under
2570
+ * @param {string} args.oid - The SHA-1 object id of the object to get the note for.
2571
+ * @param {object} [args.cache] - a [cache](cache.md) object
2572
+ *
2573
+ * @returns {Promise<Uint8Array>} Resolves successfully with note contents as a Buffer.
2574
+ */
2575
+ export function readNote({ fs, dir, gitdir, ref, oid, cache, }: {
2576
+ fs: FsClient;
2577
+ dir?: string | undefined;
2578
+ gitdir?: string | undefined;
2579
+ ref?: string | undefined;
2580
+ oid: string;
2581
+ cache?: object;
2582
+ }): Promise<Uint8Array>;
2583
+ /**
2584
+ *
2585
+ * @typedef {Object} DeflatedObject
2586
+ * @property {string} oid
2587
+ * @property {'deflated'} type
2588
+ * @property {'deflated'} format
2589
+ * @property {Uint8Array} object
2590
+ * @property {string} [source]
2591
+ *
2592
+ */
2593
+ /**
2594
+ *
2595
+ * @typedef {Object} WrappedObject
2596
+ * @property {string} oid
2597
+ * @property {'wrapped'} type
2598
+ * @property {'wrapped'} format
2599
+ * @property {Uint8Array} object
2600
+ * @property {string} [source]
2601
+ *
2602
+ */
2603
+ /**
2604
+ *
2605
+ * @typedef {Object} RawObject
2606
+ * @property {string} oid
2607
+ * @property {'blob'|'commit'|'tree'|'tag'} type
2608
+ * @property {'content'} format
2609
+ * @property {Uint8Array} object
2610
+ * @property {string} [source]
2611
+ *
2612
+ */
2613
+ /**
2614
+ *
2615
+ * @typedef {Object} ParsedBlobObject
2616
+ * @property {string} oid
2617
+ * @property {'blob'} type
2618
+ * @property {'parsed'} format
2619
+ * @property {string} object
2620
+ * @property {string} [source]
2621
+ *
2622
+ */
2623
+ /**
2624
+ *
2625
+ * @typedef {Object} ParsedCommitObject
2626
+ * @property {string} oid
2627
+ * @property {'commit'} type
2628
+ * @property {'parsed'} format
2629
+ * @property {CommitObject} object
2630
+ * @property {string} [source]
2631
+ *
2632
+ */
2633
+ /**
2634
+ *
2635
+ * @typedef {Object} ParsedTreeObject
2636
+ * @property {string} oid
2637
+ * @property {'tree'} type
2638
+ * @property {'parsed'} format
2639
+ * @property {TreeObject} object
2640
+ * @property {string} [source]
2641
+ *
2642
+ */
2643
+ /**
2644
+ *
2645
+ * @typedef {Object} ParsedTagObject
2646
+ * @property {string} oid
2647
+ * @property {'tag'} type
2648
+ * @property {'parsed'} format
2649
+ * @property {TagObject} object
2650
+ * @property {string} [source]
2651
+ *
2652
+ */
2653
+ /**
2654
+ *
2655
+ * @typedef {ParsedBlobObject | ParsedCommitObject | ParsedTreeObject | ParsedTagObject} ParsedObject
2656
+ */
2657
+ /**
2658
+ *
2659
+ * @typedef {DeflatedObject | WrappedObject | RawObject | ParsedObject } ReadObjectResult
2660
+ */
2661
+ /**
2662
+ * Read a git object directly by its SHA-1 object id
2663
+ *
2664
+ * Regarding `ReadObjectResult`:
2665
+ *
2666
+ * - `oid` will be the same as the `oid` argument unless the `filepath` argument is provided, in which case it will be the oid of the tree or blob being returned.
2667
+ * - `type` of deflated objects is `'deflated'`, and `type` of wrapped objects is `'wrapped'`
2668
+ * - `format` is usually, but not always, the format you requested. Packfiles do not store each object individually compressed so if you end up reading the object from a packfile it will be returned in format 'content' even if you requested 'deflated' or 'wrapped'.
2669
+ * - `object` will be an actual Object if format is 'parsed' and the object is a commit, tree, or annotated tag. Blobs are still formatted as Buffers unless an encoding is provided in which case they'll be strings. If format is anything other than 'parsed', object will be a Buffer.
2670
+ * - `source` is the name of the packfile or loose object file where the object was found.
2671
+ *
2672
+ * The `format` parameter can have the following values:
2673
+ *
2674
+ * | param | description |
2675
+ * | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2676
+ * | 'deflated' | Return the raw deflate-compressed buffer for an object if possible. Useful for efficiently shuffling around loose objects when you don't care about the contents and can save time by not inflating them. |
2677
+ * | 'wrapped' | Return the inflated object buffer wrapped in the git object header if possible. This is the raw data used when calculating the SHA-1 object id of a git object. |
2678
+ * | 'content' | Return the object buffer without the git header. |
2679
+ * | 'parsed' | Returns a parsed representation of the object. |
2680
+ *
2681
+ * The result will be in one of the following schemas:
2682
+ *
2683
+ * ## `'deflated'` format
2684
+ *
2685
+ * {@link DeflatedObject typedef}
2686
+ *
2687
+ * ## `'wrapped'` format
2688
+ *
2689
+ * {@link WrappedObject typedef}
2690
+ *
2691
+ * ## `'content'` format
2692
+ *
2693
+ * {@link RawObject typedef}
2694
+ *
2695
+ * ## `'parsed'` format
2696
+ *
2697
+ * ### parsed `'blob'` type
2698
+ *
2699
+ * {@link ParsedBlobObject typedef}
2700
+ *
2701
+ * ### parsed `'commit'` type
2702
+ *
2703
+ * {@link ParsedCommitObject typedef}
2704
+ * {@link CommitObject typedef}
2705
+ *
2706
+ * ### parsed `'tree'` type
2707
+ *
2708
+ * {@link ParsedTreeObject typedef}
2709
+ * {@link TreeObject typedef}
2710
+ * {@link TreeEntry typedef}
2711
+ *
2712
+ * ### parsed `'tag'` type
2713
+ *
2714
+ * {@link ParsedTagObject typedef}
2715
+ * {@link TagObject typedef}
2716
+ *
2717
+ * @deprecated
2718
+ * > This command is overly complicated.
2719
+ * >
2720
+ * > If you know the type of object you are reading, use [`readBlob`](./readBlob.md), [`readCommit`](./readCommit.md), [`readTag`](./readTag.md), or [`readTree`](./readTree.md).
2721
+ *
2722
+ * @param {object} args
2723
+ * @param {FsClient} args.fs - a file system client
2724
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2725
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2726
+ * @param {string} args.oid - The SHA-1 object id to get
2727
+ * @param {'deflated' | 'wrapped' | 'content' | 'parsed'} [args.format = 'parsed'] - What format to return the object in. The choices are described in more detail below.
2728
+ * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the object at that filepath. To return the root directory of a tree set filepath to `''`
2729
+ * @param {string} [args.encoding] - A convenience argument that only affects blobs. Instead of returning `object` as a buffer, it returns a string parsed using the given encoding.
2730
+ * @param {object} [args.cache] - a [cache](cache.md) object
2731
+ *
2732
+ * @returns {Promise<ReadObjectResult>} Resolves successfully with a git object description
2733
+ * @see ReadObjectResult
2734
+ *
2735
+ * @example
2736
+ * // Given a ransom SHA-1 object id, figure out what it is
2737
+ * let { type, object } = await git.readObject({
2738
+ * fs,
2739
+ * dir: '/tutorial',
2740
+ * oid: '0698a781a02264a6f37ba3ff41d78067eaf0f075'
2741
+ * })
2742
+ * switch (type) {
2743
+ * case 'commit': {
2744
+ * console.log(object)
2745
+ * break
2746
+ * }
2747
+ * case 'tree': {
2748
+ * console.log(object)
2749
+ * break
2750
+ * }
2751
+ * case 'blob': {
2752
+ * console.log(object)
2753
+ * break
2754
+ * }
2755
+ * case 'tag': {
2756
+ * console.log(object)
2757
+ * break
2758
+ * }
2759
+ * }
2760
+ *
2761
+ */
2762
+ export function readObject({ fs: _fs, dir, gitdir, oid, format, filepath, encoding, cache, }: {
2763
+ fs: FsClient;
2764
+ dir?: string | undefined;
2765
+ gitdir?: string | undefined;
2766
+ oid: string;
2767
+ format?: "content" | "parsed" | "deflated" | "wrapped" | undefined;
2768
+ filepath?: string | undefined;
2769
+ encoding?: string | undefined;
2770
+ cache?: object;
2771
+ }): Promise<ReadObjectResult>;
2772
+ /**
2773
+ *
2774
+ * @typedef {Object} ReadTagResult - The object returned has the following schema:
2775
+ * @property {string} oid - SHA-1 object id of this tag
2776
+ * @property {TagObject} tag - the parsed tag object
2777
+ * @property {string} payload - PGP signing payload
2778
+ */
2779
+ /**
2780
+ * Read an annotated tag object directly
2781
+ *
2782
+ * @param {object} args
2783
+ * @param {FsClient} args.fs - a file system client
2784
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2785
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2786
+ * @param {string} args.oid - The SHA-1 object id to get
2787
+ * @param {object} [args.cache] - a [cache](cache.md) object
2788
+ *
2789
+ * @returns {Promise<ReadTagResult>} Resolves successfully with a git object description
2790
+ * @see ReadTagResult
2791
+ * @see TagObject
2792
+ *
2793
+ */
2794
+ export function readTag({ fs, dir, gitdir, oid, cache, }: {
2795
+ fs: FsClient;
2796
+ dir?: string | undefined;
2797
+ gitdir?: string | undefined;
2798
+ oid: string;
2799
+ cache?: object;
2800
+ }): Promise<ReadTagResult>;
2801
+ /**
2802
+ *
2803
+ * @typedef {Object} ReadTreeResult - The object returned has the following schema:
2804
+ * @property {string} oid - SHA-1 object id of this tree
2805
+ * @property {TreeObject} tree - the parsed tree object
2806
+ */
2807
+ /**
2808
+ * Read a tree object directly
2809
+ *
2810
+ * @param {object} args
2811
+ * @param {FsClient} args.fs - a file system client
2812
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2813
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2814
+ * @param {string} args.oid - The SHA-1 object id to get. Annotated tags and commits are peeled.
2815
+ * @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the tree object at that filepath.
2816
+ * @param {object} [args.cache] - a [cache](cache.md) object
2817
+ *
2818
+ * @returns {Promise<ReadTreeResult>} Resolves successfully with a git tree object
2819
+ * @see ReadTreeResult
2820
+ * @see TreeObject
2821
+ * @see TreeEntry
2822
+ *
2823
+ */
2824
+ export function readTree({ fs, dir, gitdir, oid, filepath, cache, }: {
2825
+ fs: FsClient;
2826
+ dir?: string | undefined;
2827
+ gitdir?: string | undefined;
2828
+ oid: string;
2829
+ filepath?: string | undefined;
2830
+ cache?: object;
2831
+ }): Promise<ReadTreeResult>;
2832
+ /**
2833
+ * Remove a file from the git index (aka staging area)
2834
+ *
2835
+ * Note that this does NOT delete the file in the working directory.
2836
+ *
2837
+ * @param {object} args
2838
+ * @param {FsClient} args.fs - a file system client
2839
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2840
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2841
+ * @param {string} args.filepath - The path to the file to remove from the index
2842
+ * @param {object} [args.cache] - a [cache](cache.md) object
2843
+ *
2844
+ * @returns {Promise<void>} Resolves successfully once the git index has been updated
2845
+ *
2846
+ * @example
2847
+ * await git.remove({ fs, dir: '/tutorial', filepath: 'README.md' })
2848
+ * console.log('done')
2849
+ *
2850
+ */
2851
+ export function remove({ fs: _fs, dir, gitdir, filepath, cache, }: {
2852
+ fs: FsClient;
2853
+ dir?: string | undefined;
2854
+ gitdir?: string | undefined;
2855
+ filepath: string;
2856
+ cache?: object;
2857
+ }): Promise<void>;
2858
+ /**
2859
+ * Remove an object note
2860
+ *
2861
+ * @param {object} args
2862
+ * @param {FsClient} args.fs - a file system client
2863
+ * @param {SignCallback} [args.onSign] - a PGP signing implementation
2864
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2865
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2866
+ * @param {string} [args.ref] - The notes ref to look under
2867
+ * @param {string} args.oid - The SHA-1 object id of the object to remove the note from.
2868
+ * @param {Object} [args.author] - The details about the author.
2869
+ * @param {string} [args.author.name] - Default is `user.name` config.
2870
+ * @param {string} [args.author.email] - Default is `user.email` config.
2871
+ * @param {number} [args.author.timestamp=Math.floor(Date.now()/1000)] - Set the author timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2872
+ * @param {number} [args.author.timezoneOffset] - Set the author timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2873
+ * @param {Object} [args.committer = author] - The details about the note committer, in the same format as the author parameter. If not specified, the author details are used.
2874
+ * @param {string} [args.committer.name] - Default is `user.name` config.
2875
+ * @param {string} [args.committer.email] - Default is `user.email` config.
2876
+ * @param {number} [args.committer.timestamp=Math.floor(Date.now()/1000)] - Set the committer timestamp field. This is the integer number of seconds since the Unix epoch (1970-01-01 00:00:00).
2877
+ * @param {number} [args.committer.timezoneOffset] - Set the committer timezone offset field. This is the difference, in minutes, from the current timezone to UTC. Default is `(new Date()).getTimezoneOffset()`.
2878
+ * @param {string} [args.signingKey] - Sign the tag object using this private PGP key.
2879
+ * @param {object} [args.cache] - a [cache](cache.md) object
2880
+ *
2881
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the commit object for the note removal.
2882
+ */
2883
+ export function removeNote({ fs: _fs, onSign, dir, gitdir, ref, oid, author: _author, committer: _committer, signingKey, cache, }: {
2884
+ fs: FsClient;
2885
+ onSign?: SignCallback | undefined;
2886
+ dir?: string | undefined;
2887
+ gitdir?: string | undefined;
2888
+ ref?: string | undefined;
2889
+ oid: string;
2890
+ author?: {
2891
+ name?: string | undefined;
2892
+ email?: string | undefined;
2893
+ timestamp?: number | undefined;
2894
+ timezoneOffset?: number | undefined;
2895
+ } | undefined;
2896
+ committer?: {
2897
+ name?: string | undefined;
2898
+ email?: string | undefined;
2899
+ timestamp?: number | undefined;
2900
+ timezoneOffset?: number | undefined;
2901
+ } | undefined;
2902
+ signingKey?: string | undefined;
2903
+ cache?: object;
2904
+ }): Promise<string>;
2905
+ /**
2906
+ * Rename a branch
2907
+ *
2908
+ * @param {object} args
2909
+ * @param {FsClient} args.fs - a file system implementation
2910
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2911
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2912
+ * @param {string} args.ref - What to name the branch
2913
+ * @param {string} args.oldref - What the name of the branch was
2914
+ * @param {boolean} [args.checkout = false] - Update `HEAD` to point at the newly created branch
2915
+ *
2916
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
2917
+ *
2918
+ * @example
2919
+ * await git.renameBranch({ fs, dir: '/tutorial', ref: 'main', oldref: 'master' })
2920
+ * console.log('done')
2921
+ *
2922
+ */
2923
+ export function renameBranch({ fs, dir, gitdir, ref, oldref, checkout, }: {
2924
+ fs: FsClient;
2925
+ dir?: string | undefined;
2926
+ gitdir?: string | undefined;
2927
+ ref: string;
2928
+ oldref: string;
2929
+ checkout?: boolean | undefined;
2930
+ }): Promise<void>;
2931
+ /**
2932
+ * Reset a file in the git index (aka staging area)
2933
+ *
2934
+ * Note that this does NOT modify the file in the working directory.
2935
+ *
2936
+ * @param {object} args
2937
+ * @param {FsClient} args.fs - a file system client
2938
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2939
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2940
+ * @param {string} args.filepath - The path to the file to reset in the index
2941
+ * @param {string} [args.ref = 'HEAD'] - A ref to the commit to use
2942
+ * @param {object} [args.cache] - a [cache](cache.md) object
2943
+ *
2944
+ * @returns {Promise<void>} Resolves successfully once the git index has been updated
2945
+ *
2946
+ * @example
2947
+ * await git.resetIndex({ fs, dir: '/tutorial', filepath: 'README.md' })
2948
+ * console.log('done')
2949
+ *
2950
+ */
2951
+ export function resetIndex({ fs: _fs, dir, gitdir, filepath, ref, cache, }: {
2952
+ fs: FsClient;
2953
+ dir?: string | undefined;
2954
+ gitdir?: string | undefined;
2955
+ filepath: string;
2956
+ ref?: string | undefined;
2957
+ cache?: object;
2958
+ }): Promise<void>;
2959
+ /**
2960
+ * Get the value of a symbolic ref or resolve a ref to its SHA-1 object id
2961
+ *
2962
+ * @param {object} args
2963
+ * @param {FsClient} args.fs - a file system client
2964
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2965
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2966
+ * @param {string} args.ref - The ref to resolve
2967
+ * @param {number} [args.depth = undefined] - How many symbolic references to follow before returning
2968
+ *
2969
+ * @returns {Promise<string>} Resolves successfully with a SHA-1 object id or the value of a symbolic ref
2970
+ *
2971
+ * @example
2972
+ * let currentCommit = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })
2973
+ * console.log(currentCommit)
2974
+ * let currentBranch = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD', depth: 2 })
2975
+ * console.log(currentBranch)
2976
+ *
2977
+ */
2978
+ export function resolveRef({ fs, dir, gitdir, ref, depth, }: {
2979
+ fs: FsClient;
2980
+ dir?: string | undefined;
2981
+ gitdir?: string | undefined;
2982
+ ref: string;
2983
+ depth?: number | undefined;
2984
+ }): Promise<string>;
2985
+ /**
2986
+ * Write an entry to the git config files.
2987
+ *
2988
+ * *Caveats:*
2989
+ * - Currently only the local `$GIT_DIR/config` file can be read or written. However support for the global `~/.gitconfig` and system `$(prefix)/etc/gitconfig` will be added in the future.
2990
+ * - The current parser does not support the more exotic features of the git-config file format such as `[include]` and `[includeIf]`.
2991
+ *
2992
+ * @param {Object} args
2993
+ * @param {FsClient} args.fs - a file system implementation
2994
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
2995
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
2996
+ * @param {string} args.path - The key of the git config entry
2997
+ * @param {string | boolean | number | void} args.value - A value to store at that path. (Use `undefined` as the value to delete a config entry.)
2998
+ * @param {boolean} [args.append = false] - If true, will append rather than replace when setting (use with multi-valued config options).
2999
+ *
3000
+ * @returns {Promise<void>} Resolves successfully when operation completed
3001
+ *
3002
+ * @example
3003
+ * // Write config value
3004
+ * await git.setConfig({
3005
+ * fs,
3006
+ * dir: '/tutorial',
3007
+ * path: 'user.name',
3008
+ * value: 'Mr. Test'
3009
+ * })
3010
+ *
3011
+ * // Print out config file
3012
+ * let file = await fs.promises.readFile('/tutorial/.git/config', 'utf8')
3013
+ * console.log(file)
3014
+ *
3015
+ * // Delete a config entry
3016
+ * await git.setConfig({
3017
+ * fs,
3018
+ * dir: '/tutorial',
3019
+ * path: 'user.name',
3020
+ * value: undefined
3021
+ * })
3022
+ *
3023
+ * // Print out config file
3024
+ * file = await fs.promises.readFile('/tutorial/.git/config', 'utf8')
3025
+ * console.log(file)
3026
+ */
3027
+ export function setConfig({ fs: _fs, dir, gitdir, path, value, append, }: {
3028
+ fs: FsClient;
3029
+ dir?: string | undefined;
3030
+ gitdir?: string | undefined;
3031
+ path: string;
3032
+ value: string | boolean | number | void;
3033
+ append?: boolean | undefined;
3034
+ }): Promise<void>;
3035
+ /**
3036
+ * stash api, supports {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} StashOp
3037
+ * _note_,
3038
+ * - all stash operations are done on tracked files only with loose objects, no packed objects
3039
+ * - when op === 'push', both working directory and index (staged) changes will be stashed, tracked files only
3040
+ * - when op === 'push', message is optional, and only applicable when op === 'push'
3041
+ * - when op === 'apply | pop', the stashed changes will overwrite the working directory, no abort when conflicts
3042
+ *
3043
+ * @param {object} args
3044
+ * @param {FsClient} args.fs - [required] a file system client
3045
+ * @param {string} [args.dir] - [required] The [working tree](dir-vs-gitdir.md) directory path
3046
+ * @param {string} [args.gitdir=join(dir,'.git')] - [optional] The [git directory](dir-vs-gitdir.md) path
3047
+ * @param {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} [args.op = 'push'] - [optional] name of stash operation, default to 'push'
3048
+ * @param {string} [args.message = ''] - [optional] message to be used for the stash entry, only applicable when op === 'push'
3049
+ * @param {number} [args.refIdx = 0] - [optional - Number] stash ref index of entry, only applicable when op === ['apply' | 'drop' | 'pop'], refIdx >= 0 and < num of stash pushed
3050
+ * @returns {Promise<string | void>} Resolves successfully when stash operations are complete
3051
+ *
3052
+ * @example
3053
+ * // stash changes in the working directory and index
3054
+ * let dir = '/tutorial'
3055
+ * await fs.promises.writeFile(`${dir}/a.txt`, 'original content - a')
3056
+ * await fs.promises.writeFile(`${dir}/b.js`, 'original content - b')
3057
+ * await git.add({ fs, dir, filepath: [`a.txt`,`b.txt`] })
3058
+ * let sha = await git.commit({
3059
+ * fs,
3060
+ * dir,
3061
+ * author: {
3062
+ * name: 'Mr. Stash',
3063
+ * email: 'mstasher@stash.com',
3064
+ * },
3065
+ * message: 'add a.txt and b.txt to test stash'
3066
+ * })
3067
+ * console.log(sha)
3068
+ *
3069
+ * await fs.promises.writeFile(`${dir}/a.txt`, 'stashed chang- a')
3070
+ * await git.add({ fs, dir, filepath: `${dir}/a.txt` })
3071
+ * await fs.promises.writeFile(`${dir}/b.js`, 'work dir change. not stashed - b')
3072
+ *
3073
+ * await git.stash({ fs, dir }) // default gitdir and op
3074
+ *
3075
+ * console.log(await git.status({ fs, dir, filepath: 'a.txt' })) // 'unmodified'
3076
+ * console.log(await git.status({ fs, dir, filepath: 'b.txt' })) // 'unmodified'
3077
+ *
3078
+ * const refLog = await git.stash({ fs, dir, op: 'list' })
3079
+ * console.log(refLog) // [{stash{#} message}]
3080
+ *
3081
+ * await git.stash({ fs, dir, op: 'apply' }) // apply the stash
3082
+ *
3083
+ * console.log(await git.status({ fs, dir, filepath: 'a.txt' })) // 'modified'
3084
+ * console.log(await git.status({ fs, dir, filepath: 'b.txt' })) // '*modified'
3085
+ */
3086
+ export function stash({ fs, dir, gitdir, op, message, refIdx, }: {
3087
+ fs: FsClient;
3088
+ dir?: string | undefined;
3089
+ gitdir?: string | undefined;
3090
+ op?: "pop" | "push" | "clear" | "drop" | "apply" | "list" | undefined;
3091
+ message?: string | undefined;
3092
+ refIdx?: number | undefined;
3093
+ }): Promise<string | void>;
3094
+ /**
3095
+ * Tell whether a file has been changed
3096
+ *
3097
+ * The possible resolve values are:
3098
+ *
3099
+ * | status | description |
3100
+ * | --------------------- | ------------------------------------------------------------------------------------- |
3101
+ * | `"ignored"` | file ignored by a .gitignore rule |
3102
+ * | `"unmodified"` | file unchanged from HEAD commit |
3103
+ * | `"*modified"` | file has modifications, not yet staged |
3104
+ * | `"*deleted"` | file has been removed, but the removal is not yet staged |
3105
+ * | `"*added"` | file is untracked, not yet staged |
3106
+ * | `"absent"` | file not present in HEAD commit, staging area, or working dir |
3107
+ * | `"modified"` | file has modifications, staged |
3108
+ * | `"deleted"` | file has been removed, staged |
3109
+ * | `"added"` | previously untracked file, staged |
3110
+ * | `"*unmodified"` | working dir and HEAD commit match, but index differs |
3111
+ * | `"*absent"` | file not present in working dir or HEAD commit, but present in the index |
3112
+ * | `"*undeleted"` | file was deleted from the index, but is still in the working dir |
3113
+ * | `"*undeletemodified"` | file was deleted from the index, but is present with modifications in the working dir |
3114
+ *
3115
+ * @param {object} args
3116
+ * @param {FsClient} args.fs - a file system client
3117
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
3118
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3119
+ * @param {string} args.filepath - The path to the file to query
3120
+ * @param {object} [args.cache] - a [cache](cache.md) object
3121
+ *
3122
+ * @returns {Promise<'ignored'|'unmodified'|'*modified'|'*deleted'|'*added'|'absent'|'modified'|'deleted'|'added'|'*unmodified'|'*absent'|'*undeleted'|'*undeletemodified'>} Resolves successfully with the file's git status
3123
+ *
3124
+ * @example
3125
+ * let status = await git.status({ fs, dir: '/tutorial', filepath: 'README.md' })
3126
+ * console.log(status)
3127
+ *
3128
+ */
3129
+ export function status({ fs: _fs, dir, gitdir, filepath, cache, }: {
3130
+ fs: FsClient;
3131
+ dir: string;
3132
+ gitdir?: string | undefined;
3133
+ filepath: string;
3134
+ cache?: object;
3135
+ }): Promise<"ignored" | "unmodified" | "*modified" | "*deleted" | "*added" | "absent" | "modified" | "deleted" | "added" | "*unmodified" | "*absent" | "*undeleted" | "*undeletemodified">;
3136
+ /**
3137
+ * Efficiently get the status of multiple files at once.
3138
+ *
3139
+ * The returned `StatusMatrix` is admittedly not the easiest format to read.
3140
+ * However it conveys a large amount of information in dense format that should make it easy to create reports about the current state of the repository;
3141
+ * without having to do multiple, time-consuming isomorphic-git calls.
3142
+ * My hope is that the speed and flexibility of the function will make up for the learning curve of interpreting the return value.
3143
+ *
3144
+ * ```js live
3145
+ * // get the status of all the files in 'src'
3146
+ * let status = await git.statusMatrix({
3147
+ * fs,
3148
+ * dir: '/tutorial',
3149
+ * filter: f => f.startsWith('src/')
3150
+ * })
3151
+ * console.log(status)
3152
+ * ```
3153
+ *
3154
+ * ```js live
3155
+ * // get the status of all the JSON and Markdown files
3156
+ * let status = await git.statusMatrix({
3157
+ * fs,
3158
+ * dir: '/tutorial',
3159
+ * filter: f => f.endsWith('.json') || f.endsWith('.md')
3160
+ * })
3161
+ * console.log(status)
3162
+ * ```
3163
+ *
3164
+ * The result is returned as a 2D array.
3165
+ * The outer array represents the files and/or blobs in the repo, in alphabetical order.
3166
+ * The inner arrays describe the status of the file:
3167
+ * the first value is the filepath, and the next three are integers
3168
+ * representing the HEAD status, WORKDIR status, and STAGE status of the entry.
3169
+ *
3170
+ * ```js
3171
+ * // example StatusMatrix
3172
+ * [
3173
+ * ["a.txt", 0, 2, 0], // new, untracked
3174
+ * ["b.txt", 0, 2, 2], // added, staged
3175
+ * ["c.txt", 0, 2, 3], // added, staged, with unstaged changes
3176
+ * ["d.txt", 1, 1, 1], // unmodified
3177
+ * ["e.txt", 1, 2, 1], // modified, unstaged
3178
+ * ["f.txt", 1, 2, 2], // modified, staged
3179
+ * ["g.txt", 1, 2, 3], // modified, staged, with unstaged changes
3180
+ * ["h.txt", 1, 0, 1], // deleted, unstaged
3181
+ * ["i.txt", 1, 0, 0], // deleted, staged
3182
+ * ["j.txt", 1, 2, 0], // deleted, staged, with unstaged-modified changes (new file of the same name)
3183
+ * ["k.txt", 1, 1, 0], // deleted, staged, with unstaged changes (new file of the same name)
3184
+ * ]
3185
+ * ```
3186
+ *
3187
+ * - The HEAD status is either absent (0) or present (1).
3188
+ * - The WORKDIR status is either absent (0), identical to HEAD (1), or different from HEAD (2).
3189
+ * - The STAGE status is either absent (0), identical to HEAD (1), identical to WORKDIR (2), or different from WORKDIR (3).
3190
+ *
3191
+ * ```ts
3192
+ * type Filename = string
3193
+ * type HeadStatus = 0 | 1
3194
+ * type WorkdirStatus = 0 | 1 | 2
3195
+ * type StageStatus = 0 | 1 | 2 | 3
3196
+ *
3197
+ * type StatusRow = [Filename, HeadStatus, WorkdirStatus, StageStatus]
3198
+ *
3199
+ * type StatusMatrix = StatusRow[]
3200
+ * ```
3201
+ *
3202
+ * > Think of the natural progression of file modifications as being from HEAD (previous) -> WORKDIR (current) -> STAGE (next).
3203
+ * > Then HEAD is "version 1", WORKDIR is "version 2", and STAGE is "version 3".
3204
+ * > Then, imagine a "version 0" which is before the file was created.
3205
+ * > Then the status value in each column corresponds to the oldest version of the file it is identical to.
3206
+ * > (For a file to be identical to "version 0" means the file is deleted.)
3207
+ *
3208
+ * Here are some examples of queries you can answer using the result:
3209
+ *
3210
+ * #### Q: What files have been deleted?
3211
+ * ```js
3212
+ * const FILE = 0, WORKDIR = 2
3213
+ *
3214
+ * const filenames = (await statusMatrix({ dir }))
3215
+ * .filter(row => row[WORKDIR] === 0)
3216
+ * .map(row => row[FILE])
3217
+ * ```
3218
+ *
3219
+ * #### Q: What files have unstaged changes?
3220
+ * ```js
3221
+ * const FILE = 0, WORKDIR = 2, STAGE = 3
3222
+ *
3223
+ * const filenames = (await statusMatrix({ dir }))
3224
+ * .filter(row => row[WORKDIR] !== row[STAGE])
3225
+ * .map(row => row[FILE])
3226
+ * ```
3227
+ *
3228
+ * #### Q: What files have been modified since the last commit?
3229
+ * ```js
3230
+ * const FILE = 0, HEAD = 1, WORKDIR = 2
3231
+ *
3232
+ * const filenames = (await statusMatrix({ dir }))
3233
+ * .filter(row => row[HEAD] !== row[WORKDIR])
3234
+ * .map(row => row[FILE])
3235
+ * ```
3236
+ *
3237
+ * #### Q: What files will NOT be changed if I commit right now?
3238
+ * ```js
3239
+ * const FILE = 0, HEAD = 1, STAGE = 3
3240
+ *
3241
+ * const filenames = (await statusMatrix({ dir }))
3242
+ * .filter(row => row[HEAD] === row[STAGE])
3243
+ * .map(row => row[FILE])
3244
+ * ```
3245
+ *
3246
+ * For reference, here are all possible combinations:
3247
+ *
3248
+ * | HEAD | WORKDIR | STAGE | `git status --short` equivalent |
3249
+ * | ---- | ------- | ----- | ------------------------------- |
3250
+ * | 0 | 0 | 0 | `` |
3251
+ * | 0 | 0 | 3 | `AD` |
3252
+ * | 0 | 2 | 0 | `??` |
3253
+ * | 0 | 2 | 2 | `A ` |
3254
+ * | 0 | 2 | 3 | `AM` |
3255
+ * | 1 | 0 | 0 | `D ` |
3256
+ * | 1 | 0 | 1 | ` D` |
3257
+ * | 1 | 0 | 3 | `MD` |
3258
+ * | 1 | 1 | 0 | `D ` + `??` |
3259
+ * | 1 | 1 | 1 | `` |
3260
+ * | 1 | 1 | 3 | `MM` |
3261
+ * | 1 | 2 | 0 | `D ` + `??` |
3262
+ * | 1 | 2 | 1 | ` M` |
3263
+ * | 1 | 2 | 2 | `M ` |
3264
+ * | 1 | 2 | 3 | `MM` |
3265
+ *
3266
+ * @param {object} args
3267
+ * @param {FsClient} args.fs - a file system client
3268
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
3269
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3270
+ * @param {string} [args.ref = 'HEAD'] - Optionally specify a different commit to compare against the workdir and stage instead of the HEAD
3271
+ * @param {string[]} [args.filepaths = ['.']] - Limit the query to the given files and directories
3272
+ * @param {function(string): boolean} [args.filter] - Filter the results to only those whose filepath matches a function.
3273
+ * @param {object} [args.cache] - a [cache](cache.md) object
3274
+ * @param {boolean} [args.ignored = false] - include ignored files in the result
3275
+ *
3276
+ * @returns {Promise<Array<StatusRow>>} Resolves with a status matrix, described below.
3277
+ * @see StatusRow
3278
+ */
3279
+ export function statusMatrix({ fs: _fs, dir, gitdir, ref, filepaths, filter, cache, ignored: shouldIgnore, }: {
3280
+ fs: FsClient;
3281
+ dir: string;
3282
+ gitdir?: string | undefined;
3283
+ ref?: string | undefined;
3284
+ filepaths?: string[] | undefined;
3285
+ filter?: ((arg0: string) => boolean) | undefined;
3286
+ cache?: object;
3287
+ ignored?: boolean | undefined;
3288
+ }): Promise<Array<StatusRow>>;
3289
+ /**
3290
+ * Create a lightweight tag
3291
+ *
3292
+ * @param {object} args
3293
+ * @param {FsClient} args.fs - a file system client
3294
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3295
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3296
+ * @param {string} args.ref - What to name the tag
3297
+ * @param {string} [args.object = 'HEAD'] - What oid the tag refers to. (Will resolve to oid if value is a ref.) By default, the commit object which is referred by the current `HEAD` is used.
3298
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a tag named `ref` already exists, overwrite the existing tag.
3299
+ *
3300
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
3301
+ *
3302
+ * @example
3303
+ * await git.tag({ fs, dir: '/tutorial', ref: 'test-tag' })
3304
+ * console.log('done')
3305
+ *
3306
+ */
3307
+ export function tag({ fs: _fs, dir, gitdir, ref, object, force, }: {
3308
+ fs: FsClient;
3309
+ dir?: string | undefined;
3310
+ gitdir?: string | undefined;
3311
+ ref: string;
3312
+ object?: string | undefined;
3313
+ force?: boolean | undefined;
3314
+ }): Promise<void>;
3315
+ /**
3316
+ * Register file contents in the working tree or object database to the git index (aka staging area).
3317
+ *
3318
+ * @param {object} args
3319
+ * @param {FsClient} args.fs - a file system client
3320
+ * @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
3321
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3322
+ * @param {string} args.filepath - File to act upon.
3323
+ * @param {string} [args.oid] - OID of the object in the object database to add to the index with the specified filepath.
3324
+ * @param {number} [args.mode = 100644] - The file mode to add the file to the index.
3325
+ * @param {boolean} [args.add] - Adds the specified file to the index if it does not yet exist in the index.
3326
+ * @param {boolean} [args.remove] - Remove the specified file from the index if it does not exist in the workspace anymore.
3327
+ * @param {boolean} [args.force] - Remove the specified file from the index, even if it still exists in the workspace.
3328
+ * @param {object} [args.cache] - a [cache](cache.md) object
3329
+ *
3330
+ * @returns {Promise<string | void>} Resolves successfully with the SHA-1 object id of the object written or updated in the index, or nothing if the file was removed.
3331
+ *
3332
+ * @example
3333
+ * await git.updateIndex({
3334
+ * fs,
3335
+ * dir: '/tutorial',
3336
+ * filepath: 'readme.md'
3337
+ * })
3338
+ *
3339
+ * @example
3340
+ * // Manually create a blob in the object database.
3341
+ * let oid = await git.writeBlob({
3342
+ * fs,
3343
+ * dir: '/tutorial',
3344
+ * blob: new Uint8Array([])
3345
+ * })
3346
+ *
3347
+ * // Write the object in the object database to the index.
3348
+ * await git.updateIndex({
3349
+ * fs,
3350
+ * dir: '/tutorial',
3351
+ * add: true,
3352
+ * filepath: 'readme.md',
3353
+ * oid
3354
+ * })
3355
+ */
3356
+ declare function updateIndex$1({ fs: _fs, dir, gitdir, cache, filepath, oid, mode, add, remove, force, }: {
3357
+ fs: FsClient;
3358
+ dir: string;
3359
+ gitdir?: string | undefined;
3360
+ filepath: string;
3361
+ oid?: string | undefined;
3362
+ mode?: number | undefined;
3363
+ add?: boolean | undefined;
3364
+ remove?: boolean | undefined;
3365
+ force?: boolean | undefined;
3366
+ cache?: object;
3367
+ }): Promise<string | void>;
3368
+ /**
3369
+ * Return the version number of isomorphic-git
3370
+ *
3371
+ * I don't know why you might need this. I added it just so I could check that I was getting
3372
+ * the correct version of the library and not a cached version.
3373
+ *
3374
+ * @returns {string} the version string taken from package.json at publication time
3375
+ *
3376
+ * @example
3377
+ * console.log(git.version())
3378
+ *
3379
+ */
3380
+ export function version(): string;
3381
+ /**
3382
+ * @callback WalkerMap
3383
+ * @param {string} filename
3384
+ * @param {Array<WalkerEntry | null>} entries
3385
+ * @returns {Promise<any>}
3386
+ */
3387
+ /**
3388
+ * @callback WalkerReduce
3389
+ * @param {any} parent
3390
+ * @param {any[]} children
3391
+ * @returns {Promise<any>}
3392
+ */
3393
+ /**
3394
+ * @callback WalkerIterateCallback
3395
+ * @param {WalkerEntry[]} entries
3396
+ * @returns {Promise<any[]>}
3397
+ */
3398
+ /**
3399
+ * @callback WalkerIterate
3400
+ * @param {WalkerIterateCallback} walk
3401
+ * @param {IterableIterator<WalkerEntry[]>} children
3402
+ * @returns {Promise<any[]>}
3403
+ */
3404
+ /**
3405
+ * A powerful recursive tree-walking utility.
3406
+ *
3407
+ * The `walk` API simplifies gathering detailed information about a tree or comparing all the filepaths in two or more trees.
3408
+ * Trees can be git commits, the working directory, or the or git index (staging area).
3409
+ * As long as a file or directory is present in at least one of the trees, it will be traversed.
3410
+ * Entries are traversed in alphabetical order.
3411
+ *
3412
+ * The arguments to `walk` are the `trees` you want to traverse, and 3 optional transform functions:
3413
+ * `map`, `reduce`, and `iterate`.
3414
+ *
3415
+ * ## `TREE`, `WORKDIR`, and `STAGE`
3416
+ *
3417
+ * Tree walkers are represented by three separate functions that can be imported:
3418
+ *
3419
+ * ```js
3420
+ * import { TREE, WORKDIR, STAGE } from 'isomorphic-git'
3421
+ * ```
3422
+ *
3423
+ * These functions return opaque handles called `Walker`s.
3424
+ * The only thing that `Walker` objects are good for is passing into `walk`.
3425
+ * Here are the three `Walker`s passed into `walk` by the `statusMatrix` command for example:
3426
+ *
3427
+ * ```js
3428
+ * let ref = 'HEAD'
3429
+ *
3430
+ * let trees = [TREE({ ref }), WORKDIR(), STAGE()]
3431
+ * ```
3432
+ *
3433
+ * For the arguments, see the doc pages for [TREE](./TREE.md), [WORKDIR](./WORKDIR.md), and [STAGE](./STAGE.md).
3434
+ *
3435
+ * `map`, `reduce`, and `iterate` allow you control the recursive walk by pruning and transforming `WalkerEntry`s into the desired result.
3436
+ *
3437
+ * ## WalkerEntry
3438
+ *
3439
+ * {@link WalkerEntry typedef}
3440
+ *
3441
+ * `map` receives an array of `WalkerEntry[]` as its main argument, one `WalkerEntry` for each `Walker` in the `trees` argument.
3442
+ * The methods are memoized per `WalkerEntry` so calling them multiple times in a `map` function does not adversely impact performance.
3443
+ * By only computing these values if needed, you build can build lean, mean, efficient walking machines.
3444
+ *
3445
+ * ### WalkerEntry#type()
3446
+ *
3447
+ * Returns the kind as a string. This is normally either `tree` or `blob`.
3448
+ *
3449
+ * `TREE`, `STAGE`, and `WORKDIR` walkers all return a string.
3450
+ *
3451
+ * Possible values:
3452
+ *
3453
+ * - `'tree'` directory
3454
+ * - `'blob'` file
3455
+ * - `'special'` used by `WORKDIR` to represent irregular files like sockets and FIFOs
3456
+ * - `'commit'` used by `TREE` to represent submodules
3457
+ *
3458
+ * ```js
3459
+ * await entry.type()
3460
+ * ```
3461
+ *
3462
+ * ### WalkerEntry#mode()
3463
+ *
3464
+ * Returns the file mode as a number. Use this to distinguish between regular files, symlinks, and executable files.
3465
+ *
3466
+ * `TREE`, `STAGE`, and `WORKDIR` walkers all return a number for all `type`s of entries.
3467
+ *
3468
+ * It has been normalized to one of the 4 values that are allowed in git commits:
3469
+ *
3470
+ * - `0o40000` directory
3471
+ * - `0o100644` file
3472
+ * - `0o100755` file (executable)
3473
+ * - `0o120000` symlink
3474
+ *
3475
+ * Tip: to make modes more readable, you can print them to octal using `.toString(8)`.
3476
+ *
3477
+ * ```js
3478
+ * await entry.mode()
3479
+ * ```
3480
+ *
3481
+ * ### WalkerEntry#oid()
3482
+ *
3483
+ * Returns the SHA-1 object id for blobs and trees.
3484
+ *
3485
+ * `TREE` walkers return a string for `blob` and `tree` entries.
3486
+ *
3487
+ * `STAGE` and `WORKDIR` walkers return a string for `blob` entries and `undefined` for `tree` entries.
3488
+ *
3489
+ * ```js
3490
+ * await entry.oid()
3491
+ * ```
3492
+ *
3493
+ * ### WalkerEntry#content()
3494
+ *
3495
+ * Returns the file contents as a Buffer.
3496
+ *
3497
+ * `TREE` and `WORKDIR` walkers return a Buffer for `blob` entries and `undefined` for `tree` entries.
3498
+ *
3499
+ * `STAGE` walkers always return `undefined` since the file contents are never stored in the stage.
3500
+ *
3501
+ * ```js
3502
+ * await entry.content()
3503
+ * ```
3504
+ *
3505
+ * ### WalkerEntry#stat()
3506
+ *
3507
+ * Returns a normalized subset of filesystem Stat data.
3508
+ *
3509
+ * `WORKDIR` walkers return a `Stat` for `blob` and `tree` entries.
3510
+ *
3511
+ * `STAGE` walkers return a `Stat` for `blob` entries and `undefined` for `tree` entries.
3512
+ *
3513
+ * `TREE` walkers return `undefined` for all entry types.
3514
+ *
3515
+ * ```js
3516
+ * await entry.stat()
3517
+ * ```
3518
+ *
3519
+ * {@link Stat typedef}
3520
+ *
3521
+ * ## map(string, Array<WalkerEntry|null>) => Promise<any>
3522
+ *
3523
+ * {@link WalkerMap typedef}
3524
+ *
3525
+ * This is the function that is called once per entry BEFORE visiting the children of that node.
3526
+ *
3527
+ * If you return `null` for a `tree` entry, then none of the children of that `tree` entry will be walked.
3528
+ *
3529
+ * This is a good place for query logic, such as examining the contents of a file.
3530
+ * Ultimately, compare all the entries and return any values you are interested in.
3531
+ * If you do not return a value (or return undefined) that entry will be filtered from the results.
3532
+ *
3533
+ * Example 1: Find all the files containing the word 'foo'.
3534
+ * ```js
3535
+ * async function map(filepath, [head, workdir]) {
3536
+ * let content = (await workdir.content()).toString('utf8')
3537
+ * if (content.contains('foo')) {
3538
+ * return {
3539
+ * filepath,
3540
+ * content
3541
+ * }
3542
+ * }
3543
+ * }
3544
+ * ```
3545
+ *
3546
+ * Example 2: Return the difference between the working directory and the HEAD commit
3547
+ * ```js
3548
+ * const map = async (filepath, [head, workdir]) => {
3549
+ * return {
3550
+ * filepath,
3551
+ * oid: await head?.oid(),
3552
+ * diff: diff(
3553
+ * (await head?.content())?.toString('utf8') || '',
3554
+ * (await workdir?.content())?.toString('utf8') || ''
3555
+ * )
3556
+ * }
3557
+ * }
3558
+ * ```
3559
+ *
3560
+ * Example 3:
3561
+ * ```js
3562
+ * let path = require('path')
3563
+ * // Only examine files in the directory `cwd`
3564
+ * let cwd = 'src/app'
3565
+ * async function map (filepath, [head, workdir, stage]) {
3566
+ * if (
3567
+ * // don't skip the root directory
3568
+ * head.fullpath !== '.' &&
3569
+ * // return true for 'src' and 'src/app'
3570
+ * !cwd.startsWith(filepath) &&
3571
+ * // return true for 'src/app/*'
3572
+ * path.dirname(filepath) !== cwd
3573
+ * ) {
3574
+ * return null
3575
+ * } else {
3576
+ * return filepath
3577
+ * }
3578
+ * }
3579
+ * ```
3580
+ *
3581
+ * ## reduce(parent, children)
3582
+ *
3583
+ * {@link WalkerReduce typedef}
3584
+ *
3585
+ * This is the function that is called once per entry AFTER visiting the children of that node.
3586
+ *
3587
+ * Default: `async (parent, children) => parent === undefined ? children.flat() : [parent, children].flat()`
3588
+ *
3589
+ * The default implementation of this function returns all directories and children in a giant flat array.
3590
+ * You can define a different accumulation method though.
3591
+ *
3592
+ * Example: Return a hierarchical structure
3593
+ * ```js
3594
+ * async function reduce (parent, children) {
3595
+ * return Object.assign(parent, { children })
3596
+ * }
3597
+ * ```
3598
+ *
3599
+ * ## iterate(walk, children)
3600
+ *
3601
+ * {@link WalkerIterate typedef}
3602
+ *
3603
+ * {@link WalkerIterateCallback typedef}
3604
+ *
3605
+ * Default: `(walk, children) => Promise.all([...children].map(walk))`
3606
+ *
3607
+ * The default implementation recurses all children concurrently using Promise.all.
3608
+ * However you could use a custom function to traverse children serially or use a global queue to throttle recursion.
3609
+ *
3610
+ * @param {object} args
3611
+ * @param {FsClient} args.fs - a file system client
3612
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3613
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3614
+ * @param {Walker[]} args.trees - The trees you want to traverse
3615
+ * @param {WalkerMap} [args.map] - Transform `WalkerEntry`s into a result form
3616
+ * @param {WalkerReduce} [args.reduce] - Control how mapped entries are combined with their parent result
3617
+ * @param {WalkerIterate} [args.iterate] - Fine-tune how entries within a tree are iterated over
3618
+ * @param {object} [args.cache] - a [cache](cache.md) object
3619
+ *
3620
+ * @returns {Promise<any>} The finished tree-walking result
3621
+ */
3622
+ export function walk({ fs, dir, gitdir, trees, map, reduce, iterate, cache, }: {
3623
+ fs: FsClient;
3624
+ dir?: string | undefined;
3625
+ gitdir?: string | undefined;
3626
+ trees: Walker[];
3627
+ map?: WalkerMap | undefined;
3628
+ reduce?: WalkerReduce | undefined;
3629
+ iterate?: WalkerIterate | undefined;
3630
+ cache?: object;
3631
+ }): Promise<any>;
3632
+ /**
3633
+ * Write a blob object directly
3634
+ *
3635
+ * @param {object} args
3636
+ * @param {FsClient} args.fs - a file system client
3637
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3638
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3639
+ * @param {Uint8Array} args.blob - The blob object to write
3640
+ *
3641
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object
3642
+ *
3643
+ * @example
3644
+ * // Manually create a blob.
3645
+ * let oid = await git.writeBlob({
3646
+ * fs,
3647
+ * dir: '/tutorial',
3648
+ * blob: new Uint8Array([])
3649
+ * })
3650
+ *
3651
+ * console.log('oid', oid) // should be 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'
3652
+ *
3653
+ */
3654
+ export function writeBlob({ fs, dir, gitdir, blob }: {
3655
+ fs: FsClient;
3656
+ dir?: string | undefined;
3657
+ gitdir?: string | undefined;
3658
+ blob: Uint8Array;
3659
+ }): Promise<string>;
3660
+ /**
3661
+ * Write a commit object directly
3662
+ *
3663
+ * @param {object} args
3664
+ * @param {FsClient} args.fs - a file system client
3665
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3666
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3667
+ * @param {CommitObject} args.commit - The object to write
3668
+ *
3669
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object
3670
+ * @see CommitObject
3671
+ *
3672
+ */
3673
+ export function writeCommit({ fs, dir, gitdir, commit, }: {
3674
+ fs: FsClient;
3675
+ dir?: string | undefined;
3676
+ gitdir?: string | undefined;
3677
+ commit: CommitObject;
3678
+ }): Promise<string>;
3679
+ /**
3680
+ * Write a git object directly
3681
+ *
3682
+ * `format` can have the following values:
3683
+ *
3684
+ * | param | description |
3685
+ * | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3686
+ * | 'deflated' | Treat `object` as the raw deflate-compressed buffer for an object, meaning can be written to `.git/objects/**` as-is. |
3687
+ * | 'wrapped' | Treat `object` as the inflated object buffer wrapped in the git object header. This is the raw buffer used when calculating the SHA-1 object id of a git object. |
3688
+ * | 'content' | Treat `object` as the object buffer without the git header. |
3689
+ * | 'parsed' | Treat `object` as a parsed representation of the object. |
3690
+ *
3691
+ * If `format` is `'parsed'`, then `object` must match one of the schemas for `CommitObject`, `TreeObject`, `TagObject`, or a `string` (for blobs).
3692
+ *
3693
+ * {@link CommitObject typedef}
3694
+ *
3695
+ * {@link TreeObject typedef}
3696
+ *
3697
+ * {@link TagObject typedef}
3698
+ *
3699
+ * If `format` is `'content'`, `'wrapped'`, or `'deflated'`, `object` should be a `Uint8Array`.
3700
+ *
3701
+ * @deprecated
3702
+ * > This command is overly complicated.
3703
+ * >
3704
+ * > If you know the type of object you are writing, use [`writeBlob`](./writeBlob.md), [`writeCommit`](./writeCommit.md), [`writeTag`](./writeTag.md), or [`writeTree`](./writeTree.md).
3705
+ *
3706
+ * @param {object} args
3707
+ * @param {FsClient} args.fs - a file system client
3708
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3709
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3710
+ * @param {string | Uint8Array | CommitObject | TreeObject | TagObject} args.object - The object to write.
3711
+ * @param {'blob'|'tree'|'commit'|'tag'} [args.type] - The kind of object to write.
3712
+ * @param {'deflated' | 'wrapped' | 'content' | 'parsed'} [args.format = 'parsed'] - What format the object is in. The possible choices are listed below.
3713
+ * @param {string} [args.oid] - If `format` is `'deflated'` then this param is required. Otherwise it is calculated.
3714
+ * @param {string} [args.encoding] - If `type` is `'blob'` then `object` will be converted to a Uint8Array using `encoding`.
3715
+ *
3716
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object.
3717
+ *
3718
+ * @example
3719
+ * // Manually create an annotated tag.
3720
+ * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })
3721
+ * console.log('commit', sha)
3722
+ *
3723
+ * let oid = await git.writeObject({
3724
+ * fs,
3725
+ * dir: '/tutorial',
3726
+ * type: 'tag',
3727
+ * object: {
3728
+ * object: sha,
3729
+ * type: 'commit',
3730
+ * tag: 'my-tag',
3731
+ * tagger: {
3732
+ * name: 'your name',
3733
+ * email: 'email@example.com',
3734
+ * timestamp: Math.floor(Date.now()/1000),
3735
+ * timezoneOffset: new Date().getTimezoneOffset()
3736
+ * },
3737
+ * message: 'Optional message'
3738
+ * }
3739
+ * })
3740
+ *
3741
+ * console.log('tag', oid)
3742
+ *
3743
+ */
3744
+ export function writeObject({ fs: _fs, dir, gitdir, type, object, format, oid, encoding, }: {
3745
+ fs: FsClient;
3746
+ dir?: string | undefined;
3747
+ gitdir?: string | undefined;
3748
+ object: string | Uint8Array | CommitObject | TreeObject | TagObject;
3749
+ type?: "blob" | "commit" | "tree" | "tag" | undefined;
3750
+ format?: "content" | "parsed" | "deflated" | "wrapped" | undefined;
3751
+ oid?: string | undefined;
3752
+ encoding?: string | undefined;
3753
+ }): Promise<string>;
3754
+ /**
3755
+ * Write a ref which refers to the specified SHA-1 object id, or a symbolic ref which refers to the specified ref.
3756
+ *
3757
+ * @param {object} args
3758
+ * @param {FsClient} args.fs - a file system client
3759
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3760
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3761
+ * @param {string} args.ref - The name of the ref to write
3762
+ * @param {string} args.value - When `symbolic` is false, a ref or an SHA-1 object id. When true, a ref starting with `refs/`.
3763
+ * @param {boolean} [args.force = false] - Instead of throwing an error if a ref named `ref` already exists, overwrite the existing ref.
3764
+ * @param {boolean} [args.symbolic = false] - Whether the ref is symbolic or not.
3765
+ *
3766
+ * @returns {Promise<void>} Resolves successfully when filesystem operations are complete
3767
+ *
3768
+ * @example
3769
+ * await git.writeRef({
3770
+ * fs,
3771
+ * dir: '/tutorial',
3772
+ * ref: 'refs/heads/another-branch',
3773
+ * value: 'HEAD'
3774
+ * })
3775
+ * await git.writeRef({
3776
+ * fs,
3777
+ * dir: '/tutorial',
3778
+ * ref: 'HEAD',
3779
+ * value: 'refs/heads/another-branch',
3780
+ * force: true,
3781
+ * symbolic: true
3782
+ * })
3783
+ * console.log('done')
3784
+ *
3785
+ */
3786
+ export function writeRef({ fs: _fs, dir, gitdir, ref, value, force, symbolic, }: {
3787
+ fs: FsClient;
3788
+ dir?: string | undefined;
3789
+ gitdir?: string | undefined;
3790
+ ref: string;
3791
+ value: string;
3792
+ force?: boolean | undefined;
3793
+ symbolic?: boolean | undefined;
3794
+ }): Promise<void>;
3795
+ /**
3796
+ * Write an annotated tag object directly
3797
+ *
3798
+ * @param {object} args
3799
+ * @param {FsClient} args.fs - a file system client
3800
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3801
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3802
+ * @param {TagObject} args.tag - The object to write
3803
+ *
3804
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object
3805
+ * @see TagObject
3806
+ *
3807
+ * @example
3808
+ * // Manually create an annotated tag.
3809
+ * let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })
3810
+ * console.log('commit', sha)
3811
+ *
3812
+ * let oid = await git.writeTag({
3813
+ * fs,
3814
+ * dir: '/tutorial',
3815
+ * tag: {
3816
+ * object: sha,
3817
+ * type: 'commit',
3818
+ * tag: 'my-tag',
3819
+ * tagger: {
3820
+ * name: 'your name',
3821
+ * email: 'email@example.com',
3822
+ * timestamp: Math.floor(Date.now()/1000),
3823
+ * timezoneOffset: new Date().getTimezoneOffset()
3824
+ * },
3825
+ * message: 'Optional message'
3826
+ * }
3827
+ * })
3828
+ *
3829
+ * console.log('tag', oid)
3830
+ *
3831
+ */
3832
+ export function writeTag({ fs, dir, gitdir, tag }: {
3833
+ fs: FsClient;
3834
+ dir?: string | undefined;
3835
+ gitdir?: string | undefined;
3836
+ tag: TagObject;
3837
+ }): Promise<string>;
3838
+ /**
3839
+ * Write a tree object directly
3840
+ *
3841
+ * @param {object} args
3842
+ * @param {FsClient} args.fs - a file system client
3843
+ * @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
3844
+ * @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
3845
+ * @param {TreeObject} args.tree - The object to write
3846
+ *
3847
+ * @returns {Promise<string>} Resolves successfully with the SHA-1 object id of the newly written object.
3848
+ * @see TreeObject
3849
+ * @see TreeEntry
3850
+ *
3851
+ */
3852
+ export function writeTree({ fs, dir, gitdir, tree }: {
3853
+ fs: FsClient;
3854
+ dir?: string | undefined;
3855
+ gitdir?: string | undefined;
3856
+ tree: TreeObject;
3857
+ }): Promise<string>;
3858
+ declare class AlreadyExistsError extends BaseError {
3859
+ /**
3860
+ * @param {'note'|'remote'|'tag'|'branch'} noun
3861
+ * @param {string} where
3862
+ * @param {boolean} canForce
3863
+ */
3864
+ constructor(noun: "note" | "remote" | "tag" | "branch", where: string, canForce?: boolean);
3865
+ code: "AlreadyExistsError";
3866
+ name: "AlreadyExistsError";
3867
+ data: {
3868
+ noun: "tag" | "branch" | "remote" | "note";
3869
+ where: string;
3870
+ canForce: boolean;
3871
+ };
3872
+ }
3873
+ declare namespace AlreadyExistsError {
3874
+ let code: "AlreadyExistsError";
3875
+ }
3876
+ declare class AmbiguousError extends BaseError {
3877
+ /**
3878
+ * @param {'oids'|'refs'} nouns
3879
+ * @param {string} short
3880
+ * @param {string[]} matches
3881
+ */
3882
+ constructor(nouns: "oids" | "refs", short: string, matches: string[]);
3883
+ code: "AmbiguousError";
3884
+ name: "AmbiguousError";
3885
+ data: {
3886
+ nouns: "refs" | "oids";
3887
+ short: string;
3888
+ matches: string[];
3889
+ };
3890
+ }
3891
+ declare namespace AmbiguousError {
3892
+ let code_1: "AmbiguousError";
3893
+ export { code_1 as code };
3894
+ }
3895
+ declare class CheckoutConflictError extends BaseError {
3896
+ /**
3897
+ * @param {string[]} filepaths
3898
+ */
3899
+ constructor(filepaths: string[]);
3900
+ code: "CheckoutConflictError";
3901
+ name: "CheckoutConflictError";
3902
+ data: {
3903
+ filepaths: string[];
3904
+ };
3905
+ }
3906
+ declare namespace CheckoutConflictError {
3907
+ let code_2: "CheckoutConflictError";
3908
+ export { code_2 as code };
3909
+ }
3910
+ declare class CommitNotFetchedError extends BaseError {
3911
+ /**
3912
+ * @param {string} ref
3913
+ * @param {string} oid
3914
+ */
3915
+ constructor(ref: string, oid: string);
3916
+ code: "CommitNotFetchedError";
3917
+ name: "CommitNotFetchedError";
3918
+ data: {
3919
+ ref: string;
3920
+ oid: string;
3921
+ };
3922
+ }
3923
+ declare namespace CommitNotFetchedError {
3924
+ let code_3: "CommitNotFetchedError";
3925
+ export { code_3 as code };
3926
+ }
3927
+ declare class EmptyServerResponseError extends BaseError {
3928
+ constructor();
3929
+ code: "EmptyServerResponseError";
3930
+ name: "EmptyServerResponseError";
3931
+ data: {};
3932
+ }
3933
+ declare namespace EmptyServerResponseError {
3934
+ let code_4: "EmptyServerResponseError";
3935
+ export { code_4 as code };
3936
+ }
3937
+ declare class FastForwardError extends BaseError {
3938
+ constructor();
3939
+ code: "FastForwardError";
3940
+ name: "FastForwardError";
3941
+ data: {};
3942
+ }
3943
+ declare namespace FastForwardError {
3944
+ let code_5: "FastForwardError";
3945
+ export { code_5 as code };
3946
+ }
3947
+ declare class GitPushError extends BaseError {
3948
+ /**
3949
+ * @param {string} prettyDetails
3950
+ * @param {PushResult} result
3951
+ */
3952
+ constructor(prettyDetails: string, result: PushResult);
3953
+ code: "GitPushError";
3954
+ name: "GitPushError";
3955
+ data: {
3956
+ prettyDetails: string;
3957
+ result: PushResult;
3958
+ };
3959
+ }
3960
+ declare namespace GitPushError {
3961
+ let code_6: "GitPushError";
3962
+ export { code_6 as code };
3963
+ }
3964
+ declare class HttpError extends BaseError {
3965
+ /**
3966
+ * @param {number} statusCode
3967
+ * @param {string} statusMessage
3968
+ * @param {string} response
3969
+ */
3970
+ constructor(statusCode: number, statusMessage: string, response: string);
3971
+ code: "HttpError";
3972
+ name: "HttpError";
3973
+ data: {
3974
+ statusCode: number;
3975
+ statusMessage: string;
3976
+ response: string;
3977
+ };
3978
+ }
3979
+ declare namespace HttpError {
3980
+ let code_7: "HttpError";
3981
+ export { code_7 as code };
3982
+ }
3983
+ declare class InternalError extends BaseError {
3984
+ /**
3985
+ * @param {string} message
3986
+ */
3987
+ constructor(message: string);
3988
+ code: "InternalError";
3989
+ name: "InternalError";
3990
+ data: {
3991
+ message: string;
3992
+ };
3993
+ }
3994
+ declare namespace InternalError {
3995
+ let code_8: "InternalError";
3996
+ export { code_8 as code };
3997
+ }
3998
+ declare class InvalidFilepathError extends BaseError {
3999
+ /**
4000
+ * @param {'leading-slash'|'trailing-slash'|'directory'} [reason]
4001
+ */
4002
+ constructor(reason?: "leading-slash" | "trailing-slash" | "directory");
4003
+ code: "InvalidFilepathError";
4004
+ name: "InvalidFilepathError";
4005
+ data: {
4006
+ reason: "directory" | "leading-slash" | "trailing-slash" | undefined;
4007
+ };
4008
+ }
4009
+ declare namespace InvalidFilepathError {
4010
+ let code_9: "InvalidFilepathError";
4011
+ export { code_9 as code };
4012
+ }
4013
+ declare class InvalidOidError extends BaseError {
4014
+ /**
4015
+ * @param {string} value
4016
+ */
4017
+ constructor(value: string);
4018
+ code: "InvalidOidError";
4019
+ name: "InvalidOidError";
4020
+ data: {
4021
+ value: string;
4022
+ };
4023
+ }
4024
+ declare namespace InvalidOidError {
4025
+ let code_10: "InvalidOidError";
4026
+ export { code_10 as code };
4027
+ }
4028
+ declare class InvalidRefNameError extends BaseError {
4029
+ /**
4030
+ * @param {string} ref
4031
+ * @param {string} suggestion
4032
+ * @param {boolean} canForce
4033
+ */
4034
+ constructor(ref: string, suggestion: string);
4035
+ code: "InvalidRefNameError";
4036
+ name: "InvalidRefNameError";
4037
+ data: {
4038
+ ref: string;
4039
+ suggestion: string;
4040
+ };
4041
+ }
4042
+ declare namespace InvalidRefNameError {
4043
+ let code_11: "InvalidRefNameError";
4044
+ export { code_11 as code };
4045
+ }
4046
+ declare class MaxDepthError extends BaseError {
4047
+ /**
4048
+ * @param {number} depth
4049
+ */
4050
+ constructor(depth: number);
4051
+ code: "MaxDepthError";
4052
+ name: "MaxDepthError";
4053
+ data: {
4054
+ depth: number;
4055
+ };
4056
+ }
4057
+ declare namespace MaxDepthError {
4058
+ let code_12: "MaxDepthError";
4059
+ export { code_12 as code };
4060
+ }
4061
+ declare class MergeNotSupportedError extends BaseError {
4062
+ constructor();
4063
+ code: "MergeNotSupportedError";
4064
+ name: "MergeNotSupportedError";
4065
+ data: {};
4066
+ }
4067
+ declare namespace MergeNotSupportedError {
4068
+ let code_13: "MergeNotSupportedError";
4069
+ export { code_13 as code };
4070
+ }
4071
+ declare class MergeConflictError extends BaseError {
4072
+ /**
4073
+ * @param {Array<string>} filepaths
4074
+ * @param {Array<string>} bothModified
4075
+ * @param {Array<string>} deleteByUs
4076
+ * @param {Array<string>} deleteByTheirs
4077
+ */
4078
+ constructor(filepaths: Array<string>, bothModified: Array<string>, deleteByUs: Array<string>, deleteByTheirs: Array<string>);
4079
+ code: "MergeConflictError";
4080
+ name: "MergeConflictError";
4081
+ data: {
4082
+ filepaths: string[];
4083
+ bothModified: string[];
4084
+ deleteByUs: string[];
4085
+ deleteByTheirs: string[];
4086
+ };
4087
+ }
4088
+ declare namespace MergeConflictError {
4089
+ let code_14: "MergeConflictError";
4090
+ export { code_14 as code };
4091
+ }
4092
+ declare class MissingNameError extends BaseError {
4093
+ /**
4094
+ * @param {'author'|'committer'|'tagger'} role
4095
+ */
4096
+ constructor(role: "author" | "committer" | "tagger");
4097
+ code: "MissingNameError";
4098
+ name: "MissingNameError";
4099
+ data: {
4100
+ role: "author" | "committer" | "tagger";
4101
+ };
4102
+ }
4103
+ declare namespace MissingNameError {
4104
+ let code_15: "MissingNameError";
4105
+ export { code_15 as code };
4106
+ }
4107
+ declare class MissingParameterError extends BaseError {
4108
+ /**
4109
+ * @param {string} parameter
4110
+ */
4111
+ constructor(parameter: string);
4112
+ code: "MissingParameterError";
4113
+ name: "MissingParameterError";
4114
+ data: {
4115
+ parameter: string;
4116
+ };
4117
+ }
4118
+ declare namespace MissingParameterError {
4119
+ let code_16: "MissingParameterError";
4120
+ export { code_16 as code };
4121
+ }
4122
+ declare class MultipleGitError extends BaseError {
4123
+ /**
4124
+ * @param {Error[]} errors
4125
+ * @param {string} message
4126
+ */
4127
+ constructor(errors: Error[]);
4128
+ code: "MultipleGitError";
4129
+ name: "MultipleGitError";
4130
+ data: {
4131
+ errors: Error[];
4132
+ };
4133
+ errors: Error[];
4134
+ }
4135
+ declare namespace MultipleGitError {
4136
+ let code_17: "MultipleGitError";
4137
+ export { code_17 as code };
4138
+ }
4139
+ declare class NoRefspecError extends BaseError {
4140
+ /**
4141
+ * @param {string} remote
4142
+ */
4143
+ constructor(remote: string);
4144
+ code: "NoRefspecError";
4145
+ name: "NoRefspecError";
4146
+ data: {
4147
+ remote: string;
4148
+ };
4149
+ }
4150
+ declare namespace NoRefspecError {
4151
+ let code_18: "NoRefspecError";
4152
+ export { code_18 as code };
4153
+ }
4154
+ declare class NotFoundError extends BaseError {
4155
+ /**
4156
+ * @param {string} what
4157
+ */
4158
+ constructor(what: string);
4159
+ code: "NotFoundError";
4160
+ name: "NotFoundError";
4161
+ data: {
4162
+ what: string;
4163
+ };
4164
+ }
4165
+ declare namespace NotFoundError {
4166
+ let code_19: "NotFoundError";
4167
+ export { code_19 as code };
4168
+ }
4169
+ declare class ObjectTypeError extends BaseError {
4170
+ /**
4171
+ * @param {string} oid
4172
+ * @param {'blob'|'commit'|'tag'|'tree'} actual
4173
+ * @param {'blob'|'commit'|'tag'|'tree'} expected
4174
+ * @param {string} [filepath]
4175
+ */
4176
+ constructor(oid: string, actual: "blob" | "commit" | "tag" | "tree", expected: "blob" | "commit" | "tag" | "tree", filepath?: string);
4177
+ code: "ObjectTypeError";
4178
+ name: "ObjectTypeError";
4179
+ data: {
4180
+ oid: string;
4181
+ actual: "blob" | "commit" | "tree" | "tag";
4182
+ expected: "blob" | "commit" | "tree" | "tag";
4183
+ filepath: string | undefined;
4184
+ };
4185
+ }
4186
+ declare namespace ObjectTypeError {
4187
+ let code_20: "ObjectTypeError";
4188
+ export { code_20 as code };
4189
+ }
4190
+ declare class ParseError extends BaseError {
4191
+ /**
4192
+ * @param {string} expected
4193
+ * @param {string} actual
4194
+ */
4195
+ constructor(expected: string, actual: string);
4196
+ code: "ParseError";
4197
+ name: "ParseError";
4198
+ data: {
4199
+ expected: string;
4200
+ actual: string;
4201
+ };
4202
+ }
4203
+ declare namespace ParseError {
4204
+ let code_21: "ParseError";
4205
+ export { code_21 as code };
4206
+ }
4207
+ declare class PushRejectedError extends BaseError {
4208
+ /**
4209
+ * @param {'not-fast-forward'|'tag-exists'} reason
4210
+ */
4211
+ constructor(reason: "not-fast-forward" | "tag-exists");
4212
+ code: "PushRejectedError";
4213
+ name: "PushRejectedError";
4214
+ data: {
4215
+ reason: "not-fast-forward" | "tag-exists";
4216
+ };
4217
+ }
4218
+ declare namespace PushRejectedError {
4219
+ let code_22: "PushRejectedError";
4220
+ export { code_22 as code };
4221
+ }
4222
+ declare class RemoteCapabilityError extends BaseError {
4223
+ /**
4224
+ * @param {'shallow'|'deepen-since'|'deepen-not'|'deepen-relative'} capability
4225
+ * @param {'depth'|'since'|'exclude'|'relative'} parameter
4226
+ */
4227
+ constructor(capability: "shallow" | "deepen-since" | "deepen-not" | "deepen-relative", parameter: "depth" | "since" | "exclude" | "relative");
4228
+ code: "RemoteCapabilityError";
4229
+ name: "RemoteCapabilityError";
4230
+ data: {
4231
+ capability: "shallow" | "deepen-since" | "deepen-not" | "deepen-relative";
4232
+ parameter: "depth" | "since" | "exclude" | "relative";
4233
+ };
4234
+ }
4235
+ declare namespace RemoteCapabilityError {
4236
+ let code_23: "RemoteCapabilityError";
4237
+ export { code_23 as code };
4238
+ }
4239
+ declare class SmartHttpError extends BaseError {
4240
+ /**
4241
+ * @param {string} preview
4242
+ * @param {string} response
4243
+ */
4244
+ constructor(preview: string, response: string);
4245
+ code: "SmartHttpError";
4246
+ name: "SmartHttpError";
4247
+ data: {
4248
+ preview: string;
4249
+ response: string;
4250
+ };
4251
+ }
4252
+ declare namespace SmartHttpError {
4253
+ let code_24: "SmartHttpError";
4254
+ export { code_24 as code };
4255
+ }
4256
+ declare class UnknownTransportError extends BaseError {
4257
+ /**
4258
+ * @param {string} url
4259
+ * @param {string} transport
4260
+ * @param {string} [suggestion]
4261
+ */
4262
+ constructor(url: string, transport: string, suggestion?: string);
4263
+ code: "UnknownTransportError";
4264
+ name: "UnknownTransportError";
4265
+ data: {
4266
+ url: string;
4267
+ transport: string;
4268
+ suggestion: string | undefined;
4269
+ };
4270
+ }
4271
+ declare namespace UnknownTransportError {
4272
+ let code_25: "UnknownTransportError";
4273
+ export { code_25 as code };
4274
+ }
4275
+ declare class UnsafeFilepathError extends BaseError {
4276
+ /**
4277
+ * @param {string} filepath
4278
+ */
4279
+ constructor(filepath: string);
4280
+ code: "UnsafeFilepathError";
4281
+ name: "UnsafeFilepathError";
4282
+ data: {
4283
+ filepath: string;
4284
+ };
4285
+ }
4286
+ declare namespace UnsafeFilepathError {
4287
+ let code_26: "UnsafeFilepathError";
4288
+ export { code_26 as code };
4289
+ }
4290
+ declare class UrlParseError extends BaseError {
4291
+ /**
4292
+ * @param {string} url
4293
+ */
4294
+ constructor(url: string);
4295
+ code: "UrlParseError";
4296
+ name: "UrlParseError";
4297
+ data: {
4298
+ url: string;
4299
+ };
4300
+ }
4301
+ declare namespace UrlParseError {
4302
+ let code_27: "UrlParseError";
4303
+ export { code_27 as code };
4304
+ }
4305
+ declare class UserCanceledError extends BaseError {
4306
+ constructor();
4307
+ code: "UserCanceledError";
4308
+ name: "UserCanceledError";
4309
+ data: {};
4310
+ }
4311
+ declare namespace UserCanceledError {
4312
+ let code_28: "UserCanceledError";
4313
+ export { code_28 as code };
4314
+ }
4315
+ declare class UnmergedPathsError extends BaseError {
4316
+ /**
4317
+ * @param {Array<string>} filepaths
4318
+ */
4319
+ constructor(filepaths: Array<string>);
4320
+ code: "UnmergedPathsError";
4321
+ name: "UnmergedPathsError";
4322
+ data: {
4323
+ filepaths: string[];
4324
+ };
4325
+ }
4326
+ declare namespace UnmergedPathsError {
4327
+ let code_29: "UnmergedPathsError";
4328
+ export { code_29 as code };
4329
+ }
4330
+ declare class IndexResetError extends BaseError {
4331
+ /**
4332
+ * @param {Array<string>} filepaths
4333
+ */
4334
+ constructor(filepath: any);
4335
+ code: "IndexResetError";
4336
+ name: "IndexResetError";
4337
+ data: {
4338
+ filepath: any;
4339
+ };
4340
+ }
4341
+ declare namespace IndexResetError {
4342
+ let code_30: "IndexResetError";
4343
+ export { code_30 as code };
4344
+ }
4345
+ declare class NoCommitError extends BaseError {
4346
+ /**
4347
+ * @param {string} ref
4348
+ */
4349
+ constructor(ref: string);
4350
+ code: "NoCommitError";
4351
+ name: "NoCommitError";
4352
+ data: {
4353
+ ref: string;
4354
+ };
4355
+ }
4356
+ declare namespace NoCommitError {
4357
+ let code_31: "NoCommitError";
4358
+ export { code_31 as code };
4359
+ }
4360
+ /**
4361
+ * @typedef {Object} GitProgressEvent
4362
+ * @property {string} phase
4363
+ * @property {number} loaded
4364
+ * @property {number} total
4365
+ */
4366
+ /**
4367
+ * @callback ProgressCallback
4368
+ * @param {GitProgressEvent} progress
4369
+ * @returns {void | Promise<void>}
4370
+ */
4371
+ /**
4372
+ * @typedef {Object} GitHttpRequest
4373
+ * @property {string} url - The URL to request
4374
+ * @property {string} [method='GET'] - The HTTP method to use
4375
+ * @property {Object<string, string>} [headers={}] - Headers to include in the HTTP request
4376
+ * @property {Object} [agent] - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
4377
+ * @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
4378
+ * @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
4379
+ * @property {object} [signal] - Reserved for future use (canceling a request)
4380
+ */
4381
+ /**
4382
+ * @typedef {Object} GitHttpResponse
4383
+ * @property {string} url - The final URL that was fetched after any redirects
4384
+ * @property {string} [method] - The HTTP method that was used
4385
+ * @property {Object<string, string>} [headers] - HTTP response headers
4386
+ * @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of the response
4387
+ * @property {number} statusCode - The HTTP status code
4388
+ * @property {string} statusMessage - The HTTP status message
4389
+ */
4390
+ /**
4391
+ * @callback HttpFetch
4392
+ * @param {GitHttpRequest} request
4393
+ * @returns {Promise<GitHttpResponse>}
4394
+ */
4395
+ /**
4396
+ * @typedef {Object} HttpClient
4397
+ * @property {HttpFetch} request
4398
+ */
4399
+ /**
4400
+ * A git commit object.
4401
+ *
4402
+ * @typedef {Object} CommitObject
4403
+ * @property {string} message Commit message
4404
+ * @property {string} tree SHA-1 object id of corresponding file tree
4405
+ * @property {string[]} parent an array of zero or more SHA-1 object ids
4406
+ * @property {Object} author
4407
+ * @property {string} author.name The author's name
4408
+ * @property {string} author.email The author's email
4409
+ * @property {number} author.timestamp UTC Unix timestamp in seconds
4410
+ * @property {number} author.timezoneOffset Timezone difference from UTC in minutes
4411
+ * @property {Object} committer
4412
+ * @property {string} committer.name The committer's name
4413
+ * @property {string} committer.email The committer's email
4414
+ * @property {number} committer.timestamp UTC Unix timestamp in seconds
4415
+ * @property {number} committer.timezoneOffset Timezone difference from UTC in minutes
4416
+ * @property {string} [gpgsig] PGP signature (if present)
4417
+ */
4418
+ /**
4419
+ * An entry from a git tree object. Files are called 'blobs' and directories are called 'trees'.
4420
+ *
4421
+ * @typedef {Object} TreeEntry
4422
+ * @property {string} mode the 6 digit hexadecimal mode
4423
+ * @property {string} path the name of the file or directory
4424
+ * @property {string} oid the SHA-1 object id of the blob or tree
4425
+ * @property {'commit'|'blob'|'tree'} type the type of object
4426
+ */
4427
+ /**
4428
+ * A git tree object. Trees represent a directory snapshot.
4429
+ *
4430
+ * @typedef {TreeEntry[]} TreeObject
4431
+ */
4432
+ /**
4433
+ * A git annotated tag object.
4434
+ *
4435
+ * @typedef {Object} TagObject
4436
+ * @property {string} object SHA-1 object id of object being tagged
4437
+ * @property {'blob' | 'tree' | 'commit' | 'tag'} type the type of the object being tagged
4438
+ * @property {string} tag the tag name
4439
+ * @property {Object} tagger
4440
+ * @property {string} tagger.name the tagger's name
4441
+ * @property {string} tagger.email the tagger's email
4442
+ * @property {number} tagger.timestamp UTC Unix timestamp in seconds
4443
+ * @property {number} tagger.timezoneOffset timezone difference from UTC in minutes
4444
+ * @property {string} message tag message
4445
+ * @property {string} [gpgsig] PGP signature (if present)
4446
+ */
4447
+ /**
4448
+ * @typedef {Object} ReadCommitResult
4449
+ * @property {string} oid - SHA-1 object id of this commit
4450
+ * @property {CommitObject} commit - the parsed commit object
4451
+ * @property {string} payload - PGP signing payload
4452
+ */
4453
+ /**
4454
+ * @typedef {Object} ServerRef - This object has the following schema:
4455
+ * @property {string} ref - The name of the ref
4456
+ * @property {string} oid - The SHA-1 object id the ref points to
4457
+ * @property {string} [target] - The target ref pointed to by a symbolic ref
4458
+ * @property {string} [peeled] - If the oid is the SHA-1 object id of an annotated tag, this is the SHA-1 object id that the annotated tag points to
4459
+ */
4460
+ /**
4461
+ * @typedef Walker
4462
+ * @property {Symbol} Symbol('GitWalkerSymbol')
4463
+ */
4464
+ /**
4465
+ * Normalized subset of filesystem `stat` data:
4466
+ *
4467
+ * @typedef {Object} Stat
4468
+ * @property {number} ctimeSeconds
4469
+ * @property {number} ctimeNanoseconds
4470
+ * @property {number} mtimeSeconds
4471
+ * @property {number} mtimeNanoseconds
4472
+ * @property {number} dev
4473
+ * @property {number} ino
4474
+ * @property {number} mode
4475
+ * @property {number} uid
4476
+ * @property {number} gid
4477
+ * @property {number} size
4478
+ */
4479
+ /**
4480
+ * The `WalkerEntry` is an interface that abstracts computing many common tree / blob stats.
4481
+ *
4482
+ * @typedef {Object} WalkerEntry
4483
+ * @property {function(): Promise<'tree'|'blob'|'special'|'commit'>} type
4484
+ * @property {function(): Promise<number>} mode
4485
+ * @property {function(): Promise<string>} oid
4486
+ * @property {function(): Promise<Uint8Array|void>} content
4487
+ * @property {function(): Promise<Stat>} stat
4488
+ */
4489
+ /**
4490
+ * @typedef {Object} CallbackFsClient
4491
+ * @property {function} readFile - https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback
4492
+ * @property {function} writeFile - https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback
4493
+ * @property {function} unlink - https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback
4494
+ * @property {function} readdir - https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback
4495
+ * @property {function} mkdir - https://nodejs.org/api/fs.html#fs_fs_mkdir_path_mode_callback
4496
+ * @property {function} rmdir - https://nodejs.org/api/fs.html#fs_fs_rmdir_path_callback
4497
+ * @property {function} stat - https://nodejs.org/api/fs.html#fs_fs_stat_path_options_callback
4498
+ * @property {function} lstat - https://nodejs.org/api/fs.html#fs_fs_lstat_path_options_callback
4499
+ * @property {function} [readlink] - https://nodejs.org/api/fs.html#fs_fs_readlink_path_options_callback
4500
+ * @property {function} [symlink] - https://nodejs.org/api/fs.html#fs_fs_symlink_target_path_type_callback
4501
+ * @property {function} [chmod] - https://nodejs.org/api/fs.html#fs_fs_chmod_path_mode_callback
4502
+ */
4503
+ /**
4504
+ * @typedef {Object} PromiseFsClient
4505
+ * @property {Object} promises
4506
+ * @property {function} promises.readFile - https://nodejs.org/api/fs.html#fs_fspromises_readfile_path_options
4507
+ * @property {function} promises.writeFile - https://nodejs.org/api/fs.html#fs_fspromises_writefile_file_data_options
4508
+ * @property {function} promises.unlink - https://nodejs.org/api/fs.html#fs_fspromises_unlink_path
4509
+ * @property {function} promises.readdir - https://nodejs.org/api/fs.html#fs_fspromises_readdir_path_options
4510
+ * @property {function} promises.mkdir - https://nodejs.org/api/fs.html#fs_fspromises_mkdir_path_options
4511
+ * @property {function} promises.rmdir - https://nodejs.org/api/fs.html#fs_fspromises_rmdir_path
4512
+ * @property {function} promises.stat - https://nodejs.org/api/fs.html#fs_fspromises_stat_path_options
4513
+ * @property {function} promises.lstat - https://nodejs.org/api/fs.html#fs_fspromises_lstat_path_options
4514
+ * @property {function} [promises.readlink] - https://nodejs.org/api/fs.html#fs_fspromises_readlink_path_options
4515
+ * @property {function} [promises.symlink] - https://nodejs.org/api/fs.html#fs_fspromises_symlink_target_path_type
4516
+ * @property {function} [promises.chmod] - https://nodejs.org/api/fs.html#fs_fspromises_chmod_path_mode
4517
+ */
4518
+ /**
4519
+ * @typedef {CallbackFsClient | PromiseFsClient} FsClient
4520
+ */
4521
+ /**
4522
+ * @callback MessageCallback
4523
+ * @param {string} message
4524
+ * @returns {void | Promise<void>}
4525
+ */
4526
+ /**
4527
+ * @typedef {Object} GitAuth
4528
+ * @property {string} [username]
4529
+ * @property {string} [password]
4530
+ * @property {Object<string, string>} [headers]
4531
+ * @property {boolean} [cancel] Tells git to throw a `UserCanceledError` (instead of an `HttpError`).
4532
+ */
4533
+ /**
4534
+ * @callback AuthCallback
4535
+ * @param {string} url
4536
+ * @param {GitAuth} auth Might have some values if the URL itself originally contained a username or password.
4537
+ * @returns {GitAuth | void | Promise<GitAuth | void>}
4538
+ */
4539
+ /**
4540
+ * @callback AuthFailureCallback
4541
+ * @param {string} url
4542
+ * @param {GitAuth} auth The credentials that failed
4543
+ * @returns {GitAuth | void | Promise<GitAuth | void>}
4544
+ */
4545
+ /**
4546
+ * @callback AuthSuccessCallback
4547
+ * @param {string} url
4548
+ * @param {GitAuth} auth
4549
+ * @returns {void | Promise<void>}
4550
+ */
4551
+ /**
4552
+ * @typedef {Object} SignParams
4553
+ * @property {string} payload - a plaintext message
4554
+ * @property {string} secretKey - an 'ASCII armor' encoded PGP key (technically can actually contain _multiple_ keys)
4555
+ */
4556
+ /**
4557
+ * @callback SignCallback
4558
+ * @param {SignParams} args
4559
+ * @return {{signature: string} | Promise<{signature: string}>} - an 'ASCII armor' encoded "detached" signature
4560
+ */
4561
+ /**
4562
+ * @typedef {Object} MergeDriverParams
4563
+ * @property {Array<string>} branches
4564
+ * @property {Array<string>} contents
4565
+ * @property {string} path
4566
+ */
4567
+ /**
4568
+ * @callback MergeDriverCallback
4569
+ * @param {MergeDriverParams} args
4570
+ * @return {{cleanMerge: boolean, mergedText: string} | Promise<{cleanMerge: boolean, mergedText: string}>}
4571
+ */
4572
+ /**
4573
+ * @callback WalkerMap
4574
+ * @param {string} filename
4575
+ * @param {WalkerEntry[]} entries
4576
+ * @returns {Promise<any>}
4577
+ */
4578
+ /**
4579
+ * @callback WalkerReduce
4580
+ * @param {any} parent
4581
+ * @param {any[]} children
4582
+ * @returns {Promise<any>}
4583
+ */
4584
+ /**
4585
+ * @callback WalkerIterateCallback
4586
+ * @param {WalkerEntry[]} entries
4587
+ * @returns {Promise<any[]>}
4588
+ */
4589
+ /**
4590
+ * @callback WalkerIterate
4591
+ * @param {WalkerIterateCallback} walk
4592
+ * @param {IterableIterator<WalkerEntry[]>} children
4593
+ * @returns {Promise<any[]>}
4594
+ */
4595
+ /**
4596
+ * @typedef {Object} RefUpdateStatus
4597
+ * @property {boolean} ok
4598
+ * @property {string} error
4599
+ */
4600
+ /**
4601
+ * @typedef {Object} PushResult
4602
+ * @property {boolean} ok
4603
+ * @property {?string} error
4604
+ * @property {Object<string, RefUpdateStatus>} refs
4605
+ * @property {Object<string, string>} [headers]
4606
+ */
4607
+ /**
4608
+ * @typedef {0|1} HeadStatus
4609
+ */
4610
+ /**
4611
+ * @typedef {0|1|2} WorkdirStatus
4612
+ */
4613
+ /**
4614
+ * @typedef {0|1|2|3} StageStatus
4615
+ */
4616
+ /**
4617
+ * @typedef {[string, HeadStatus, WorkdirStatus, StageStatus]} StatusRow
4618
+ */
4619
+ /**
4620
+ * @typedef {'push' | 'pop' | 'apply' | 'drop' | 'list' | 'clear'} StashOp the type of stash ops
4621
+ */
4622
+ /**
4623
+ * @typedef {'equal' | 'modify' | 'add' | 'remove' | 'unknown'} StashChangeType - when compare WORDIR to HEAD, 'remove' could mean 'untracked'
4624
+ * @typedef {Object} ClientRef
4625
+ * @property {string} ref The name of the ref
4626
+ * @property {string} oid The SHA-1 object id the ref points to
4627
+ */
4628
+ /**
4629
+ * @typedef {Object} PrePushParams
4630
+ * @property {string} remote The expanded name of target remote
4631
+ * @property {string} url The URL address of target remote
4632
+ * @property {ClientRef} localRef The ref which the client wants to push to the remote
4633
+ * @property {ClientRef} remoteRef The ref which is known by the remote
4634
+ */
4635
+ /**
4636
+ * @callback PrePushCallback
4637
+ * @param {PrePushParams} args
4638
+ * @returns {boolean | Promise<boolean>} Returns false if push must be cancelled
4639
+ */
4640
+ /**
4641
+ * @typedef {Object} PostCheckoutParams
4642
+ * @property {string} previousHead The SHA-1 object id of HEAD before checkout
4643
+ * @property {string} newHead The SHA-1 object id of HEAD after checkout
4644
+ * @property {'branch' | 'file'} type flag determining whether a branch or a set of files was checked
4645
+ */
4646
+ /**
4647
+ * @callback PostCheckoutCallback
4648
+ * @param {PostCheckoutParams} args
4649
+ * @returns {void | Promise<void>}
4650
+ */
4651
+ declare class BaseError extends Error {
4652
+ constructor(message: any);
4653
+ caller: string;
4654
+ toJSON(): {
4655
+ code: any;
4656
+ data: any;
4657
+ caller: string;
4658
+ message: string;
4659
+ stack: string | undefined;
4660
+ };
4661
+ fromJSON(json: any): BaseError;
4662
+ get isIsomorphicGitError(): boolean;
4663
+ }
4664
+ export { updateIndex$1 as updateIndex };