isomorphic-git 1.32.2 → 1.33.0

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.
@@ -0,0 +1,952 @@
1
+ export type TreeEntry = {
2
+ /**
3
+ * - the 6 digit hexadecimal mode
4
+ */
5
+ mode: string;
6
+ /**
7
+ * - the name of the file or directory
8
+ */
9
+ path: string;
10
+ /**
11
+ * - the SHA-1 object id of the blob or tree
12
+ */
13
+ oid: string;
14
+ /**
15
+ * - the type of object
16
+ */
17
+ type: "commit" | "blob" | "tree";
18
+ };
19
+ export type GitProgressEvent = {
20
+ phase: string;
21
+ loaded: number;
22
+ total: number;
23
+ };
24
+ export type ProgressCallback = (progress: GitProgressEvent) => void | Promise<void>;
25
+ export type GitHttpRequest = {
26
+ /**
27
+ * - The URL to request
28
+ */
29
+ url: string;
30
+ /**
31
+ * - The HTTP method to use
32
+ */
33
+ method?: string | undefined;
34
+ /**
35
+ * - Headers to include in the HTTP request
36
+ */
37
+ headers?: {
38
+ [x: string]: string;
39
+ } | undefined;
40
+ /**
41
+ * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
42
+ */
43
+ agent?: any;
44
+ /**
45
+ * - An async iterator of Uint8Arrays that make up the body of POST requests
46
+ */
47
+ body?: AsyncIterableIterator<Uint8Array>;
48
+ /**
49
+ * - Reserved for future use (emitting `GitProgressEvent`s)
50
+ */
51
+ onProgress?: ProgressCallback | undefined;
52
+ /**
53
+ * - Reserved for future use (canceling a request)
54
+ */
55
+ signal?: object;
56
+ };
57
+ export type GitHttpResponse = {
58
+ /**
59
+ * - The final URL that was fetched after any redirects
60
+ */
61
+ url: string;
62
+ /**
63
+ * - The HTTP method that was used
64
+ */
65
+ method?: string | undefined;
66
+ /**
67
+ * - HTTP response headers
68
+ */
69
+ headers?: {
70
+ [x: string]: string;
71
+ } | undefined;
72
+ /**
73
+ * - An async iterator of Uint8Arrays that make up the body of the response
74
+ */
75
+ body?: AsyncIterableIterator<Uint8Array>;
76
+ /**
77
+ * - The HTTP status code
78
+ */
79
+ statusCode: number;
80
+ /**
81
+ * - The HTTP status message
82
+ */
83
+ statusMessage: string;
84
+ };
85
+ export type HttpFetch = (request: GitHttpRequest) => Promise<GitHttpResponse>;
86
+ export type HttpClient = {
87
+ request: HttpFetch;
88
+ };
89
+ /**
90
+ * A git commit object.
91
+ */
92
+ export type CommitObject = {
93
+ /**
94
+ * Commit message
95
+ */
96
+ message: string;
97
+ /**
98
+ * SHA-1 object id of corresponding file tree
99
+ */
100
+ tree: string;
101
+ /**
102
+ * an array of zero or more SHA-1 object ids
103
+ */
104
+ parent: string[];
105
+ author: {
106
+ name: string;
107
+ email: string;
108
+ timestamp: number;
109
+ timezoneOffset: number;
110
+ };
111
+ committer: {
112
+ name: string;
113
+ email: string;
114
+ timestamp: number;
115
+ timezoneOffset: number;
116
+ };
117
+ /**
118
+ * PGP signature (if present)
119
+ */
120
+ gpgsig?: string | undefined;
121
+ };
122
+ /**
123
+ * A git tree object. Trees represent a directory snapshot.
124
+ */
125
+ export type TreeObject = TreeEntry[];
126
+ /**
127
+ * A git annotated tag object.
128
+ */
129
+ export type TagObject = {
130
+ /**
131
+ * SHA-1 object id of object being tagged
132
+ */
133
+ object: string;
134
+ /**
135
+ * the type of the object being tagged
136
+ */
137
+ type: "blob" | "tree" | "commit" | "tag";
138
+ /**
139
+ * the tag name
140
+ */
141
+ tag: string;
142
+ tagger: {
143
+ name: string;
144
+ email: string;
145
+ timestamp: number;
146
+ timezoneOffset: number;
147
+ };
148
+ /**
149
+ * tag message
150
+ */
151
+ message: string;
152
+ /**
153
+ * PGP signature (if present)
154
+ */
155
+ gpgsig?: string | undefined;
156
+ };
157
+ export type ReadCommitResult = {
158
+ /**
159
+ * - SHA-1 object id of this commit
160
+ */
161
+ oid: string;
162
+ /**
163
+ * - the parsed commit object
164
+ */
165
+ commit: CommitObject;
166
+ /**
167
+ * - PGP signing payload
168
+ */
169
+ payload: string;
170
+ };
171
+ /**
172
+ * - This object has the following schema:
173
+ */
174
+ export type ServerRef = {
175
+ /**
176
+ * - The name of the ref
177
+ */
178
+ ref: string;
179
+ /**
180
+ * - The SHA-1 object id the ref points to
181
+ */
182
+ oid: string;
183
+ /**
184
+ * - The target ref pointed to by a symbolic ref
185
+ */
186
+ target?: string | undefined;
187
+ /**
188
+ * - 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
189
+ */
190
+ peeled?: string | undefined;
191
+ };
192
+ export type Walker = {
193
+ /**
194
+ * ('GitWalkerSymbol')
195
+ */
196
+ Symbol: Symbol;
197
+ };
198
+ /**
199
+ * Normalized subset of filesystem `stat` data:
200
+ */
201
+ export type Stat = {
202
+ ctimeSeconds: number;
203
+ ctimeNanoseconds: number;
204
+ mtimeSeconds: number;
205
+ mtimeNanoseconds: number;
206
+ dev: number;
207
+ ino: number;
208
+ mode: number;
209
+ uid: number;
210
+ gid: number;
211
+ size: number;
212
+ };
213
+ /**
214
+ * The `WalkerEntry` is an interface that abstracts computing many common tree / blob stats.
215
+ */
216
+ export type WalkerEntry = {
217
+ type: () => Promise<"tree" | "blob" | "special" | "commit">;
218
+ mode: () => Promise<number>;
219
+ oid: () => Promise<string>;
220
+ content: () => Promise<Uint8Array | void>;
221
+ stat: () => Promise<Stat>;
222
+ };
223
+ export type CallbackFsClient = {
224
+ /**
225
+ * - https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback
226
+ */
227
+ readFile: Function;
228
+ /**
229
+ * - https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback
230
+ */
231
+ writeFile: Function;
232
+ /**
233
+ * - https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback
234
+ */
235
+ unlink: Function;
236
+ /**
237
+ * - https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback
238
+ */
239
+ readdir: Function;
240
+ /**
241
+ * - https://nodejs.org/api/fs.html#fs_fs_mkdir_path_mode_callback
242
+ */
243
+ mkdir: Function;
244
+ /**
245
+ * - https://nodejs.org/api/fs.html#fs_fs_rmdir_path_callback
246
+ */
247
+ rmdir: Function;
248
+ /**
249
+ * - https://nodejs.org/api/fs.html#fs_fs_stat_path_options_callback
250
+ */
251
+ stat: Function;
252
+ /**
253
+ * - https://nodejs.org/api/fs.html#fs_fs_lstat_path_options_callback
254
+ */
255
+ lstat: Function;
256
+ /**
257
+ * - https://nodejs.org/api/fs.html#fs_fs_readlink_path_options_callback
258
+ */
259
+ readlink?: Function | undefined;
260
+ /**
261
+ * - https://nodejs.org/api/fs.html#fs_fs_symlink_target_path_type_callback
262
+ */
263
+ symlink?: Function | undefined;
264
+ /**
265
+ * - https://nodejs.org/api/fs.html#fs_fs_chmod_path_mode_callback
266
+ */
267
+ chmod?: Function | undefined;
268
+ };
269
+ export type PromiseFsClient = {
270
+ promises: {
271
+ readFile: Function;
272
+ writeFile: Function;
273
+ unlink: Function;
274
+ readdir: Function;
275
+ mkdir: Function;
276
+ rmdir: Function;
277
+ stat: Function;
278
+ lstat: Function;
279
+ readlink?: Function | undefined;
280
+ symlink?: Function | undefined;
281
+ chmod?: Function | undefined;
282
+ };
283
+ };
284
+ export type FsClient = CallbackFsClient | PromiseFsClient;
285
+ export type MessageCallback = (message: string) => void | Promise<void>;
286
+ export type GitAuth = {
287
+ username?: string | undefined;
288
+ password?: string | undefined;
289
+ headers?: {
290
+ [x: string]: string;
291
+ } | undefined;
292
+ /**
293
+ * Tells git to throw a `UserCanceledError` (instead of an `HttpError`).
294
+ */
295
+ cancel?: boolean | undefined;
296
+ };
297
+ export type AuthCallback = (url: string, auth: GitAuth) => GitAuth | void | Promise<GitAuth | void>;
298
+ export type AuthFailureCallback = (url: string, auth: GitAuth) => GitAuth | void | Promise<GitAuth | void>;
299
+ export type AuthSuccessCallback = (url: string, auth: GitAuth) => void | Promise<void>;
300
+ export type SignParams = {
301
+ /**
302
+ * - a plaintext message
303
+ */
304
+ payload: string;
305
+ /**
306
+ * - an 'ASCII armor' encoded PGP key (technically can actually contain _multiple_ keys)
307
+ */
308
+ secretKey: string;
309
+ };
310
+ export type SignCallback = (args: SignParams) => {
311
+ signature: string;
312
+ } | Promise<{
313
+ signature: string;
314
+ }>;
315
+ export type MergeDriverParams = {
316
+ branches: Array<string>;
317
+ contents: Array<string>;
318
+ path: string;
319
+ };
320
+ export type MergeDriverCallback = (args: MergeDriverParams) => {
321
+ cleanMerge: boolean;
322
+ mergedText: string;
323
+ } | Promise<{
324
+ cleanMerge: boolean;
325
+ mergedText: string;
326
+ }>;
327
+ export type WalkerMap = (filename: string, entries: WalkerEntry[]) => Promise<any>;
328
+ export type WalkerReduce = (parent: any, children: any[]) => Promise<any>;
329
+ export type WalkerIterateCallback = (entries: WalkerEntry[]) => Promise<any[]>;
330
+ export type WalkerIterate = (walk: WalkerIterateCallback, children: IterableIterator<WalkerEntry[]>) => Promise<any[]>;
331
+ export type RefUpdateStatus = {
332
+ ok: boolean;
333
+ error: string;
334
+ };
335
+ export type PushResult = {
336
+ ok: boolean;
337
+ error: string | null;
338
+ refs: {
339
+ [x: string]: RefUpdateStatus;
340
+ };
341
+ headers?: {
342
+ [x: string]: string;
343
+ } | undefined;
344
+ };
345
+ export type HeadStatus = 0 | 1;
346
+ export type WorkdirStatus = 0 | 1 | 2;
347
+ export type StageStatus = 0 | 1 | 2 | 3;
348
+ export type StatusRow = [string, HeadStatus, WorkdirStatus, StageStatus];
349
+ /**
350
+ * the type of stash ops
351
+ */
352
+ export type StashOp = "push" | "pop" | "apply" | "drop" | "list" | "clear";
353
+ /**
354
+ * - when compare WORDIR to HEAD, 'remove' could mean 'untracked'
355
+ */
356
+ export type StashChangeType = "equal" | "modify" | "add" | "remove" | "unknown";
357
+ export type ClientRef = {
358
+ /**
359
+ * The name of the ref
360
+ */
361
+ ref: string;
362
+ /**
363
+ * The SHA-1 object id the ref points to
364
+ */
365
+ oid: string;
366
+ };
367
+ export type PrePushParams = {
368
+ /**
369
+ * The expanded name of target remote
370
+ */
371
+ remote: string;
372
+ /**
373
+ * The URL address of target remote
374
+ */
375
+ url: string;
376
+ /**
377
+ * The ref which the client wants to push to the remote
378
+ */
379
+ localRef: ClientRef;
380
+ /**
381
+ * The ref which is known by the remote
382
+ */
383
+ remoteRef: ClientRef;
384
+ };
385
+ export type PrePushCallback = (args: PrePushParams) => boolean | Promise<boolean>;
386
+ export type PostCheckoutParams = {
387
+ /**
388
+ * The SHA-1 object id of HEAD before checkout
389
+ */
390
+ previousHead: string;
391
+ /**
392
+ * The SHA-1 object id of HEAD after checkout
393
+ */
394
+ newHead: string;
395
+ /**
396
+ * flag determining whether a branch or a set of files was checked
397
+ */
398
+ type: "branch" | "file";
399
+ };
400
+ export type PostCheckoutCallback = (args: PostCheckoutParams) => void | Promise<void>;
401
+ /**
402
+ * Manages access to the Git configuration file, providing methods to read and save configurations.
403
+ */
404
+ export class GitConfigManager {
405
+ /**
406
+ * Reads the Git configuration file from the specified `.git` directory.
407
+ *
408
+ * @param {object} opts - Options for reading the Git configuration.
409
+ * @param {FSClient} opts.fs - A file system implementation.
410
+ * @param {string} opts.gitdir - The path to the `.git` directory.
411
+ * @returns {Promise<GitConfig>} A `GitConfig` object representing the parsed configuration.
412
+ */
413
+ static get({ fs, gitdir }: {
414
+ fs: FSClient;
415
+ gitdir: string;
416
+ }): Promise<GitConfig>;
417
+ /**
418
+ * Saves the provided Git configuration to the specified `.git` directory.
419
+ *
420
+ * @param {object} opts - Options for saving the Git configuration.
421
+ * @param {FSClient} opts.fs - A file system implementation.
422
+ * @param {string} opts.gitdir - The path to the `.git` directory.
423
+ * @param {GitConfig} opts.config - The `GitConfig` object to save.
424
+ * @returns {Promise<void>} Resolves when the configuration has been successfully saved.
425
+ */
426
+ static save({ fs, gitdir, config }: {
427
+ fs: FSClient;
428
+ gitdir: string;
429
+ config: GitConfig;
430
+ }): Promise<void>;
431
+ }
432
+ export class GitIgnoreManager {
433
+ /**
434
+ * Determines whether a given file is ignored based on `.gitignore` rules and exclusion files.
435
+ *
436
+ * @param {Object} args
437
+ * @param {FSClient} args.fs - A file system implementation.
438
+ * @param {string} args.dir - The working directory.
439
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
440
+ * @param {string} args.filepath - The path of the file to check.
441
+ * @returns {Promise<boolean>} - `true` if the file is ignored, `false` otherwise.
442
+ */
443
+ static isIgnored({ fs, dir, gitdir, filepath }: {
444
+ fs: FSClient;
445
+ dir: string;
446
+ gitdir?: string | undefined;
447
+ filepath: string;
448
+ }): Promise<boolean>;
449
+ }
450
+ export class GitIndexManager {
451
+ /**
452
+ * Manages access to the Git index file, ensuring thread-safe operations and caching.
453
+ *
454
+ * @param {object} opts - Options for acquiring the Git index.
455
+ * @param {FSClient} opts.fs - A file system implementation.
456
+ * @param {string} opts.gitdir - The path to the `.git` directory.
457
+ * @param {object} opts.cache - A shared cache object for storing index data.
458
+ * @param {boolean} [opts.allowUnmerged=true] - Whether to allow unmerged paths in the index.
459
+ * @param {function(GitIndex): any} closure - A function to execute with the Git index.
460
+ * @returns {Promise<any>} The result of the closure function.
461
+ * @throws {UnmergedPathsError} If unmerged paths exist and `allowUnmerged` is `false`.
462
+ */
463
+ static acquire({ fs, gitdir, cache, allowUnmerged }: {
464
+ fs: FSClient;
465
+ gitdir: string;
466
+ cache: object;
467
+ allowUnmerged?: boolean | undefined;
468
+ }, closure: (arg0: GitIndex) => any): Promise<any>;
469
+ }
470
+ /**
471
+ * A class for managing Git references, including reading, writing, deleting, and resolving refs.
472
+ */
473
+ export class GitRefManager {
474
+ /**
475
+ * Updates remote refs based on the provided refspecs and options.
476
+ *
477
+ * @param {Object} args
478
+ * @param {FSClient} args.fs - A file system implementation.
479
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
480
+ * @param {string} args.remote - The name of the remote.
481
+ * @param {Map<string, string>} args.refs - A map of refs to their object IDs.
482
+ * @param {Map<string, string>} args.symrefs - A map of symbolic refs.
483
+ * @param {boolean} args.tags - Whether to fetch tags.
484
+ * @param {string[]} [args.refspecs = undefined] - The refspecs to use.
485
+ * @param {boolean} [args.prune = false] - Whether to prune stale refs.
486
+ * @param {boolean} [args.pruneTags = false] - Whether to prune tags.
487
+ * @returns {Promise<Object>} - An object containing pruned refs.
488
+ */
489
+ static updateRemoteRefs({ fs, gitdir, remote, refs, symrefs, tags, refspecs, prune, pruneTags, }: {
490
+ fs: FSClient;
491
+ gitdir?: string | undefined;
492
+ remote: string;
493
+ refs: Map<string, string>;
494
+ symrefs: Map<string, string>;
495
+ tags: boolean;
496
+ refspecs?: string[] | undefined;
497
+ prune?: boolean | undefined;
498
+ pruneTags?: boolean | undefined;
499
+ }): Promise<any>;
500
+ /**
501
+ * Writes a ref to the file system.
502
+ *
503
+ * @param {Object} args
504
+ * @param {FSClient} args.fs - A file system implementation.
505
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
506
+ * @param {string} args.ref - The ref to write.
507
+ * @param {string} args.value - The object ID to write.
508
+ * @returns {Promise<void>}
509
+ */
510
+ static writeRef({ fs, gitdir, ref, value }: {
511
+ fs: FSClient;
512
+ gitdir?: string | undefined;
513
+ ref: string;
514
+ value: string;
515
+ }): Promise<void>;
516
+ /**
517
+ * Writes a symbolic ref to the file system.
518
+ *
519
+ * @param {Object} args
520
+ * @param {FSClient} args.fs - A file system implementation.
521
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
522
+ * @param {string} args.ref - The ref to write.
523
+ * @param {string} args.value - The target ref.
524
+ * @returns {Promise<void>}
525
+ */
526
+ static writeSymbolicRef({ fs, gitdir, ref, value }: {
527
+ fs: FSClient;
528
+ gitdir?: string | undefined;
529
+ ref: string;
530
+ value: string;
531
+ }): Promise<void>;
532
+ /**
533
+ * Deletes a single ref.
534
+ *
535
+ * @param {Object} args
536
+ * @param {FSClient} args.fs - A file system implementation.
537
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
538
+ * @param {string} args.ref - The ref to delete.
539
+ * @returns {Promise<void>}
540
+ */
541
+ static deleteRef({ fs, gitdir, ref }: {
542
+ fs: FSClient;
543
+ gitdir?: string | undefined;
544
+ ref: string;
545
+ }): Promise<void>;
546
+ /**
547
+ * Deletes multiple refs.
548
+ *
549
+ * @param {Object} args
550
+ * @param {FSClient} args.fs - A file system implementation.
551
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
552
+ * @param {string[]} args.refs - The refs to delete.
553
+ * @returns {Promise<void>}
554
+ */
555
+ static deleteRefs({ fs, gitdir, refs }: {
556
+ fs: FSClient;
557
+ gitdir?: string | undefined;
558
+ refs: string[];
559
+ }): Promise<void>;
560
+ /**
561
+ * Resolves a ref to its object ID.
562
+ *
563
+ * @param {Object} args
564
+ * @param {FSClient} args.fs - A file system implementation.
565
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
566
+ * @param {string} args.ref - The ref to resolve.
567
+ * @param {number} [args.depth = undefined] - The maximum depth to resolve symbolic refs.
568
+ * @returns {Promise<string>} - The resolved object ID.
569
+ */
570
+ static resolve({ fs, gitdir, ref, depth }: {
571
+ fs: FSClient;
572
+ gitdir?: string | undefined;
573
+ ref: string;
574
+ depth?: number | undefined;
575
+ }): Promise<string>;
576
+ /**
577
+ * Checks if a ref exists.
578
+ *
579
+ * @param {Object} args
580
+ * @param {FSClient} args.fs - A file system implementation.
581
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
582
+ * @param {string} args.ref - The ref to check.
583
+ * @returns {Promise<boolean>} - True if the ref exists, false otherwise.
584
+ */
585
+ static exists({ fs, gitdir, ref }: {
586
+ fs: FSClient;
587
+ gitdir?: string | undefined;
588
+ ref: string;
589
+ }): Promise<boolean>;
590
+ /**
591
+ * Expands a ref to its full name.
592
+ *
593
+ * @param {Object} args
594
+ * @param {FSClient} args.fs - A file system implementation.
595
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
596
+ * @param {string} args.ref - The ref to expand.
597
+ * @returns {Promise<string>} - The full ref name.
598
+ */
599
+ static expand({ fs, gitdir, ref }: {
600
+ fs: FSClient;
601
+ gitdir?: string | undefined;
602
+ ref: string;
603
+ }): Promise<string>;
604
+ /**
605
+ * Expands a ref against a provided map.
606
+ *
607
+ * @param {Object} args
608
+ * @param {string} args.ref - The ref to expand.
609
+ * @param {Map<string, string>} args.map - The map of refs.
610
+ * @returns {Promise<string>} - The expanded ref.
611
+ */
612
+ static expandAgainstMap({ ref, map }: {
613
+ ref: string;
614
+ map: Map<string, string>;
615
+ }): Promise<string>;
616
+ /**
617
+ * Resolves a ref against a provided map.
618
+ *
619
+ * @param {Object} args
620
+ * @param {string} args.ref - The ref to resolve.
621
+ * @param {string} [args.fullref = args.ref] - The full ref name.
622
+ * @param {number} [args.depth = undefined] - The maximum depth to resolve symbolic refs.
623
+ * @param {Map<string, string>} args.map - The map of refs.
624
+ * @returns {Object} - An object containing the full ref and its object ID.
625
+ */
626
+ static resolveAgainstMap({ ref, fullref, depth, map }: {
627
+ ref: string;
628
+ fullref?: string | undefined;
629
+ depth?: number | undefined;
630
+ map: Map<string, string>;
631
+ }): any;
632
+ /**
633
+ * Reads the packed refs file and returns a map of refs.
634
+ *
635
+ * @param {Object} args
636
+ * @param {FSClient} args.fs - A file system implementation.
637
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
638
+ * @returns {Promise<Map<string, string>>} - A map of packed refs.
639
+ */
640
+ static packedRefs({ fs, gitdir }: {
641
+ fs: FSClient;
642
+ gitdir?: string | undefined;
643
+ }): Promise<Map<string, string>>;
644
+ /**
645
+ * Lists all refs matching a given filepath prefix.
646
+ *
647
+ * @param {Object} args
648
+ * @param {FSClient} args.fs - A file system implementation.
649
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
650
+ * @param {string} args.filepath - The filepath prefix to match.
651
+ * @returns {Promise<string[]>} - A sorted list of refs.
652
+ */
653
+ static listRefs({ fs, gitdir, filepath }: {
654
+ fs: FSClient;
655
+ gitdir?: string | undefined;
656
+ filepath: string;
657
+ }): Promise<string[]>;
658
+ /**
659
+ * Lists all branches, optionally filtered by remote.
660
+ *
661
+ * @param {Object} args
662
+ * @param {FSClient} args.fs - A file system implementation.
663
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
664
+ * @param {string} [args.remote] - The remote to filter branches by.
665
+ * @returns {Promise<string[]>} - A list of branch names.
666
+ */
667
+ static listBranches({ fs, gitdir, remote }: {
668
+ fs: FSClient;
669
+ gitdir?: string | undefined;
670
+ remote?: string | undefined;
671
+ }): Promise<string[]>;
672
+ /**
673
+ * Lists all tags.
674
+ *
675
+ * @param {Object} args
676
+ * @param {FSClient} args.fs - A file system implementation.
677
+ * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
678
+ * @returns {Promise<string[]>} - A list of tag names.
679
+ */
680
+ static listTags({ fs, gitdir }: {
681
+ fs: FSClient;
682
+ gitdir?: string | undefined;
683
+ }): Promise<string[]>;
684
+ }
685
+ export class GitRemoteHTTP {
686
+ /**
687
+ * Returns the capabilities of the GitRemoteHTTP class.
688
+ *
689
+ * @returns {Promise<string[]>} - An array of supported capabilities.
690
+ */
691
+ static capabilities(): Promise<string[]>;
692
+ /**
693
+ * Discovers references from a remote Git repository.
694
+ *
695
+ * @param {Object} args
696
+ * @param {HttpClient} args.http - The HTTP client to use for requests.
697
+ * @param {ProgressCallback} [args.onProgress] - Callback for progress updates.
698
+ * @param {AuthCallback} [args.onAuth] - Callback for providing authentication credentials.
699
+ * @param {AuthFailureCallback} [args.onAuthFailure] - Callback for handling authentication failures.
700
+ * @param {AuthSuccessCallback} [args.onAuthSuccess] - Callback for handling successful authentication.
701
+ * @param {string} [args.corsProxy] - Optional CORS proxy URL.
702
+ * @param {string} args.service - The Git service (e.g., "git-upload-pack").
703
+ * @param {string} args.url - The URL of the remote repository.
704
+ * @param {Object<string, string>} args.headers - HTTP headers to include in the request.
705
+ * @param {1 | 2} args.protocolVersion - The Git protocol version to use.
706
+ * @returns {Promise<Object>} - The parsed response from the remote repository.
707
+ * @throws {HttpError} - If the HTTP request fails.
708
+ * @throws {SmartHttpError} - If the response cannot be parsed.
709
+ * @throws {UserCanceledError} - If the user cancels the operation.
710
+ */
711
+ static discover({ http, onProgress, onAuth, onAuthSuccess, onAuthFailure, corsProxy, service, url: _origUrl, headers, protocolVersion, }: {
712
+ http: HttpClient;
713
+ onProgress?: ProgressCallback | undefined;
714
+ onAuth?: AuthCallback | undefined;
715
+ onAuthFailure?: AuthFailureCallback | undefined;
716
+ onAuthSuccess?: AuthSuccessCallback | undefined;
717
+ corsProxy?: string | undefined;
718
+ service: string;
719
+ url: string;
720
+ headers: {
721
+ [x: string]: string;
722
+ };
723
+ protocolVersion: 1 | 2;
724
+ }): Promise<any>;
725
+ /**
726
+ * Connects to a remote Git repository and sends a request.
727
+ *
728
+ * @param {Object} args
729
+ * @param {HttpClient} args.http - The HTTP client to use for requests.
730
+ * @param {ProgressCallback} [args.onProgress] - Callback for progress updates.
731
+ * @param {string} [args.corsProxy] - Optional CORS proxy URL.
732
+ * @param {string} args.service - The Git service (e.g., "git-upload-pack").
733
+ * @param {string} args.url - The URL of the remote repository.
734
+ * @param {Object<string, string>} [args.headers] - HTTP headers to include in the request.
735
+ * @param {any} args.body - The request body to send.
736
+ * @param {any} args.auth - Authentication credentials.
737
+ * @returns {Promise<GitHttpResponse>} - The HTTP response from the remote repository.
738
+ * @throws {HttpError} - If the HTTP request fails.
739
+ */
740
+ static connect({ http, onProgress, corsProxy, service, url, auth, body, headers, }: {
741
+ http: HttpClient;
742
+ onProgress?: ProgressCallback | undefined;
743
+ corsProxy?: string | undefined;
744
+ service: string;
745
+ url: string;
746
+ headers?: {
747
+ [x: string]: string;
748
+ } | undefined;
749
+ body: any;
750
+ auth: any;
751
+ }): Promise<GitHttpResponse>;
752
+ }
753
+ /**
754
+ * A class for managing Git remotes and determining the appropriate remote helper for a given URL.
755
+ */
756
+ export class GitRemoteManager {
757
+ /**
758
+ * Determines the appropriate remote helper for the given URL.
759
+ *
760
+ * @param {Object} args
761
+ * @param {string} args.url - The URL of the remote repository.
762
+ * @returns {Object} - The remote helper class for the specified transport.
763
+ * @throws {UrlParseError} - If the URL cannot be parsed.
764
+ * @throws {UnknownTransportError} - If the transport is not supported.
765
+ */
766
+ static getRemoteHelperFor({ url }: {
767
+ url: string;
768
+ }): any;
769
+ }
770
+ export class GitShallowManager {
771
+ /**
772
+ * Reads the `shallow` file in the Git repository and returns a set of object IDs (OIDs).
773
+ *
774
+ * @param {Object} args
775
+ * @param {FSClient} args.fs - A file system implementation.
776
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
777
+ * @returns {Promise<Set<string>>} - A set of shallow object IDs.
778
+ */
779
+ static read({ fs, gitdir }: {
780
+ fs: FSClient;
781
+ gitdir?: string | undefined;
782
+ }): Promise<Set<string>>;
783
+ /**
784
+ * Writes a set of object IDs (OIDs) to the `shallow` file in the Git repository.
785
+ * If the set is empty, the `shallow` file is removed.
786
+ *
787
+ * @param {Object} args
788
+ * @param {FSClient} args.fs - A file system implementation.
789
+ * @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
790
+ * @param {Set<string>} args.oids - A set of shallow object IDs to write.
791
+ * @returns {Promise<void>}
792
+ */
793
+ static write({ fs, gitdir, oids }: {
794
+ fs: FSClient;
795
+ gitdir?: string | undefined;
796
+ oids: Set<string>;
797
+ }): Promise<void>;
798
+ }
799
+ export class GitStashManager {
800
+ /**
801
+ * Gets the reference name for the stash.
802
+ *
803
+ * @returns {string} - The stash reference name.
804
+ */
805
+ static get refStash(): string;
806
+ /**
807
+ * Gets the reference name for the stash reflogs.
808
+ *
809
+ * @returns {string} - The stash reflogs reference name.
810
+ */
811
+ static get refLogsStash(): string;
812
+ /**
813
+ * Creates an instance of GitStashManager.
814
+ *
815
+ * @param {Object} args
816
+ * @param {FSClient} args.fs - A file system implementation.
817
+ * @param {string} args.dir - The working directory.
818
+ * @param {string}[args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
819
+ */
820
+ constructor({ fs, dir, gitdir }: {
821
+ fs: FSClient;
822
+ dir: string;
823
+ gitdir?: string | undefined;
824
+ });
825
+ /**
826
+ * Gets the file path for the stash reference.
827
+ *
828
+ * @returns {string} - The file path for the stash reference.
829
+ */
830
+ get refStashPath(): string;
831
+ /**
832
+ * Gets the file path for the stash reflogs.
833
+ *
834
+ * @returns {string} - The file path for the stash reflogs.
835
+ */
836
+ get refLogsStashPath(): string;
837
+ /**
838
+ * Retrieves the author information for the stash.
839
+ *
840
+ * @returns {Promise<Object>} - The author object.
841
+ * @throws {MissingNameError} - If the author name is missing.
842
+ */
843
+ getAuthor(): Promise<any>;
844
+ _author: void | {
845
+ name: string;
846
+ email: string;
847
+ timestamp: number;
848
+ timezoneOffset: number;
849
+ } | undefined;
850
+ /**
851
+ * Gets the SHA of a stash entry by its index.
852
+ *
853
+ * @param {number} refIdx - The index of the stash entry.
854
+ * @param {string[]} [stashEntries] - Optional preloaded stash entries.
855
+ * @returns {Promise<string|null>} - The SHA of the stash entry or `null` if not found.
856
+ */
857
+ getStashSHA(refIdx: number, stashEntries?: string[]): Promise<string | null>;
858
+ /**
859
+ * Writes a stash commit to the repository.
860
+ *
861
+ * @param {Object} args
862
+ * @param {string} args.message - The commit message.
863
+ * @param {string} args.tree - The tree object ID.
864
+ * @param {string[]} args.parent - The parent commit object IDs.
865
+ * @returns {Promise<string>} - The object ID of the written commit.
866
+ */
867
+ writeStashCommit({ message, tree, parent }: {
868
+ message: string;
869
+ tree: string;
870
+ parent: string[];
871
+ }): Promise<string>;
872
+ /**
873
+ * Reads a stash commit by its index.
874
+ *
875
+ * @param {number} refIdx - The index of the stash entry.
876
+ * @returns {Promise<Object>} - The stash commit object.
877
+ * @throws {InvalidRefNameError} - If the index is invalid.
878
+ */
879
+ readStashCommit(refIdx: number): Promise<any>;
880
+ /**
881
+ * Writes a stash reference to the repository.
882
+ *
883
+ * @param {string} stashCommit - The object ID of the stash commit.
884
+ * @returns {Promise<void>}
885
+ */
886
+ writeStashRef(stashCommit: string): Promise<void>;
887
+ /**
888
+ * Writes a reflog entry for a stash commit.
889
+ *
890
+ * @param {Object} args
891
+ * @param {string} args.stashCommit - The object ID of the stash commit.
892
+ * @param {string} args.message - The reflog message.
893
+ * @returns {Promise<void>}
894
+ */
895
+ writeStashReflogEntry({ stashCommit, message }: {
896
+ stashCommit: string;
897
+ message: string;
898
+ }): Promise<void>;
899
+ /**
900
+ * Reads the stash reflogs.
901
+ *
902
+ * @param {Object} args
903
+ * @param {boolean} [args.parsed=false] - Whether to parse the reflog entries.
904
+ * @returns {Promise<string[]|Object[]>} - The reflog entries as strings or parsed objects.
905
+ */
906
+ readStashReflogs({ parsed }: {
907
+ parsed?: boolean | undefined;
908
+ }): Promise<string[] | any[]>;
909
+ }
910
+ declare class GitConfig {
911
+ static from(text: any): GitConfig;
912
+ constructor(text: any);
913
+ parsedConfig: any;
914
+ get(path: any, getall?: boolean): Promise<any>;
915
+ getall(path: any): Promise<any>;
916
+ getSubsections(section: any): Promise<any>;
917
+ deleteSection(section: any, subsection: any): Promise<void>;
918
+ append(path: any, value: any): Promise<void>;
919
+ set(path: any, value: any, append?: boolean): Promise<void>;
920
+ toString(): any;
921
+ }
922
+ declare class GitIndex {
923
+ [x: number]: () => {};
924
+ static from(buffer: any): Promise<GitIndex>;
925
+ static fromBuffer(buffer: any): Promise<GitIndex>;
926
+ static _entryToBuffer(entry: any): Promise<any>;
927
+ constructor(entries: any, unmergedPaths: any);
928
+ _dirty: boolean;
929
+ _unmergedPaths: any;
930
+ _entries: any;
931
+ _addEntry(entry: any): void;
932
+ get unmergedPaths(): any[];
933
+ get entries(): any[];
934
+ get entriesMap(): any;
935
+ get entriesFlat(): any;
936
+ insert({ filepath, stats, oid, stage }: {
937
+ filepath: any;
938
+ stats: any;
939
+ oid: any;
940
+ stage?: number | undefined;
941
+ }): void;
942
+ delete({ filepath }: {
943
+ filepath: any;
944
+ }): void;
945
+ clear(): void;
946
+ has({ filepath }: {
947
+ filepath: any;
948
+ }): any;
949
+ render(): string;
950
+ toObject(): Promise<any>;
951
+ }
952
+ export {};