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