isomorphic-git 1.10.1

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