-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.d.ts
More file actions
1863 lines (1861 loc) · 62.6 KB
/
index.d.ts
File metadata and controls
1863 lines (1861 loc) · 62.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export interface CommitOptions {
updateRef?: string
/**
* Signature for author.
*
* If not provided, the default signature of the repository will be used.
* If there is no default signature set for the repository, an error will occur.
*/
author?: SignaturePayload
/**
* Signature for commiter.
*
* If not provided, the default signature of the repository will be used.
* If there is no default signature set for the repository, an error will occur.
*/
committer?: SignaturePayload
parents?: Array<string>
}
export const enum DiffFlags {
/** File(s) treated as binary data. */
Binary = 1,
/** File(s) treated as text data. */
NotBinary = 2,
/** `id` value is known correct. */
ValidId = 4,
/** File exists at this side of the delta. */
Exists = 8
}
/** Check diff flags contains given flags. */
export declare function diffFlagsContains(source: number, target: number): boolean
/** What type of change is described by a `DiffDelta`? */
export type DeltaType = /** No changes */
'Unmodified' | /** Entry does not exist in an old version */
'Added' | /** Entry does not exist in a new version */
'Deleted' | /** Entry content changed between old and new */
'Modified' | /** Entry was renamed between old and new */
'Renamed' | /** Entry was copied from another old entry */
'Copied' | /** Entry is ignored item in workdir */
'Ignored' | /** Entry is untracked item in workdir */
'Untracked' | /** Type of entry changed between old and new */
'Typechange' | /** Entry is unreadable */
'Unreadable' | /** Entry in the index is conflicted */
'Conflicted';
/** Possible output formats for diff data. */
export type DiffFormat = /** full `git diff` (default) */
'Patch' | /** just the headers of the patch */
'PatchHeader' | /** like `git diff --raw` */
'Raw' | /** like `git diff --name-only` */
'NameOnly' | /** like `git diff --name-status` */
'NameStatus' | /** `git diff` as used by `git patch-id` */
'PatchId';
export interface DiffPrintOptions {
format?: DiffFormat
}
/** Valid modes for index and tree entries. */
export type FileMode = 'Unreadable' | 'Tree' | 'Blob' | /** Group writable blob. Obsolete mode kept for compatibility reasons */
'BlobGroupWritable' | 'BlobExecutable' | 'Link' | 'Commit';
/** Describing options about how the diff should be executed. */
export interface DiffOptions {
/** Flag indicating whether the sides of the diff will be reversed. */
reverse?: boolean
/** Flag indicating whether ignored files are included. */
includeIgnored?: boolean
/** Flag indicating whether ignored directories are traversed deeply or not. */
recurseIgnoredDirs?: boolean
/** Flag indicating whether untracked files are in the diff */
includeUntracked?: boolean
/**
* Flag indicating whether untracked directories are traversed deeply or
* not.
*/
recurseUntrackedDirs?: boolean
/** Flag indicating whether unmodified files are in the diff. */
includeUnmodified?: boolean
/** If enabled, then Typechange delta records are generated. */
includeTypechange?: boolean
/**
* Event with `includeTypechange`, the tree returned generally shows a
* deleted blob. This flag correctly labels the tree transitions as a
* typechange record with the `new_file`'s mode set to tree.
*
* Note that the tree SHA will not be available.
*/
includeTypechangeTrees?: boolean
/** Flag indicating whether file mode changes are ignored. */
ignoreFilemode?: boolean
/** Flag indicating whether all submodules should be treated as unmodified. */
ignoreSubmodules?: boolean
/** Flag indicating whether case insensitive filenames should be used. */
ignoreCase?: boolean
/**
* If pathspecs are specified, this flag means that they should be applied
* as an exact match instead of a fnmatch pattern.
*/
disablePathspecMatch?: boolean
/**
* Disable updating the `binary` flag in delta records. This is useful when
* iterating over a diff if you don't need hunk and data callbacks and want
* to avoid having to load a file completely.
*/
skipBinaryCheck?: boolean
/**
* When diff finds an untracked directory, to match the behavior of core
* Git, it scans the contents for ignored and untracked files. If all
* contents are ignored, then the directory is ignored; if any contents are
* not ignored, then the directory is untracked. This is extra work that
* may not matter in many cases.
*
* This flag turns off that scan and immediately labels an untracked
* directory as untracked (changing the behavior to not match core git).
*/
enableFastUntrackedDirs?: boolean
/**
* When diff finds a file in the working directory with stat information
* different from the index, but the OID ends up being the same, write the
* correct stat information into the index. Note: without this flag, diff
* will always leave the index untouched.
*/
updateIndex?: boolean
/** Include unreadable files in the diff */
includeUnreadable?: boolean
/** Include unreadable files in the diff as untracked files */
includeUnreadableAsUntracked?: boolean
/** Treat all files as text, disabling binary attributes and detection. */
forceText?: boolean
/** Treat all files as binary, disabling text diffs */
forceBinary?: boolean
/** Ignore all whitespace */
ignoreWhitespace?: boolean
/** Ignore changes in the amount of whitespace */
ignoreWhitespaceChange?: boolean
/** Ignore whitespace at the end of line */
ignoreWhitespaceEol?: boolean
/** Ignore blank lines */
ignoreBlankLines?: boolean
/**
* When generating patch text, include the content of untracked files.
*
* This automatically turns on `includeUntracked` but it does not turn on
* `recurseUntrackedDirs`. Add that flag if you want the content of every
* single untracked file.
*/
showUntrackedContent?: boolean
/**
* When generating output, include the names of unmodified files if they
* are included in the `Diff`. Normally these are skipped in the formats
* that list files (e.g. name-only, name-status, raw). Even with this these
* will not be included in the patch format.
*/
showUnmodified?: boolean
/** Use the "patience diff" algorithm */
patience?: boolean
/** Take extra time to find the minimal diff */
minimal?: boolean
/**
* Include the necessary deflate/delta information so that `git-apply` can
* apply given diff information to binary files.
*/
showBinary?: boolean
/**
* Use a heuristic that takes indentation and whitespace into account
* which generally can produce better diffs when dealing with ambiguous
* diff hunks.
*/
indentHeuristic?: boolean
/**
* Set the number of unchanged lines that define the boundary of a hunk
* (and to display before and after).
*
* The default value for this is 3.
*/
contextLines?: number
/**
* Set the maximum number of unchanged lines between hunk boundaries before
* the hunks will be merged into one.
*
* The default value for this is 0.
*/
interhunkLines?: number
/** The default value for this is `core.abbrev` or 7 if unset. */
idAbbrev?: number
/**
* Maximum size (in bytes) above which a blob will be marked as binary
* automatically.
*
* A negative value will disable this entirely.
*
* The default value for this is 512MB.
*/
maxSize?: number
/**
* The virtual "directory" to prefix old file names with in hunk headers.
*
* The default value for this is "a".
*/
oldPrefix?: string
/**
* The virtual "directory" to prefix new file names with in hunk headers.
*
* The default value for this is "b".
*/
newPrefix?: string
/** Add to the array of paths/fnmatch patterns to constrain the diff. */
pathspecs?: Array<string>
}
export interface IndexEntry {
ctime: Date
mtime: Date
dev: number
ino: number
mode: number
uid: number
gid: number
fileSize: number
id: string
flags: number
flagsExtended: number
/**
* The path of this index entry as a byte vector. Regardless of the
* current platform, the directory separator is an ASCII forward slash
* (`0x2F`). There are no terminating or internal NUL characters, and no
* trailing slashes. Most of the time, paths will be valid utf-8 — but
* not always. For more information on the path storage format, see
* [these git docs][git-index-docs]. Note that libgit2 will take care of
* handling the prefix compression mentioned there.
*
* [git-index-docs]: https://github.com/git/git/blob/a08a83db2bf27f015bec9a435f6d73e223c21c5e/Documentation/technical/index-format.txt#L107-L124
*/
path: Buffer
}
export interface IndexOnMatchCallbackArgs {
/** The path of entry. */
path: string
/** The patchspec that matched it. */
pathspec: string
}
export interface IndexAddAllOptions {
/**
* Files that are ignored will be skipped (unlike `addPath`). If a file is
* already tracked in the index, then it will be updated even if it is
* ignored. Pass the `force` flag to skip the checking of ignore rules.
*/
force?: boolean
/**
* The `pathspecs` are a list of file names or shell glob patterns that
* will matched against files in the repository's working directory. Each
* file that matches will be added to the index (either updating an
* existing entry or adding a new entry). You can disable glob expansion
* and force exact matching with the `disablePathspecMatch` flag.
*/
disablePathspecMatch?: boolean
/**
* To emulate `git add -A` and generate an error if the pathspec contains
* the exact path of an ignored file (when not using `force`), add the
* `checkPathspec` flag. This checks that each entry in `pathspecs`
* that is an exact match to a filename on disk is either not ignored or
* already in the index. If this check fails, the function will return
* an error.
*/
checkPathspec?: boolean
/**
* If you provide a callback function, it will be invoked on each matching
* item in the working directory immediately before it is added to /
* updated in the index. Returning zero will add the item to the index,
* greater than zero will skip the item, and less than zero will abort the
* scan an return an error to the caller.
*/
onMatch?: (args: IndexOnMatchCallbackArgs) => number
}
export type IndexStage = /** Match any index stage. */
'Any' | /** A normal staged file in the index. */
'Normal' | /** The ancestor side of a conflict. */
'Ancestor' | /** The "ours" side of a conflict. */
'Ours' | /** The "theirs" side of a conflict. */
'Theirs';
export interface IndexRemoveOptions {
stage?: IndexStage
}
export interface IndexRemoveAllOptions {
/**
* If you provide a callback function, it will be invoked on each matching
* item in the index immediately before it is removed. Return 0 to remove
* the item, > 0 to skip the item, and < 0 to abort the scan.
*/
onMatch?: (args: IndexOnMatchCallbackArgs) => number
}
export interface IndexUpdateAllOptions {
/**
* If you provide a callback function, it will be invoked on each matching
* item in the index immediately before it is updated (either refreshed or
* removed depending on working directory state). Return 0 to proceed with
* updating the item, > 0 to skip the item, and < 0 to abort the scan.
*/
onMatch?: (args: IndexOnMatchCallbackArgs) => number
}
/** An enumeration all possible kinds objects may have. */
export const enum ObjectType {
/** Any kind of git object */
Any = 0,
/** An object which corresponds to a git commit */
Commit = 1,
/** An object which corresponds to a git tree */
Tree = 2,
/** An object which corresponds to a git blob */
Blob = 3,
/** An object which corresponds to a git tag */
Tag = 4
}
/**
* Check if given string is valid Oid.
*
* Returns `false` if the string is empty, is longer than 40 hex
* characters, or contains any non-hex characters.
*/
export declare function isValidOid(value: string): boolean
/** Test if this Oid is all zeros. */
export declare function isZeroOid(value: string): boolean
/** Creates an all zero Oid structure. */
export declare function zeroOid(): string
/**
* Hashes the provided data as an object of the provided type, and returns
* an Oid corresponding to the result. This does not store the object
* inside any object database or repository.
*/
export declare function hashObjectOid(objType: ObjectType, bytes: Buffer): string
/**
* Hashes the content of the provided file as an object of the provided type,
* and returns an Oid corresponding to the result. This does not store the object
* inside any object database or repository.
*/
export declare function hashFileOid(objType: ObjectType, path: string): string
/** An enumeration of all possible kinds of references. */
export type ReferenceType = /** A reference which points at an object id. */
'Direct' | /** A reference which points at another reference. */
'Symbolic';
/**
* Ensure the reference name is well-formed.
*
* Validation is performed as if `ReferenceFormat.AllowOnelevel`
* was given to `normalizeReferenceName`
* No normalization is performed, however.
*
* @example
* ```ts
* import { isValidReferenceName } from 'es-git';
*
* console.assert(isValidReferenceName("HEAD"));
* console.assert(isValidReferenceName("refs/heads/main"));
*
* // But:
* console.assert(!isValidReferenceName("main"));
* console.assert(!isValidReferenceName("refs/heads/*"));
* console.assert(!isValidReferenceName("foo//bar"));
* ```
*/
export declare function isValidReferenceName(refname: string): boolean
/** Options for normalize reference name. */
export const enum ReferenceFormat {
/** No particular normalization. */
Normal = 0,
/**
* Control whether one-level refname are accepted (i.e., refnames that
* do not contain multiple `/`-separated components). Those are
* expected to be written only using uppercase letters and underscore
* (e.g. `HEAD`, `FETCH_HEAD`).
* (1 << 0)
*/
AllowOnelevel = 1,
/**
* Interpret the provided name as a reference pattern for a refspec (as
* used with remote repositories). If this option is enabled, the name
* is allowed to contain a single `*` in place of a full pathname
* components (e.g., `foo/*\/bar` but not `foo/bar*`).
* (1 << 1)
*/
RefspecPattern = 2,
/**
* Interpret the name as part of a refspec in shorthand form so the
* `AllowOnelevel` naming rules aren't enforced and `main` becomes a
* valid name.
* (1 << 2)
*/
RefspecShorthand = 4
}
/**
* Normalize reference name and check validity.
*
* This will normalize the reference name by collapsing runs of adjacent
* slashes between name components into a single slash. It also validates
* the name according to the following rules:
*
* 1. If `ReferenceFormat.AllowOnelevel` is given, the name may
* contain only capital letters and underscores, and must begin and end
* with a letter. (e.g. "HEAD", "ORIG_HEAD").
* 2. The flag `ReferenceFormat.RefspecShorthand` has an effect
* only when combined with `ReferenceFormat.AllowOnelevel`. If
* it is given, "shorthand" branch names (i.e. those not prefixed by
* `refs/`, but consisting of a single word without `/` separators)
* become valid. For example, "main" would be accepted.
* 3. If `ReferenceFormat.RefspecPattern` is given, the name may
* contain a single `*` in place of a full pathname component (e.g.
* `foo/*\/bar`, `foo/bar*`).
* 4. Names prefixed with "refs/" can be almost anything. You must avoid
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
* sequences ".." and "@{" which have special meaning to revparse.
*
* If the reference passes validation, it is returned in normalized form,
* otherwise an `null` is returned.
*
* @example
* ```ts
* import { normalizeReferenceName, ReferenceFormat } from 'es-git';
*
* console.assert(
* normalizeReferenceName('foo//bar"),
* 'foo/bar'
* );
* console.assert(
* normalizeReferenceName(
* 'HEAD',
* ReferenceFormat.AllowOnelevel
* ),
* 'HEAD'
* );
* console.assert(
* normalizeReferenceName(
* 'refs/heads/*',
* ReferenceFormat.RefspecPattern
* ),
* 'refs/heads/*'
* );
* console.assert(
* normalizeReferenceName(
* 'main',
* ReferenceFormat.AllowOnelevel | ReferenceFormat.RefspecShorthand
* ),
* 'main'
* );
* ```
*/
export declare function normalizeReferenceName(refname: string, format?: number | undefined | null): string | null
export interface RenameReferenceOptions {
/**
* If the force flag is not enabled, and there's already a reference with
* the given name, the renaming will fail.
*/
force?: boolean
logMessage?: string
}
/** An enumeration of the possible directions for a remote. */
export type Direction = 'Fetch' | 'Push';
/**
* A data object to represent a git [refspec][1].
*
* Refspecs are currently mainly accessed/created through a `Remote`.
*
* [1]: https://git-scm.com/book/en/Git-Internals-The-Refspec
*/
export interface Refspec {
direction: Direction
src: string
dst: string
force: boolean
}
/** Options which can be specified to various fetch operations. */
export interface ProxyOptions {
/**
* Try to auto-detect the proxy from the git configuration.
*
* Note that this will override `url` specified before.
*/
auto?: boolean
/**
* Specify the exact URL of the proxy to use.
*
* Note that this will override `auto` specified before.
*/
url?: string
}
/** Configuration for how pruning is done on a fetch. */
export type FetchPrune = /** Use the setting from the configuration */
'Unspecified' | /** Force pruning on */
'On' | /** Force pruning off */
'Off';
export type Credential = /** Create a "default" credential usable for Negotiate mechanisms like NTLM or Kerberos authentication.*/
{
type: 'Default';
} | /** Create a new ssh key credential object used for querying an ssh-agent.
The username specified is the username to authenticate.*/
{
type: 'SSHKeyFromAgent';
username?: string;
} | /** Create a new passphrase-protected ssh key credential object.*/
{
type: 'SSHKeyFromPath';
username?: string;
publicKeyPath?: string;
privateKeyPath: string;
passphrase?: string;
} | /** Create a new ssh key credential object reading the keys from memory.*/
{
type: 'SSHKey';
username?: string;
publicKey?: string;
privateKey: string;
passphrase?: string;
} | /** Create a new plain-text username and password credential object.*/
{
type: 'Plain';
username?: string;
password: string;
};
/** Automatic tag following options. */
export type AutotagOption = /** Use the setting from the remote's configuration */
'Unspecified' | /** Ask the server for tags pointing to objects we're already downloading */
'Auto' | /** Don't ask for any tags beyond the refspecs */
'None' | /** Ask for all the tags */
'All';
/**
* Remote redirection settings; whether redirects to another host are
* permitted.
*
* By default, git will follow a redirect on the initial request
* (`/info/refs`), but not subsequent requests.
*/
export type RemoteRedirect = /** Do not follow any off-site redirects at any stage of the fetch or push. */
'None' | /**
* Allow off-site redirects only upon the initial request. This is the
* default.
*/
'Initial' | /** Allow redirects at any stage in the fetch or push. */
'All';
/** Options which can be specified to various fetch operations. */
export interface FetchOptions {
credential?: Credential
/** Set the proxy options to use for the fetch operation. */
proxy?: ProxyOptions
/** Set whether to perform a prune after the fetch. */
prune?: FetchPrune
/**
* Set fetch depth, a value less or equal to 0 is interpreted as pull
* everything (effectively the same as not declaring a limit depth).
*/
depth?: number
/**
* Set how to behave regarding tags on the remote, such as auto-downloading
* tags for objects we're downloading or downloading all of them.
*
* The default is to auto-follow tags.
*/
downloadTags?: AutotagOption
/**
* Set remote redirection settings; whether redirects to another host are
* permitted.
*
* By default, git will follow a redirect on the initial request
* (`/info/refs`), but not subsequent requests.
*/
followRedirects?: RemoteRedirect
/** Set extra headers for this fetch operation. */
customHeaders?: Array<string>
}
/** Options to control the behavior of a git push. */
export interface PushOptions {
credential?: Credential
/** Set the proxy options to use for the push operation. */
proxy?: ProxyOptions
/**
* If the transport being used to push to the remote requires the creation
* of a pack file, this controls the number of worker threads used by the
* packbuilder when creating that pack file to be sent to the remote.
*
* If set to 0, the packbuilder will auto-detect the number of threads to
* create, and the default value is 1.
*/
pbParallelism?: number
/**
* Set remote redirection settings; whether redirects to another host are
* permitted.
*
* By default, git will follow a redirect on the initial request
* (`/info/refs`), but not subsequent requests.
*/
followRedirects?: RemoteRedirect
/** Set extra headers for this push operation. */
customHeaders?: Array<string>
/** Set "push options" to deliver to the remote. */
remoteOptions?: Array<string>
}
export interface CreateRemoteOptions {
fetchRefspec?: string
}
export interface FetchRemoteOptions {
fetch?: FetchOptions
reflogMsg?: string
}
export interface PruneOptions {
credential?: Credential
}
/** A listing of the possible states that a repository can be in. */
export type RepositoryState = 'Clean' | 'Merge' | 'Revert' | 'RevertSequence' | 'CherryPick' | 'CherryPickSequence' | 'Bisect' | 'Rebase' | 'RebaseInteractive' | 'RebaseMerge' | 'ApplyMailbox' | 'ApplyMailboxOrRebase';
/** Mode options for `RepositoryInitOptions`. */
export const enum RepositoryInitMode {
/** Use permissions configured by umask (default) */
SharedUnmask = 0,
/**
* Use `--shared=group` behavior, chmod'ing the new repo to be
* group writable and "g+sx" for sticky group assignment.
*/
SharedGroup = 1533,
/** Use `--shared=all` behavior, adding world readability. */
SharedAll = 1535
}
export interface RepositoryInitOptions {
/**
* Create a bare repository with no working directory.
*
* Defaults to `false`.
*/
bare?: boolean
/**
* Return an error if the repository path appears to already be a git
* repository.
*
* Defaults to `false`.
*/
noReinit?: boolean
/**
* Normally a '/.git/' will be appended to the repo path for non-bare repos
* (if it is not already there), but passing this flag prevents that
* behavior.
*
* Defaults to `false`.
*/
noDotgitDir?: boolean
/**
* Make the repo path (and workdir path) as needed. The ".git" directory
* will always be created regardless of this flag.
*
* Defaults to `true`.
*/
mkdir?: boolean
/**
* Make the repo path (and workdir path) as needed. The ".git" directory
* will always be created regardless of this flag.
*
* Defaults to `true`.
*/
mkpath?: boolean
/** Set to one of the `RepositoryInit` constants, or a custom value. */
mode?: number
/**
* Enable or disable using external templates.
*
* If enabled, then the `template_path` option will be queried first, then
* `init.templatedir` from the global config, and finally
* `/usr/share/git-core-templates` will be used (if it exists).
*
* Defaults to `true`.
*/
externalTemplate?: boolean
/**
* When the `externalTemplate` option is set, this is the first location
* to check for the template directory.
*
* If this is not configured, then the default locations will be searched
* instead.
*/
templatePath?: string
/**
* The path to the working directory.
*
* If this is a relative path it will be evaluated relative to the repo
* path. If this is not the "natural" working directory, a .git gitlink
* file will be created here linking to the repo path.
*/
workdirPath?: string
/**
* If set, this will be used to initialize the "description" file in the
* repository instead of using the template content.
*/
description?: string
/**
* The name of the head to point HEAD at.
*
* If not configured, this will be taken from your git configuration.
* If this begins with `refs/` it will be used verbatim;
* otherwise `refs/heads/` will be prefixed.
*/
initialHead?: string
/**
* If set, then after the rest of the repository initialization is
* completed an `origin` remote will be added pointing to this URL.
*/
originUrl?: string
}
/** Options which can be used to configure how a repository is initialized. */
export interface RepositoryOpenOptions {
/**
* If flags contains `RepositoryOpenFlags.NoSearch`, the path must point
* directly to a repository; otherwise, this may point to a subdirectory
* of a repository, and `open` will search up through parent
* directories.
*
* If flags contains `RepositoryOpenFlags.CrossFS`, the search through parent
* directories will not cross a filesystem boundary (detected when the
* stat st_dev field changes).
*
* If flags contains `RepositoryOpenFlags.Bare`, force opening the repository as
* bare even if it isn't, ignoring any working directory, and defer
* loading the repository configuration for performance.
*
* If flags contains `RepositoryOpenFlags.NoDotgit`, don't try appending
* `/.git` to `path`.
*
* If flags contains `RepositoryOpenFlags.FromEnv`, `open` will ignore
* other flags and `ceilingDirs`, and respect the same environment
* variables git does. Note, however, that `path` overrides `$GIT_DIR`.
*/
flags: number
/**
* ceiling_dirs specifies a list of paths that the search through parent
* directories will stop before entering.
*/
ceilingDirs?: Array<string>
}
/** Flags for opening repository. */
export const enum RepositoryOpenFlags {
/** Only open the specified path; don't walk upward searching. */
NoSearch = 1,
/** Search across filesystem boundaries. */
CrossFS = 2,
/** Force opening as a bare repository, and defer loading its config. */
Bare = 4,
/** Don't try appending `/.git` to the specified repository path. */
NoDotGit = 8,
/** Respect environment variables like `$GIT_DIR`. */
FromEnv = 16
}
export interface RepositoryCloneOptions {
/**
* Indicate whether the repository will be cloned as a bare repository or
* not.
*/
bare?: boolean
/**
* Specify the name of the branch to check out after the clone.
*
* If not specified, the remote's default branch will be used.
*/
branch?: string
/**
* Clone a remote repository, initialize and update its submodules
* recursively.
*
* This is similar to `git clone --recursive`.
*/
recursive?: boolean
/** Options which control the fetch. */
fetch?: FetchOptions
}
/** Creates a new repository in the specified folder. */
export declare function initRepository(path: string, options?: RepositoryInitOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
/** Attempt to open an already-existing repository at `path`. */
export declare function openRepository(path: string, options?: RepositoryOpenOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
/**
* Attempt to open an already-existing repository at or above `path`.
*
* This starts at `path` and looks up the filesystem hierarchy
* until it finds a repository.
*/
export declare function discoverRepository(path: string, signal?: AbortSignal | undefined | null): Promise<Repository>
/**
* Clone a remote repository.
*
* This will use the options configured so far to clone the specified URL
* into the specified local path.
*/
export declare function cloneRepository(url: string, path: string, options?: RepositoryCloneOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
/** Flags for the revparse. */
export const enum RevparseMode {
/** The spec targeted a single object */
Single = 1,
/** The spec targeted a range of commits */
Range = 2,
/** The spec used the `...` operator, which invokes special semantics. */
MergeBase = 4
}
/** Check revparse mode contains specific flags. */
export declare function revparseModeContains(source: number, target: number): boolean
/** A revspec represents a range of revisions within a repository. */
export interface Revspec {
/** Access the `from` range of this revspec. */
from?: string
/** Access the `to` range of this revspec. */
to?: string
/** Returns the intent of the revspec. */
mode: number
}
/** Orderings that may be specified for Revwalk iteration. */
export const enum RevwalkSort {
/**
* Sort the repository contents in no particular ordering.
*
* This sorting is arbitrary, implementation-specific, and subject to
* change at any time. This is the default sorting for new walkers.
*/
None = 0,
/**
* Sort the repository contents in topological order (children before
* parents).
*
* This sorting mode can be combined with time sorting.
*/
Topological = 1,
/**
* Sort the repository contents by commit time.
*
* This sorting mode can be combined with topological sorting.
*/
Time = 2,
/**
* Iterate through the repository contents in reverse order.
*
* This sorting mode can be combined with any others.
*/
Reverse = 4
}
/**
* A Signature is used to indicate authorship of various actions throughout the
* library.
*
* Signatures contain a name, email, and timestamp.
*/
export interface Signature {
/** Name on the signature. */
name: string
/** Email on the signature. */
email: string
/** Time in seconds, from epoch */
timestamp: number
}
export interface SignatureTimeOptions {
/** Time in seconds, from epoch */
timestamp: number
/** Timezone offset, in minutes */
offset?: number
}
/** Create a new action signature. */
export declare function createSignature(name: string, email: string, timeOptions?: SignatureTimeOptions | undefined | null): Signature
export interface SignaturePayload {
/** Name on the signature. */
name: string
/** Email on the signature. */
email: string
timeOptions?: SignatureTimeOptions
}
/**
* Determine whether a tag name is valid, meaning that (when prefixed with refs/tags/) that
* it is a valid reference name, and that any additional tag name restrictions are imposed
* (eg, it cannot start with a -).
*/
export declare function isValidTagName(tagName: string): boolean
export interface CreateTagOptions {
/**
* Signature for tagger.
*
* If not provided, default signature of repository will be used.
* If there is no default signature set for the repository, an error will occur.
*/
tagger?: SignaturePayload
force?: boolean
}
export interface CreateAnnotationTagOptions {
/**
* Signature for tagger.
*
* If not provided, default signature of repository will be used.
* If there is no default signature set for the repository, an error will occur.
*/
tagger?: SignaturePayload
}
export interface CreateLightweightTagOptions {
force?: boolean
}
/**
* A binary indicator of whether a tree walk should be performed in pre-order
* or post-order.
*/
export type TreeWalkMode = 'PreOrder' | 'PostOrder';
/**
* A class to represent a git [blob][1].
*
* [1]: https://git-scm.com/book/en/Git-Internals-Git-Objects
*/
export declare class Blob {
/** Get the id (SHA1) of a repository blob. */
id(): string
/** Determine if the blob content is most certainly binary or not. */
isBinary(): boolean
/** Get the content of this blob. */
content(): Uint8Array
/** Get the size in bytes of the contents of this blob. */
size(): bigint
}
/**
* A class to represent a git commit.
* @hideconstructor
*/
export declare class Commit {
/** Get the id (SHA1) of a repository commit */
id(): string
/** Get the author of this commit. */
author(): Signature
/** Get the committer of this commit. */
committer(): Signature
/**
* Get the full message of a commit.
*
* The returned message will be slightly prettified by removing any
* potential leading newlines.
*
* Throws error if the message is not valid utf-8.
*/
message(): string
/**
* Get the short "summary" of the git commit message.
*
* The returned message is the summary of the commit, comprising the first
* paragraph of the message with whitespace trimmed and squashed.
*
* Throws error if the summary is not valid utf-8.
*/
summary(): string | null
/**
* Get the long "body" of the git commit message.
*
* The returned message is the body of the commit, comprising everything
* but the first paragraph of the message. Leading and trailing whitespaces
* are trimmed.
*
* Throws error if the summary is not valid utf-8.
*/
body(): string | null
/** Get the commit time (i.e. committer time) of a commit. */
time(): Date
/** Get the tree pointed to by a commit. */
tree(): Tree
/** Casts this Commit to be usable as an `GitObject`. */
asObject(): GitObject
}
/**
* The diff object that contains all individual file deltas.
*
* This is an opaque structure which will be allocated by one of the diff
* generator functions on the `Repository` class (e.g. `diffTreeToTree`
* or other `diff*` functions).
*
* @hideconstructor
*/
export declare class Diff {
/**
* Merge one diff into another.
*
* This merges items from the "from" list into the "self" list. The
* resulting diff will have all items that appear in either list.
* If an item appears in both lists, then it will be "merged" to appear
* as if the old version was from the "onto" list and the new version
* is from the "from" list (with the exception that if the item has a
* pending DELETE in the middle, then it will show as deleted).
*/
merge(diff: Diff): void
/** Returns an iterator over the deltas in this diff. */
deltas(): Deltas
/** Check if deltas are sorted case sensitively or insensitively. */
isSortedIcase(): boolean
/** Accumulate diff statistics for all patches. */
stats(): DiffStats
/** Iterate over a diff generating formatted text output. */
print(options?: DiffPrintOptions | undefined | null): string
}
/**
* A class describing a hunk of a diff.
*
* @hideconstructor
*/
export declare class DiffStats {
/** Get the total number of files changed in a diff. */
get filesChanged(): bigint
/** Get the total number of insertions in a diff */
get insertions(): bigint
/** Get the total number of deletions in a diff */
get deletions(): bigint
}
/**