-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
1271 lines (1269 loc) · 40.6 KB
/
index.d.ts
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 const enum DiffFlags {
/**
* File(s) treated as binary data.
* 1 << 0
*/
Binary = 1,
/**
* File(s) treated as text data.
* 1 << 1
*/
NotBinary = 2,
/**
* `id` value is known correct.
* 1 << 2
*/
ValidId = 4,
/**
* File exists at this side of the delta.
* 1 << 3
*/
Exists = 8
}
/** Valid modes for index and tree entries. */
export const enum FileMode {
/** Unreadable */
Unreadable = 0,
/** Tree */
Tree = 1,
/** Blob */
Blob = 2,
/** Group writable blob. Obsolete mode kept for compatibility reasons */
BlobGroupWritable = 3,
/** Blob executable */
BlobExecutable = 4,
/** Link */
Link = 5,
/** Commit */
Commit = 6
}
export const enum Delta {
/** No changes */
Unmodified = 0,
/** Entry does not exist in old version */
Added = 1,
/** Entry does not exist in new version */
Deleted = 2,
/** Entry content changed between old and new */
Modified = 3,
/** Entry was renamed between old and new */
Renamed = 4,
/** Entry was copied from another old entry */
Copied = 5,
/** Entry is ignored item in workdir */
Ignored = 6,
/** Entry is untracked item in workdir */
Untracked = 7,
/** Type of entry changed between old and new */
Typechange = 8,
/** Entry is unreadable */
Unreadable = 9,
/** Entry in the index is conflicted */
Conflicted = 10
}
export interface DiffOptions {
/**
* 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
}
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
}
/** An enumeration of all possible kinds of references. */
export const enum ReferenceType {
/** A reference which points at an object id. */
Direct = 0,
/** A reference which points at another reference. */
Symbolic = 1,
Unknown = 2
}
/** An enumeration of the possible directions for a remote. */
export const enum Direction {
/** Data will be fetched (read) from this remote. */
Fetch = 0,
/** Data will be pushed (written) to this remote. */
Push = 1
}
/** Configuration for how pruning is done on a fetch */
export const enum FetchPrune {
/** Use the setting from the configuration */
Unspecified = 0,
/** Force pruning on */
On = 1,
/** Force pruning off */
Off = 2
}
/** Automatic tag following options. */
export const enum AutotagOption {
/** Use the setting from the remote's configuration */
Unspecified = 0,
/** Ask the server for tags pointing to objects we're already downloading */
Auto = 1,
/** Don't ask for any tags beyond the refspecs */
None = 2,
/** Ask for all the tags */
All = 3
}
/**
* 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 const enum RemoteRedirect {
/** Do not follow any off-site redirects at any stage of the fetch or push. */
None = 0,
/**
* Allow off-site redirects only upon the initial request. This is the
* default.
*/
Initial = 1,
/** Allow redirects at any stage in the fetch or push. */
All = 2
}
/** Types of credentials that can be requested by a credential callback. */
export const enum CredentialType {
/** 1 << 0 */
UserPassPlaintext = 1,
/** 1 << 1 */
SshKey = 2,
/** 1 << 6 */
SshMemory = 64,
/** 1 << 2 */
SshCustom = 4,
/** 1 << 3 */
Default = 8,
/** 1 << 4 */
SshInteractive = 16,
/** 1 << 5 */
Username = 32
}
export interface CredInfo {
credType: CredentialType
url: string
username: string
}
export const enum RemoteUpdateFlags {
UpdateFetchHead = 1,
ReportUnchanged = 2
}
export interface Progress {
totalObjects: number
indexedObjects: number
receivedObjects: number
localObjects: number
totalDeltas: number
indexedDeltas: number
receivedBytes: number
}
export interface PushTransferProgress {
current: number
total: number
bytes: number
}
/** Check whether a cred_type contains another credential type. */
export function credTypeContains(credType: CredentialType, another: CredentialType): boolean
export const enum RepositoryState {
Clean = 0,
Merge = 1,
Revert = 2,
RevertSequence = 3,
CherryPick = 4,
CherryPickSequence = 5,
Bisect = 6,
Rebase = 7,
RebaseInteractive = 8,
RebaseMerge = 9,
ApplyMailbox = 10,
ApplyMailboxOrRebase = 11
}
export const enum RepositoryOpenFlags {
/** Only open the specified path; don't walk upward searching. */
NoSearch = 0,
/** Search across filesystem boundaries. */
CrossFS = 1,
/** Force opening as bare repository, and defer loading its config. */
Bare = 2,
/** Don't try appending `/.git` to the specified repository path. */
NoDotGit = 3,
/** Respect environment variables like `$GIT_DIR`. */
FromEnv = 4
}
export const enum CloneLocal {
/**
* Auto-detect (default)
*
* Here libgit2 will bypass the git-aware transport for local paths, but
* use a normal fetch for `file://` URLs.
*/
Auto = 0,
/** Bypass the git-aware transport even for `file://` URLs. */
Local = 1,
/** Never bypass the git-aware transport */
None = 2,
/** Bypass the git-aware transport, but don't try to use hardlinks. */
NoLinks = 3
}
/** Orderings that may be specified for Revwalk iteration. */
export const enum Sort {
/**
* 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.
* 1 << 0
*/
Topological = 1,
/**
* Sort the repository contents by commit time.
*
* This sorting mode can be combined with topological sorting.
* 1 << 1
*/
Time = 2,
/**
* Iterate through the repository contents in reverse order.
*
* This sorting mode can be combined with any others.
* 1 << 2
*/
Reverse = 4
}
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
}
export declare class Commit {
/** Get the id (SHA1) of a repository object */
id(): string
/**
* Get the id of the tree pointed to by this commit.
*
* No attempts are made to fetch an object from the ODB.
*/
treeId(): string
/** Get the tree pointed to by this commit. */
tree(): Tree
/**
*
* The returned message will be slightly prettified by removing any
* potential leading newlines.
*
* `None` will be returned if the message is not valid utf-8
*/
message(): string | null
/**
* Get the full message of a commit as a byte slice.
*
* The returned message will be slightly prettified by removing any
* potential leading newlines.
*/
messageBytes(): Buffer
/**
* Get the encoding for the message of a commit, as a string representing a
* standard encoding name.
*
* `None` will be returned if the encoding is not known
*/
messageEncoding(): string | null
/**
* Get the full raw message of a commit.
*
* `None` will be returned if the message is not valid utf-8
*/
messageRaw(): string | null
/** Get the full raw message of a commit. */
messageRawBytes(): Buffer
/**
* Get the full raw text of the commit header.
*
* `None` will be returned if the message is not valid utf-8
*/
rawHeader(): string | null
/** Get an arbitrary header field. */
headerFieldBytes(field: string): Buffer
/** Get the full raw text of the commit header. */
rawHeaderBytes(): Buffer
/**
* 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.
*
* `None` may be returned if an error occurs or if the summary is not valid
* utf-8.
*/
summary(): string | null
/**
* 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.
*
* `None` may be returned if an error occurs
*/
summaryBytes(): Buffer | 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.
*
* `None` may be returned if an error occurs or if the summary is not valid
* utf-8.
*/
body(): 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.
*
* `None` may be returned if an error occurs.
*/
bodyBytes(): Buffer | null
/**
* Get the commit time (i.e. committer time) of a commit.
*
* The first element of the tuple is the time, in seconds, since the epoch.
* The second element is the offset, in minutes, of the time zone of the
* committer's preferred time zone.
*/
time(): Date
/** Get the author of this commit. */
author(): Signature
/** Get the committer of this commit. */
committer(): Signature
/**
* Amend this existing commit with all non-`None` values
*
* This creates a new commit that is exactly the same as the old commit,
* except that any non-`None` values will be updated. The new commit has
* the same parents as the old commit.
*
* For information about `update_ref`, see [`Repository::commit`].
*
* [`Repository::commit`]: struct.Repository.html#method.commit
*/
amend(updateRef?: string | undefined | null, author?: Signature | undefined | null, committer?: Signature | undefined | null, messageEncoding?: string | undefined | null, message?: string | undefined | null, tree?: Tree | undefined | null): string
/**
* Get the number of parents of this commit.
*
* Use the `parents` iterator to return an iterator over all parents.
*/
parentCount(): bigint
/**
* Get the specified parent of the commit.
*
* Use the `parents` iterator to return an iterator over all parents.
*/
parent(i: number): Commit
/**
* Get the specified parent id of the commit.
*
* This is different from `parent`, which will attempt to load the
* parent commit from the ODB.
*
* Use the `parent_ids` iterator to return an iterator over all parents.
*/
parentId(i: number): string
/** Casts this Commit to be usable as an `Object` */
asObject(): GitObject
}
/** An iterator over the diffs in a delta */
export declare class Deltas {
[Symbol.iterator](): Iterator<DiffDelta, void, void>
}
export declare class DiffDelta {
/**
* Returns the flags on the delta.
*
* For more information, see `DiffFlags`'s documentation.
*/
flags(): DiffFlags
/** Returns the number of files in this delta. */
numFiles(): number
/** Returns the status of this entry */
status(): Delta
/**
* Return the file which represents the "from" side of the diff.
*
* What side this means depends on the function that was used to generate
* the diff and will be documented on the function itself.
*/
oldFile(): DiffFile
/**
* Return the file which represents the "to" side of the diff.
*
* What side this means depends on the function that was used to generate
* the diff and will be documented on the function itself.
*/
newFile(): DiffFile
}
export declare class DiffFile {
/**
* Returns the Oid of this item.
*
* If this entry represents an absent side of a diff (e.g. the `old_file`
* of a `Added` delta), then the oid returned will be zeroes.
*/
id(): string
/**
* Returns the path, in bytes, of the entry relative to the working
* directory of the repository.
*/
path(): string | null
/** Returns the size of this entry, in bytes */
size(): bigint
/** Returns `true` if file(s) are treated as binary data. */
isBinary(): boolean
/** Returns `true` if file(s) are treated as text data. */
isNotBinary(): boolean
/** Returns `true` if `id` value is known correct. */
isValidId(): boolean
/** Returns `true` if file exists at this side of the delta. */
exists(): boolean
/** Returns file mode. */
mode(): FileMode
}
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
}
export declare class GitObject {
/** Get the id (SHA1) of a repository object */
id(): string
/** Get the type of the object. */
kind(): ObjectType | null
/**
* Recursively peel an object until an object of the specified type is met.
*
* If you pass `Any` as the target type, then the object will be
* peeled until the type changes (e.g. a tag will be chased until the
* referenced object is no longer a tag).
*/
peel(kind: ObjectType): GitObject
/** Recursively peel an object until a blob is found */
peelToBlob(): Blob
}
export declare class Reference {
/**
* Ensure the reference name is well-formed.
*
* Validation is performed as if [`ReferenceFormat::ALLOW_ONELEVEL`]
* was given to [`Reference.normalize_name`]. No normalization is
* performed, however.
*
* ```ts
* import { Reference } from '@napi-rs/simple-git'
*
* console.assert(Reference.is_valid_name("HEAD"));
* console.assert(Reference.is_valid_name("refs/heads/main"));
*
* // But:
* console.assert(!Reference.is_valid_name("main"));
* console.assert(!Reference.is_valid_name("refs/heads/*"));
* console.assert(!Reference.is_valid_name("foo//bar"));
* ```
*/
static isValidName(name: string): boolean
/** Check if a reference is a local branch. */
isBranch(): boolean
/** Check if a reference is a note. */
isNote(): boolean
/** Check if a reference is a remote tracking branch */
isRemote(): boolean
/** Check if a reference is a tag */
isTag(): boolean
kind(): ReferenceType
/**
* Get the full name of a reference.
*
* Returns `None` if the name is not valid utf-8.
*/
name(): string | null
/**
* Get the full shorthand of a reference.
*
* This will transform the reference name into a name "human-readable"
* version. If no shortname is appropriate, it will return the full name.
*
* Returns `None` if the shorthand is not valid utf-8.
*/
shorthand(): string | null
/**
* Get the OID pointed to by a direct reference.
*
* Only available if the reference is direct (i.e. an object id reference,
* not a symbolic one).
*/
target(): string | null
/**
* Return the peeled OID target of this reference.
*
* This peeled OID only applies to direct references that point to a hard
* Tag object: it is the result of peeling such Tag.
*/
targetPeel(): string | null
/**
* Peel a reference to a tree
*
* This method recursively peels the reference until it reaches
* a tree.
*/
peelToTree(): Tree
/**
* Get full name to the reference pointed to by a symbolic reference.
*
* May return `None` if the reference is either not symbolic or not a
* valid utf-8 string.
*/
symbolicTarget(): string | null
/**
* Resolve a symbolic reference to a direct reference.
*
* This method iteratively peels a symbolic reference until it resolves to
* a direct reference to an OID.
*
* If a direct reference is passed as an argument, a copy of that
* reference is returned.
*/
resolve(): Reference
/**
* Rename an existing reference.
*
* This method works for both direct and symbolic references.
*
* If the force flag is not enabled, and there's already a reference with
* the given name, the renaming will fail.
*/
rename(newName: string, force: boolean, msg: string): Reference
}
export declare class Remote {
/** Ensure the remote name is well-formed. */
static isValidName(name: string): boolean
/**
* Get the remote's name.
*
* Returns `None` if this remote has not yet been named or if the name is
* not valid utf-8
*/
name(): string | null
/**
* Get the remote's url.
*
* Returns `None` if the url is not valid utf-8
*/
url(): string | null
/**
* Get the remote's pushurl.
*
* Returns `None` if the pushurl is not valid utf-8
*/
pushurl(): string | null
/**
* Get the remote's default branch.
*
* The remote (or more exactly its transport) must have connected to the
* remote repository. This default branch is available as soon as the
* connection to the remote is initiated and it remains available after
* disconnecting.
*/
defaultBranch(): string
/** Open a connection to a remote. */
connect(dir: Direction): void
/** Check whether the remote is connected */
connected(): boolean
/** Disconnect from the remote */
disconnect(): void
/**
* Cancel the operation
*
* At certain points in its operation, the network code checks whether the
* operation has been cancelled and if so stops the operation.
*/
stop(): void
/**
* Download new data and update tips
*
* Convenience function to connect to a remote, download the data,
* disconnect and update the remote-tracking branches.
*
*/
fetch(refspecs: Array<string>, fetchOptions?: FetchOptions | undefined | null): void
/** Update the tips to the new state */
updateTips(updateFetchhead: RemoteUpdateFlags, downloadTags: AutotagOption, callbacks?: RemoteCallbacks | undefined | null, msg?: string | undefined | null): void
}
export declare class RemoteCallbacks {
constructor()
/**
* The callback through which to fetch credentials if required.
*
* # Example
*
* Prepare a callback to authenticate using the `$HOME/.ssh/id_rsa` SSH key, and
* extracting the username from the URL (i.e. [email protected]:rust-lang/git2-rs.git):
*
* ```js
* import { join } from 'node:path'
* import { homedir } from 'node:os'
*
* import { Cred, FetchOptions, RemoteCallbacks, RepoBuilder, credTypeContains } from '@napi-rs/simple-git'
*
* const builder = new RepoBuilder()
* const remoteCallbacks = new RemoteCallbacks()
* .credentials((cred) => {
* return Cred.sshKey(cred.username, null, join(homedir(), '.ssh', 'id_rsa'), null)
* })
*
* const fetchOptions = new FetchOptions().depth(0).remoteCallback(remoteCallbacks)
*
* const repo = builder.branch('master')
* .fetchOptions(fetchOptions)
* .clone("[email protected]:rust-lang/git2-rs.git", "git2-rs")
* ```
*/
credentials(callback: (arg: CredInfo) => Cred): this
/** The callback through which progress is monitored. */
transferProgress(callback: (arg: Progress) => void): this
/** The callback through which progress of push transfer is monitored */
pushTransferProgress(callback: (current: number, total: number, bytes: number) => void): this
}
export declare class FetchOptions {
constructor()
/** Set the callbacks to use for the fetch operation. */
remoteCallback(callback: RemoteCallbacks): this
/** Set the proxy options to use for the fetch operation. */
proxyOptions(options: ProxyOptions): this
/** Set whether to perform a prune after the fetch. */
prune(prune: FetchPrune): this
/**
* Set whether to write the results to FETCH_HEAD.
*
* Defaults to `true`.
*/
updateFetchhead(update: boolean): this
/**
* 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(depth: number): this
/**
* 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(opt: AutotagOption): this
/**
* 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(opt: RemoteRedirect): this
/** Set extra headers for this fetch operation. */
customHeaders(headers: Array<string>): this
}
export declare class ProxyOptions {
constructor()
/**
* Try to auto-detect the proxy from the git configuration.
*
* Note that this will override `url` specified before.
*/
auto(): this
/**
* Specify the exact URL of the proxy to use.
*
* Note that this will override `auto` specified before.
*/
url(url: string): this
}
export declare class Cred {
/**
* Create a "default" credential usable for Negotiate mechanisms like NTLM
* or Kerberos authentication.
*/
constructor()
/**
* Create a new ssh key credential object used for querying an ssh-agent.
*
* The username specified is the username to authenticate.
*/
static sshKeyFromAgent(username: string): Cred
/** Create a new passphrase-protected ssh key credential object. */
static sshKey(username: string, publickey: string | undefined | null, privatekey: string, passphrase?: string | undefined | null): Cred
/** Create a new ssh key credential object reading the keys from memory. */
static sshKeyFromMemory(username: string, publickey: string | undefined | null, privatekey: string, passphrase?: string | undefined | null): Cred
/** Create a new plain-text username and password credential object. */
static userpassPlaintext(username: string, password: string): Cred
/**
* Create a credential to specify a username.
*
* This is used with ssh authentication to query for the username if none is
* specified in the URL.
*/
static username(username: string): Cred
/** Check whether a credential object contains username information. */
hasUsername(): boolean
/** Return the type of credentials that this object represents. */
credtype(): CredentialType
}
export declare class Repository {
static init(p: string): Repository
/**
* Find and open an existing repository, with additional options.
*
* If flags contains REPOSITORY_OPEN_NO_SEARCH, the path must point
* directly to a repository; otherwise, this may point to a subdirectory
* of a repository, and `open_ext` will search up through parent
* directories.
*
* If flags contains REPOSITORY_OPEN_CROSS_FS, the search through parent
* directories will not cross a filesystem boundary (detected when the
* stat st_dev field changes).
*
* If flags contains REPOSITORY_OPEN_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 REPOSITORY_OPEN_NO_DOTGIT, don't try appending
* `/.git` to `path`.
*
* If flags contains REPOSITORY_OPEN_FROM_ENV, `open_ext` will ignore
* other flags and `ceiling_dirs`, and respect the same environment
* variables git does. Note, however, that `path` overrides `$GIT_DIR`; to
* respect `$GIT_DIR` as well, use `open_from_env`.
*
* ceiling_dirs specifies a list of paths that the search through parent
* directories will stop before entering. Use the functions in std::env
* to construct or manipulate such a path list.
*/
static openExt(path: string, flags: RepositoryOpenFlags, ceilingDirs: Array<string>): 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.
*/
static discover(path: string): Repository
/**
* Creates a new `--bare` repository in the specified folder.
*
* The folder must exist prior to invoking this function.
*/
static initBare(path: string): Repository
/**
* Clone a remote repository.
*
* See the `RepoBuilder` struct for more information. This function will
* delegate to a fresh `RepoBuilder`
*/
static clone(url: string, path: string): Repository
/**
* Clone a remote repository, initialize and update its submodules
* recursively.
*
* This is similar to `git clone --recursive`.
*/
static cloneRecurse(url: string, path: string): Repository
/**
* Attempt to open an already-existing repository at `path`.
*
* The path can point to either a normal or bare repository.
*/
constructor(gitDir: string)
/** Retrieve and resolve the reference pointed at by HEAD. */
head(): Reference
/** Tests whether this repository is a shallow clone. */
isShallow(): boolean
/** Tests whether this repository is empty. */
isEmpty(): boolean
/** Tests whether this repository is a worktree. */
isWorktree(): boolean
/**
* Returns the path to the `.git` folder for normal repositories or the
* repository itself for bare repositories.
*/
path(): string
/** Returns the current state of this repository */
state(): RepositoryState
/**
* Get the path of the working directory for this repository.
*
* If this repository is bare, then `None` is returned.
*/
workdir(): string | null
/**
* Set the path to the working directory for this repository.
*
* If `update_link` is true, create/update the gitlink file in the workdir
* and set config "core.worktree" (if workdir is not the parent of the .git
* directory).
*/
setWorkdir(path: string, updateGitlink: boolean): void
/**
* Get the currently active namespace for this repository.
*
* If there is no namespace, or the namespace is not a valid utf8 string,
* `None` is returned.
*/
namespace(): string | null
/** Set the active namespace for this repository. */
setNamespace(namespace: string): void
/** Remove the active namespace for this repository. */
removeNamespace(): void
/**
* Retrieves the Git merge message.
* Remember to remove the message when finished.
*/
message(): string
/** Remove the Git merge message. */
removeMessage(): void
/** List all remotes for a given repository */
remotes(): Array<string>
/** Get the information for a particular remote */
findRemote(name: string): Remote | null
/**
* Add a remote with the default fetch refspec to the repository's
* configuration.
*/
remote(name: string, url: string): Remote
/**
* Add a remote with the provided fetch refspec to the repository's
* configuration.
*/
remoteWithFetch(name: string, url: string, refspect: string): Remote
/**
* Create an anonymous remote
*
* Create a remote with the given URL and refspec in memory. You can use
* this when you have a URL instead of a remote's name. Note that anonymous
* remotes cannot be converted to persisted remotes.
*/
remoteAnonymous(url: string): Remote
/**
* Give a remote a new name
*
* All remote-tracking branches and configuration settings for the remote
* are updated.
*
* A temporary in-memory remote cannot be given a name with this method.
*
* No loaded instances of the remote with the old name will change their
* name or their list of refspecs.
*
* The returned array of strings is a list of the non-default refspecs
* which cannot be renamed and are returned for further processing by the
* caller.
*/
remoteRename(name: string, newName: string): Array<string>
/**
* Delete an existing persisted remote.
*
* All remote-tracking branches and configuration settings for the remote
* will be removed.
*/
remoteDelete(name: string): this
/**
* Add a fetch refspec to the remote's configuration
*
* Add the given refspec to the fetch list in the configuration. No loaded
*/
remoteAddFetch(name: string, refspec: string): this
/**
* Add a push refspec to the remote's configuration.
*
* Add the given refspec to the push list in the configuration. No
* loaded remote instances will be affected.
*/
remoteAddPush(name: string, refspec: string): this
/**
* Add a push refspec to the remote's configuration.
*
* Add the given refspec to the push list in the configuration. No
* loaded remote instances will be affected.
*/
remoteSetUrl(name: string, url: string): this
/**
* Set the remote's URL for pushing in the configuration.
*
* Remote objects already in memory will not be affected. This assumes
* the common case of a single-url remote and will otherwise return an
* error.
*
* `None` indicates that it should be cleared.
*/
remoteSetPushurl(name: string, url?: string | undefined | null): this
/** Lookup a reference to one of the objects in a repository. */
findTree(oid: string): Tree | null
findCommit(oid: string): Commit | null
/**
* Create a new tag in the repository from an object
*
* A new reference will also be created pointing to this tag object. If
* `force` is true and a reference already exists with the given name,
* it'll be replaced.
*
* The message will not be cleaned up.
*
* The tag name will be checked for validity. You must avoid the characters
* '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @
* {" which have special meaning to revparse.
*/
tag(name: string, target: GitObject, tagger: Signature, message: string, force: boolean): string
/**
* Create a new tag in the repository from an object without creating a reference.
*
* The message will not be cleaned up.
*
* The tag name will be checked for validity. You must avoid the characters
* '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @
* {" which have special meaning to revparse.
*/
tagAnnotationCreate(name: string, target: GitObject, tagger: Signature, message: string): string
/**
* Create a new lightweight tag pointing at a target object
*
* A new direct reference will be created pointing to this target object.
* If force is true and a reference already exists with the given name,
* it'll be replaced.
*/
tagLightweight(name: string, target: GitObject, force: boolean): string
/** Lookup a tag object from the repository. */
findTag(oid: string): Tag
/**
* Delete an existing tag reference.
*
* The tag name will be checked for validity, see `tag` for some rules
* about valid names.
*/
tagDelete(name: string): void
/**
* Get a list with all the tags in the repository.
*
* An optional fnmatch pattern can also be specified.
*/
tagNames(pattern?: string | undefined | null): Array<string>
/**
* iterate over all tags calling `cb` on each.
* the callback is provided the tag id and name
*/