-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.d.ts
More file actions
1335 lines (1293 loc) · 42.3 KB
/
index.d.ts
File metadata and controls
1335 lines (1293 loc) · 42.3 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
/* auto-generated by NAPI-RS */
/* eslint-disable */
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
}
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
}
/**
* An iterator over the diffs in a delta
*
* This type extends JavaScript's `Iterator`, and so has the iterator helper
* methods. It may extend the upcoming TypeScript `Iterator` class in the future.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helper_methods
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-6.html#iterator-helper-methods
*/
export declare class Deltas extends Iterator<DiffDelta, void, void> {
next(value?: void): IteratorResult<DiffDelta, void>
}
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 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 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 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 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 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. git@github.com: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("git@github.com: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 RepoBuilder {
constructor()
/**
* Indicate whether the repository will be cloned as a bare repository or
* not.
*/
bare(bare: boolean): this
/**
* Specify the name of the branch to check out after the clone.
*
* If not specified, the remote's default branch will be used.
*/
branch(branch: string): this
/**
* Configures options for bypassing the git-aware transport on clone.
*
* Bypassing it means that instead of a fetch libgit2 will copy the object
* database directory instead of figuring out what it needs, which is
* faster. If possible, it will hardlink the files to save space.
*/
cloneLocal(cloneLocal: CloneLocal): this
/**
* Options which control the fetch, including callbacks.
*
* The callbacks are used for reporting fetch progress, and for acquiring
* credentials in the event they are needed.
*/
fetchOptions(fetchOptions: FetchOptions): this
clone(url: string, path: string): Repository
}
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
/** Lookup a tag object by prefix hash from the repository. */
findTagByPrefix(prefixHash: 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
*/
tagForeach(cb: (arg0: string, arg1: Buffer) => boolean): void
/**
* Create a diff between a tree and the working directory.
*
* The tree you provide will be used for the "old_file" side of the delta,
* and the working directory will be used for the "new_file" side.
*
* This is not the same as `git diff <treeish>` or `git diff-index
* <treeish>`. Those commands use information from the index, whereas this
* function strictly returns the differences between the tree and the files
* in the working directory, regardless of the state of the index. Use
* `tree_to_workdir_with_index` to emulate those commands.
*
* To see difference between this and `tree_to_workdir_with_index`,
* consider the example of a staged file deletion where the file has then
* been put back into the working dir and further modified. The
* tree-to-workdir diff for that file is 'modified', but `git diff` would
* show status 'deleted' since there is a staged delete.
*
* If `None` is passed for `tree`, then an empty tree is used.
*/
diffTreeToWorkdir(oldTree?: Tree | undefined | null): Diff
/**
* Create a diff between a tree and the working directory using index data
* to account for staged deletes, tracked files, etc.
*
* This emulates `git diff <tree>` by diffing the tree to the index and
* the index to the working directory and blending the results into a
* single diff that includes staged deleted, etc.
*/
diffTreeToWorkdirWithIndex(oldTree?: Tree | undefined | null): Diff
treeEntryToObject(treeEntry: TreeEntry): GitObject
/**
* Create new commit in the repository
*
* If the `update_ref` is not `None`, name of the reference that will be
* updated to point to this commit. If the reference is not direct, it will
* be resolved to a direct reference. Use "HEAD" to update the HEAD of the
* current branch and make it point to this commit. If the reference
* doesn't exist yet, it will be created. If it does exist, the first
* parent must be the tip of this branch.
*/
commit(updateRef: string | undefined | null, author: Signature, committer: Signature, message: string, tree: Tree): string
/** Create a revwalk that can be used to traverse the commit graph. */
revWalk(): RevWalk
getFileLatestModifiedDate(filepath: string): number
getFileLatestModifiedDateAsync(filepath: string, signal?: AbortSignal | undefined | null): Promise<number>
getFileCreatedDate(filepath: string): number
getFileCreatedDateAsync(filepath: string, signal?: AbortSignal | undefined | null): Promise<number>
}
/**
* This type extends JavaScript's `Iterator`, and so has the iterator helper
* methods. It may extend the upcoming TypeScript `Iterator` class in the future.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helper_methods
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-6.html#iterator-helper-methods
*/
export declare class RevWalk extends Iterator<string, void, void> {
/**
* Reset a revwalk to allow re-configuring it.
*
* The revwalk is automatically reset when iteration of its commits
* completes.
*/
reset(): this
/** Set the sorting mode for a revwalk. */
setSorting(sorting: Sort): this
/**
* Simplify the history by first-parent
*
* No parents other than the first for each commit will be enqueued.
*/
simplifyFirstParent(): this
/**
* Mark a commit to start traversal from.
*
* The given OID must belong to a commitish on the walked repository.
*
* The given commit will be used as one of the roots when starting the
* revision walk. At least one commit must be pushed onto the walker before
* a walk can be started.
*/
push(oid: string): this
/**
* Push the repository's HEAD
*
* For more information, see `push`.
*/
pushHead(): this
/**
* Push matching references
*
* The OIDs pointed to by the references that match the given glob pattern
* will be pushed to the revision walker.
*
* A leading 'refs/' is implied if not present as well as a trailing `/ \
* *` if the glob lacks '?', ' \ *' or '['.
*
* Any references matching this glob which do not point to a commitish
* will be ignored.
*/
pushGlob(glob: string): this
/**
* Push and hide the respective endpoints of the given range.
*
* The range should be of the form `<commit>..<commit>` where each
* `<commit>` is in the form accepted by `revparse_single`. The left-hand
* commit will be hidden and the right-hand commit pushed.
*/
pushRange(range: string): this
/**
* Push the OID pointed to by a reference
*
* The reference must point to a commitish.
*/
pushRef(reference: string): this
/** Mark a commit as not of interest to this revwalk. */
hide(oid: string): this
/**
* Hide the repository's HEAD
*
* For more information, see `hide`.
*/
hideHead(): this
/**
* Hide matching references.
*
* The OIDs pointed to by the references that match the given glob pattern
* and their ancestors will be hidden from the output on the revision walk.
*
* A leading 'refs/' is implied if not present as well as a trailing `/ \
* *` if the glob lacks '?', ' \ *' or '['.
*
* Any references matching this glob which do not point to a commitish
* will be ignored.
*/
hideGlob(glob: string): this
/**
* Hide the OID pointed to by a reference.
*
* The reference must point to a commitish.
*/
hideRef(reference: string): this
next(value?: void): IteratorResult<string, void>
}
/**
* A Signature is used to indicate authorship of various actions throughout the
* library.
*
* Signatures contain a name, email, and timestamp. All fields can be specified
* with `new` while the `now` constructor omits the timestamp. The
* [`Repository::signature`] method can be used to create a default signature
* with name and email values read from the configuration.
*
* [`Repository::signature`]: struct.Repository.html#method.signature
*/
export declare class Signature {
/**
* Create a new action signature with a timestamp of 'now'.
*
* See `new` for more information
*/
static now(name: string, email: string): Signature
/**
* Create a new action signature.
*
* The `time` specified is in seconds since the epoch, and the `offset` is
* the time zone offset in minutes.
*
* Returns error if either `name` or `email` contain angle brackets.
*/
constructor(name: string, email: string, time: number)
/**
* Gets the name on the signature.
*
* Returns `None` if the name is not valid utf-8
*/
name(): string | null
/**
* Gets the email on the signature.
*
* Returns `None` if the email is not valid utf-8
*/
email(): string | null
/** Return the time, in seconds, from epoch */
when(): number
}
export declare class Tag {
/**
* 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 -).
*/
static isValidName(name: string): boolean
/** Get the id (SHA1) of a repository object */
id(): string
/**
* Get the message of a tag