es-git 0.0.12 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -8,59 +8,299 @@ export interface CommitOptions {
8
8
  /**
9
9
  * Signature for author.
10
10
  *
11
- * If not provided, default signature of repository will be used.
11
+ * If not provided, the default signature of the repository will be used.
12
12
  * If there is no default signature set for the repository, an error will occur.
13
13
  */
14
14
  author?: SignaturePayload
15
15
  /**
16
16
  * Signature for commiter.
17
17
  *
18
- * If not provided, default signature of repository will be used.
18
+ * If not provided, the default signature of the repository will be used.
19
19
  * If there is no default signature set for the repository, an error will occur.
20
20
  */
21
21
  committer?: SignaturePayload
22
22
  parents?: Array<string>
23
23
  }
24
- export const enum DiffFlags {
25
- /** File(s) treated as binary data. (1 << 0) */
24
+ /**
25
+ * - `ProgramData` : System-wide on Windows, for compatibility with portable git.
26
+ * - `System` : System-wide configuration file. (e.g. `/etc/gitconfig`)
27
+ * - `XDG` : XDG-compatible configuration file. (e.g. `~/.config/git/config`)
28
+ * - `Global` : User-specific configuration. (e.g. `~/.gitconfig`)
29
+ * - `Local` : Repository specific config. (e.g. `$PWD/.git/config`)
30
+ * - `Worktree` : Worktree specific configuration file. (e.g. `$GIT_DIR/config.worktree`)
31
+ * - `App` : Application specific configuration file.
32
+ * - `Highest` : Highest level available.
33
+ */
34
+ export type ConfigLevel = 'ProgramData' | 'System' | 'XDG' | 'Global' | 'Local' | 'Worktree' | 'App' | 'Highest';
35
+ export interface ConfigEntry {
36
+ /** The name of this entry. */
37
+ name: string
38
+ /** The value of this entry. If no value is defined, the value will be `null`. */
39
+ value?: string
40
+ /** The configuration level of this entry. */
41
+ level: ConfigLevel
42
+ /** Depth of includes where this variable was found */
43
+ includeDepth: number
44
+ }
45
+ /**
46
+ * Create a new config instance containing a single on-disk file
47
+ *
48
+ * @category Config
49
+ * @signature
50
+ * ```ts
51
+ * function openConfig(path: string): Config;
52
+ * ```
53
+ *
54
+ * @param {string} path - Path to config file.
55
+ * @returns Config instance representing a git configuration key/value store.
56
+ */
57
+ export declare function openConfig(path: string): Config
58
+ /**
59
+ * Open the global, XDG and system configuration files
60
+ *
61
+ * Utility wrapper that finds the global, XDG and system configuration
62
+ * files and opens them into a single prioritized config object that can
63
+ * be used when accessing default config data outside a repository.
64
+ *
65
+ * @category Config
66
+ * @signature
67
+ * ```ts
68
+ * function openDefaultConfig(): Config;
69
+ * ```
70
+ *
71
+ * @returns Config instance representing a git configuration key/value store.
72
+ */
73
+ export declare function openDefaultConfig(): Config
74
+ /**
75
+ * Locate the path to the global configuration file.
76
+ *
77
+ * The user or global configuration file is usually located in
78
+ * `$HOME/.gitconfig`.
79
+ *
80
+ * This method will try to guess the full path to that file, if the file
81
+ * exists. The returned path may be used on any method call to load
82
+ * the global configuration file.
83
+ *
84
+ * This method will not guess the path to the XDG compatible config file
85
+ * (`.config/git/config`).
86
+ *
87
+ * @category Config
88
+ * @signature
89
+ * ```ts
90
+ * function findGlobalConfigPath(): string | null;
91
+ * ```
92
+ *
93
+ * @returns The path to the global configuration file.
94
+ */
95
+ export declare function findGlobalConfigPath(): string | null
96
+ /**
97
+ * Locate the path to the system configuration file.
98
+ *
99
+ * If `/etc/gitconfig` doesn't exist, it will look for `%PROGRAMFILES%`.
100
+ *
101
+ * @category Config
102
+ * @signature
103
+ * ```ts
104
+ * function findSystemConfigPath(): string | null;
105
+ * ```
106
+ *
107
+ * @returns The path to the system configuration file.
108
+ */
109
+ export declare function findSystemConfigPath(): string | null
110
+ /**
111
+ * Locate the path to the global XDG compatible configuration file.
112
+ *
113
+ * The XDG compatible configuration file is usually located in
114
+ * `$HOME/.config/git/config`.
115
+ *
116
+ * @category Config
117
+ * @signature
118
+ * ```ts
119
+ * function findXdgConfigPath(): string | null;
120
+ * ```
121
+ *
122
+ * @returns The path to the XDG compatible configuration file.
123
+ */
124
+ export declare function findXdgConfigPath(): string | null
125
+ /**
126
+ * Parse a string as a bool.
127
+ *
128
+ * @category Config
129
+ * @signature
130
+ * ```ts
131
+ * function parseConfigBool(value: string): boolean;
132
+ * ```
133
+ *
134
+ * @param {string} value - Input value.
135
+ * @returns Interprets "true", "yes", "on", 1, or any non-zero number as `true`.
136
+ * Interprets "false", "no", "off", 0, or an empty string as `false`.
137
+ */
138
+ export declare function parseConfigBool(value: string): boolean
139
+ /**
140
+ * Parse a string as an i32; handles suffixes like k, M, or G, and
141
+ * multiplies by the appropriate power of 1024.
142
+ *
143
+ * @category Config
144
+ * @signature
145
+ * ```ts
146
+ * function parseConfigI32(value: string): number;
147
+ * ```
148
+ *
149
+ * @param {string} value - Input value.
150
+ * @returns Parsed i32 value.
151
+ */
152
+ export declare function parseConfigI32(value: string): number
153
+ /**
154
+ * Parse a string as an i64; handles suffixes like k, M, or G, and
155
+ * multiplies by the appropriate power of 1024.
156
+ *
157
+ * @category Config
158
+ * @signature
159
+ * ```ts
160
+ * function parseConfigI64(value: string): number;
161
+ * ```
162
+ *
163
+ * @param {string} value - Input value.
164
+ * @returns Parsed i64 value.
165
+ */
166
+ export declare function parseConfigI64(value: string): number
167
+ /**
168
+ * - `DiffFlags.Binary` : File(s) treated as binary data.
169
+ * - `DiffFlags.NotBinary` : File(s) treated as text data.
170
+ * - `DiffFlags.ValidId` : `id` value is known correct.
171
+ * - `DiffFlags.Exists` : File exists at this side of the delta.
172
+ */
173
+ export enum DiffFlags {
26
174
  Binary = 1,
27
- /** File(s) treated as text data. (1 << 1) */
28
175
  NotBinary = 2,
29
- /** `id` value is known correct. (1 << 2) */
30
176
  ValidId = 4,
31
- /** File exists at this side of the delta. (1 << 3) */
32
177
  Exists = 8
33
178
  }
34
- /** Check diff flags contains given flags. */
179
+ /**
180
+ * Check diff flags contains given flags.
181
+ *
182
+ * @category Diff
183
+ * @signature
184
+ * ```ts
185
+ * function diffFlagsContains(source: number, target: number): boolean;
186
+ * ```
187
+ *
188
+ * @param {number} source - Source flags.
189
+ * @param {number} target - Target flags.
190
+ * @returns Returns `true` is source flags contains target flags.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { DiffDelta, DiffFlags, diffFlagsContains } from 'es-git';
195
+ *
196
+ * const delta: DiffDelta;
197
+ * console.assert(diffFlagsContains(delta.flags(), DiffFlags.Binary | DiffFlags.ValidId));
198
+ * ```
199
+ */
35
200
  export declare function diffFlagsContains(source: number, target: number): boolean
36
- /** What type of change is described by a `DiffDelta`? */
37
- export type DeltaType = /** No changes */
38
- 'Unmodified' | /** Entry does not exist in old version */
39
- 'Added' | /** Entry does not exist in new version */
40
- 'Deleted' | /** Entry content changed between old and new */
41
- 'Modified' | /** Entry was renamed between old and new */
42
- 'Renamed' | /** Entry was copied from another old entry */
43
- 'Copied' | /** Entry is ignored item in workdir */
44
- 'Ignored' | /** Entry is untracked item in workdir */
45
- 'Untracked' | /** Type of entry changed between old and new */
46
- 'Typechange' | /** Entry is unreadable */
47
- 'Unreadable' | /** Entry in the index is conflicted */
48
- 'Conflicted';
49
- /** Possible output formats for diff data */
50
- export type DiffFormat = /** full git diff (default) */
51
- 'Patch' | /** just the headers of the patch */
52
- 'PatchHeader' | /** like git diff --raw */
53
- 'Raw' | /** like git diff --name-only */
54
- 'NameOnly' | /** like git diff --name-status */
55
- 'NameStatus' | /** git diff as used by git patch-id */
56
- 'PatchId';
201
+ /**
202
+ * - `Unmodified` : No changes.
203
+ * - `Added` : Entry does not exist in an old version.
204
+ * - `Deleted` : Entry does not exist in a new version.
205
+ * - `Modified` : Entry content changed between old and new.
206
+ * - `Renamed` : Entry was renamed between old and new.
207
+ * - `Copied` : Entry was copied from another old entry.
208
+ * - `Ignored` : Entry is ignored item in workdir.
209
+ * - `Untracked` : Entry is untracked item in workdir.
210
+ * - `Typechange` : Type of entry changed between old and new.
211
+ * - `Unreadable` : Entry is unreadable.
212
+ * - `Conflicted` : Entry in the index is conflicted.
213
+ */
214
+ export type DeltaType = 'Unmodified' | 'Added' | 'Deleted' | 'Modified' | 'Renamed' | 'Copied' | 'Ignored' | 'Untracked' | 'Typechange' | 'Unreadable' | 'Conflicted';
215
+ /**
216
+ * Possible output formats for diff data.
217
+ *
218
+ * - `Patch`: Full `git diff` (default)
219
+ * - `PatchHeader` : Just the headers of the patch
220
+ * - `Raw` : Like `git diff --raw` the headers of the patch
221
+ * - `NameOnly` : Like `git diff --name-only`
222
+ * - `NameStatus` : Like `git diff --name-status`
223
+ * - `PatchId` : `git diff` as used by `git patch-id`
224
+ */
225
+ export type DiffFormat = 'Patch' | 'PatchHeader' | 'Raw' | 'NameOnly' | 'NameStatus' | 'PatchId';
57
226
  export interface DiffPrintOptions {
58
227
  format?: DiffFormat
59
228
  }
229
+ export interface DiffFindOptions {
230
+ /** Look for renames? */
231
+ renames?: boolean
232
+ /** Consider old side of modified for renames? */
233
+ renamesFromRewrites?: boolean
234
+ /** Look for copies? */
235
+ copies?: boolean
236
+ /**
237
+ * Consider unmodified as copy sources?
238
+ *
239
+ * For this to work correctly, use `includeUnmodified` when the initial
240
+ * diff is being generated.
241
+ */
242
+ copiesFromUnmodified?: boolean
243
+ /** Mark significant rewrites for split. */
244
+ rewrites?: boolean
245
+ /** Actually split large rewrites into delete/add pairs */
246
+ breakRewrites?: boolean
247
+ /**
248
+ * Find renames/copies for untracked items in working directory.
249
+ *
250
+ * For this to work correctly use the `includeUntracked` option when the
251
+ * initial diff is being generated.
252
+ */
253
+ forUntracked?: boolean
254
+ /** Turn on all finding features. */
255
+ all?: boolean
256
+ /** Measure similarity ignoring leading whitespace (default) */
257
+ ignoreLeadingWhitespace?: boolean
258
+ /** Measure similarity ignoring all whitespace */
259
+ ignoreWhitespace?: boolean
260
+ /** Measure similarity including all data */
261
+ dontIgnoreWhitespace?: boolean
262
+ /** Measure similarity only by comparing SHAs (fast and cheap) */
263
+ exactMatchOnly?: boolean
264
+ /**
265
+ * Do not break rewrites unless they contribute to a rename.
266
+ *
267
+ * Normally, `breakRewrites` and `rewrites` will measure the
268
+ * self-similarity of modified files and split the ones that have changed a
269
+ * lot into a delete/add pair. Then the sides of that pair will be
270
+ * considered candidates for rename and copy detection
271
+ *
272
+ * If you add this flag in and the split pair is not used for an actual
273
+ * rename or copy, then the modified record will be restored to a regular
274
+ * modified record instead of being split.
275
+ */
276
+ breakRewritesForRenamesOnly?: boolean
277
+ /**
278
+ * Remove any unmodified deltas after find_similar is done.
279
+ *
280
+ * Using `copiesFromUnmodified` to emulate the `--find-copies-harder`
281
+ * behavior requires building a diff with the `includeUnmodified` flag. If
282
+ * you do not want unmodified records in the final result, pas this flag to
283
+ * have them removed.
284
+ */
285
+ removeUnmodified?: boolean
286
+ /** Similarity to consider a file renamed (default 50) */
287
+ renameThreshold?: number
288
+ /** Similarity of modified to be eligible rename source (default 50) */
289
+ renameFromRewriteThreshold?: number
290
+ /** Similarity to consider a file copy (default 50) */
291
+ copyThreshold?: number
292
+ /** Similarity to split modify into delete/add pair (default 60) */
293
+ breakRewriteThreshold?: number
294
+ /**
295
+ * Maximum similarity sources to examine for a file (somewhat like
296
+ * git-diff's `-l` option or `diff.renameLimit` config)
297
+ *
298
+ * Defaults to 200
299
+ */
300
+ renameLimit?: number
301
+ }
60
302
  /** Valid modes for index and tree entries. */
61
- export type FileMode = 'Unreadable' | 'Tree' | 'Blob' | /** Group writable blob. Obsolete mode kept for compatibility reasons */
62
- 'BlobGroupWritable' | 'BlobExecutable' | 'Link' | 'Commit';
63
- /** Structure describing options about how the diff should be executed. */
303
+ export type FileMode = 'Unreadable' | 'Tree' | 'Blob' | 'BlobGroupWritable' | 'BlobExecutable' | 'Link' | 'Commit';
64
304
  export interface DiffOptions {
65
305
  /** Flag indicating whether the sides of the diff will be reversed. */
66
306
  reverse?: boolean
@@ -82,7 +322,7 @@ export interface DiffOptions {
82
322
  /**
83
323
  * Event with `includeTypechange`, the tree returned generally shows a
84
324
  * deleted blob. This flag correctly labels the tree transitions as a
85
- * typechange record with the `new_file`'s mode set to tree.
325
+ * typechange record with the `newFile`'s mode set to tree.
86
326
  *
87
327
  * Note that the tree SHA will not be available.
88
328
  */
@@ -226,10 +466,8 @@ export interface IndexEntry {
226
466
  * (`0x2F`). There are no terminating or internal NUL characters, and no
227
467
  * trailing slashes. Most of the time, paths will be valid utf-8 — but
228
468
  * not always. For more information on the path storage format, see
229
- * [these git docs][git-index-docs]. Note that libgit2 will take care of
230
- * handling the prefix compression mentioned there.
231
- *
232
- * [git-index-docs]: https://github.com/git/git/blob/a08a83db2bf27f015bec9a435f6d73e223c21c5e/Documentation/technical/index-format.txt#L107-L124
469
+ * [these git docs](https://github.com/git/git/blob/a08a83db2bf27f015bec9a435f6d73e223c21c5e/Documentation/technical/index-format.txt#L107-L124).
470
+ * Note that libgit2 will take care of handling the prefix compression mentioned there.
233
471
  */
234
472
  path: Buffer
235
473
  }
@@ -272,12 +510,14 @@ export interface IndexAddAllOptions {
272
510
  */
273
511
  onMatch?: (args: IndexOnMatchCallbackArgs) => number
274
512
  }
275
- export type IndexStage = /** Match any index stage. */
276
- 'Any' | /** A normal staged file in the index. */
277
- 'Normal' | /** The ancestor side of a conflict. */
278
- 'Ancestor' | /** The "ours" side of a conflict. */
279
- 'Ours' | /** The "theirs" side of a conflict. */
280
- 'Theirs';
513
+ /**
514
+ * - `Any` : Match any index stage.
515
+ * - `Normal` : A normal staged file in the index.
516
+ * - `Ancestor` : The ancestor side of a conflict.
517
+ * - `Ours` : The "ours" side of a conflict.
518
+ * - `Theirs` : The "theirs" side of a conflict.
519
+ */
520
+ export type IndexStage = 'Any' | 'Normal' | 'Ancestor' | 'Ours' | 'Theirs';
281
521
  export interface IndexRemoveOptions {
282
522
  stage?: IndexStage
283
523
  }
@@ -298,93 +538,142 @@ export interface IndexUpdateAllOptions {
298
538
  */
299
539
  onMatch?: (args: IndexOnMatchCallbackArgs) => number
300
540
  }
301
- /** An enumeration all possible kinds objects may have. */
302
- export const enum ObjectType {
303
- /** Any kind of git object */
304
- Any = 0,
305
- /** An object which corresponds to a git commit */
306
- Commit = 1,
307
- /** An object which corresponds to a git tree */
308
- Tree = 2,
309
- /** An object which corresponds to a git blob */
310
- Blob = 3,
311
- /** An object which corresponds to a git tag */
312
- Tag = 4
313
- }
541
+ /**
542
+ * - `Any` : Any kind of git object
543
+ * - `Commit` : An object which corresponds to a git commit
544
+ * - `Tree` : An object which corresponds to a git tree
545
+ * - `Blob` : An object which corresponds to a git blob
546
+ * - `Tag` : An object which corresponds to a git tag
547
+ */
548
+ export type ObjectType = 'Any' | 'Commit' | 'Tree' | 'Blob' | 'Tag';
314
549
  /**
315
550
  * Check if given string is valid Oid.
316
551
  *
317
- * Returns `false` if the string is empty, is longer than 40 hex
552
+ * @category Oid
553
+ * @signature
554
+ * ```ts
555
+ * function isValidOid(value: string): boolean;
556
+ * ```
557
+ *
558
+ * @param {string} value - String to check if is valid Oid.
559
+ * @returns Returns `false` if the string is empty, is longer than 40 hex
318
560
  * characters, or contains any non-hex characters.
319
561
  */
320
562
  export declare function isValidOid(value: string): boolean
321
- /** Test if this Oid is all zeros. */
563
+ /**
564
+ * Test if this Oid is all zeros.
565
+ *
566
+ * @category Oid
567
+ * @signature
568
+ * ```ts
569
+ * function isZeroOid(value: string): boolean;
570
+ * ```
571
+ *
572
+ * @param {string} value - String to check if is zero Oid.
573
+ * @returns Returns `true` if the string is zero Oid.
574
+ * @example
575
+ * ```ts
576
+ * import { zeroOid, isZeroOid } from 'es-git';
577
+ *
578
+ * console.assert(isZeroOid(zeroOid());
579
+ * ```
580
+ */
322
581
  export declare function isZeroOid(value: string): boolean
323
- /** Creates an all zero Oid structure. */
582
+ /**
583
+ * Creates an all zero Oid structure.
584
+ *
585
+ * @category Oid
586
+ * @signature
587
+ * ```ts
588
+ * function zeroOid(): string;
589
+ * ```
590
+ *
591
+ * @returns Zero Oid string.
592
+ */
324
593
  export declare function zeroOid(): string
325
594
  /**
326
595
  * Hashes the provided data as an object of the provided type, and returns
327
596
  * an Oid corresponding to the result. This does not store the object
328
597
  * inside any object database or repository.
598
+ *
599
+ * @category Oid
600
+ * @signature
601
+ * ```ts
602
+ * function hashObjectOid(objType: ObjectType, bytes: Buffer): string;
603
+ * ```
604
+ *
605
+ * @param {ObjectType} objType - Git object type.
606
+ * @param {Buffer} bytes - Data to hashed.
607
+ * @returns Hashed string.
329
608
  */
330
609
  export declare function hashObjectOid(objType: ObjectType, bytes: Buffer): string
331
610
  /**
332
611
  * Hashes the content of the provided file as an object of the provided type,
333
612
  * and returns an Oid corresponding to the result. This does not store the object
334
613
  * inside any object database or repository.
614
+ *
615
+ * @category Oid
616
+ * @signature
617
+ * ```ts
618
+ * function hashFileOid(objType: ObjectType, path: string): string;
619
+ * ```
620
+ *
621
+ * @param {ObjectType} objType - Git object type.
622
+ * @param {string} path - File path to make hash.
623
+ * @returns Hashed string.
335
624
  */
336
625
  export declare function hashFileOid(objType: ObjectType, path: string): string
337
- /** An enumeration of all possible kinds of references. */
338
- export type ReferenceType = /** A reference which points at an object id. */
339
- 'Direct' | /** A reference which points at another reference. */
340
- 'Symbolic';
626
+ /**
627
+ * - `Direct` : A reference which points at an object id.
628
+ * - `Symbolic` : A reference which points at another reference.
629
+ */
630
+ export type ReferenceType = 'Direct' | 'Symbolic';
341
631
  /**
342
632
  * Ensure the reference name is well-formed.
343
633
  *
344
- * Validation is performed as if [`ReferenceFormat::ALLOW_ONELEVEL`]
345
- * was given to [`Reference::normalize_name`]. No normalization is
346
- * performed, however.
634
+ * Validation is performed as if `ReferenceFormat.AllowOnelevel`
635
+ * was given to `normalizeReferenceName` No normalization is performed, however.
636
+ *
637
+ * @category Reference
638
+ * @signature
639
+ * ```ts
640
+ * function isValidReferenceName(refname: string): boolean;
641
+ * ```
642
+ *
643
+ * @param {string} refname - Reference name to check if it is valid.
644
+ * @returns Returns `true` if reference name is valid.
347
645
  *
348
646
  * @example
349
647
  * ```ts
350
- * import { isReferenceNameValid } from 'es-git';
648
+ * import { isValidReferenceName } from 'es-git';
351
649
  *
352
- * console.assert(isReferenceNameValid("HEAD"));
353
- * console.assert(isReferenceNameValid("refs/heads/main"));
650
+ * console.assert(isValidReferenceName("HEAD"));
651
+ * console.assert(isValidReferenceName("refs/heads/main"));
354
652
  *
355
653
  * // But:
356
- * console.assert(!isReferenceNameValid("main"));
357
- * console.assert(!isReferenceNameValid("refs/heads/*"));
358
- * console.assert(!isReferenceNameValid("foo//bar"));
654
+ * console.assert(!isValidReferenceName("main"));
655
+ * console.assert(!isValidReferenceName("refs/heads/*"));
656
+ * console.assert(!isValidReferenceName("foo//bar"));
359
657
  * ```
360
658
  */
361
- export declare function isReferenceNameValid(refname: string): boolean
362
- /** Options for normalize reference name. */
363
- export const enum ReferenceFormat {
364
- /** No particular normalization. */
659
+ export declare function isValidReferenceName(refname: string): boolean
660
+ /**
661
+ * - `ReferenceFormat.Normal` : No particular normalization.
662
+ * - `ReferenceFormat.AllowOnelevel` : Control whether one-level refname are accepted
663
+ * (i.e., refnames that do not contain multiple `/`-separated components). Those are
664
+ * expected to be written only using uppercase letters and underscore
665
+ * (e.g. `HEAD`, `FETCH_HEAD`).
666
+ * - `ReferenceFormat.RefspecPattern` : Interpret the provided name as a reference pattern
667
+ * for a refspec (as used with remote repositories). If this option is enabled, the name
668
+ * is allowed to contain a single `*` in place of a full pathname
669
+ * components (e.g., `foo/*\/bar` but not `foo/bar*`).
670
+ * - `ReferenceFormat.RefspecShorthand` : Interpret the name as part of a refspec in shorthand
671
+ * form so the `AllowOnelevel` naming rules aren't enforced and `main` becomes a valid name.
672
+ */
673
+ export enum ReferenceFormat {
365
674
  Normal = 0,
366
- /**
367
- * Control whether one-level refname are accepted (i.e., refnames that
368
- * do not contain multiple `/`-separated components). Those are
369
- * expected to be written only using uppercase letters and underscore
370
- * (e.g. `HEAD`, `FETCH_HEAD`).
371
- * (1 << 0)
372
- */
373
675
  AllowOnelevel = 1,
374
- /**
375
- * Interpret the provided name as a reference pattern for a refspec (as
376
- * used with remote repositories). If this option is enabled, the name
377
- * is allowed to contain a single `*` in place of a full pathname
378
- * components (e.g., `foo/*\/bar` but not `foo/bar*`).
379
- * (1 << 1)
380
- */
381
676
  RefspecPattern = 2,
382
- /**
383
- * Interpret the name as part of a refspec in shorthand form so the
384
- * `AllowOnelevel` naming rules aren't enforced and `main` becomes a
385
- * valid name.
386
- * (1 << 2)
387
- */
388
677
  RefspecShorthand = 4
389
678
  }
390
679
  /**
@@ -409,7 +698,16 @@ export const enum ReferenceFormat {
409
698
  * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
410
699
  * sequences ".." and "@{" which have special meaning to revparse.
411
700
  *
412
- * If the reference passes validation, it is returned in normalized form,
701
+ * @category Reference
702
+ * @signature
703
+ * ```ts
704
+ * function normalizeReferenceName(refname: string, format?: number): string | null;
705
+ * ```
706
+ *
707
+ * @param {string} refname - Reference name to normalize.
708
+ * @param {number} [format] - Reference format flags which used for normalize.
709
+ *
710
+ * @returns If the reference passes validation, it is returned in normalized form,
413
711
  * otherwise an `null` is returned.
414
712
  *
415
713
  * @example
@@ -417,7 +715,7 @@ export const enum ReferenceFormat {
417
715
  * import { normalizeReferenceName, ReferenceFormat } from 'es-git';
418
716
  *
419
717
  * console.assert(
420
- * normalizeReferenceName('foo//bar"),
718
+ * normalizeReferenceName('foo//bar'),
421
719
  * 'foo/bar'
422
720
  * );
423
721
  * console.assert(
@@ -452,81 +750,83 @@ export interface RenameReferenceOptions {
452
750
  force?: boolean
453
751
  logMessage?: string
454
752
  }
753
+ /**
754
+ * - `Fetch` : Fetch direction.
755
+ * - `Push` : Push direction.
756
+ */
455
757
  export type Direction = 'Fetch' | 'Push';
456
- export interface RefspecObject {
758
+ /**
759
+ * A data object to represent a git [refspec][1].
760
+ *
761
+ * Refspecs are currently mainly accessed/created through a `Remote`.
762
+ *
763
+ * [1]: https://git-scm.com/book/en/Git-Internals-The-Refspec
764
+ */
765
+ export interface Refspec {
457
766
  direction: Direction
767
+ /** The source specifier. */
458
768
  src: string
769
+ /** The destination specifier. */
459
770
  dst: string
771
+ /** Force update setting. */
460
772
  force: boolean
461
773
  }
462
- /** Options which can be specified to various fetch operations. */
463
- export interface ProxyOptions {
464
- /**
465
- * Try to auto-detect the proxy from the git configuration.
466
- *
467
- * Note that this will override `url` specified before.
468
- */
469
- auto?: boolean
470
- /**
471
- * Specify the exact URL of the proxy to use.
472
- *
473
- * Note that this will override `auto` specified before.
474
- */
475
- url?: string
476
- }
477
- export type FetchPrune = /** Use the setting from the configuration */
478
- 'Unspecified' | /** Force pruning on */
479
- 'On' | /** Force pruning off */
480
- 'Off';
481
- export type Credential = /** Create a "default" credential usable for Negotiate mechanisms like NTLM or Kerberos authentication.*/
482
- {
774
+ /** A interface to represent git credentials in libgit2. */
775
+ export type Credential = {
483
776
  type: 'Default';
484
- } | /** Create a new ssh key credential object used for querying an ssh-agent.
485
- The username specified is the username to authenticate.*/
486
- {
777
+ } | {
487
778
  type: 'SSHKeyFromAgent';
488
779
  username?: string;
489
- } | /** Create a new passphrase-protected ssh key credential object.*/
490
- {
780
+ } | {
491
781
  type: 'SSHKeyFromPath';
492
782
  username?: string;
493
783
  publicKeyPath?: string;
494
784
  privateKeyPath: string;
495
785
  passphrase?: string;
496
- } | /** Create a new ssh key credential object reading the keys from memory.*/
497
- {
786
+ } | {
498
787
  type: 'SSHKey';
499
788
  username?: string;
500
789
  publicKey?: string;
501
790
  privateKey: string;
502
791
  passphrase?: string;
503
- } | /** Create a new plain-text username and password credential object.*/
504
- {
792
+ } | {
505
793
  type: 'Plain';
506
794
  username?: string;
507
795
  password: string;
508
796
  };
509
- /** Automatic tag following options. */
510
- export type AutotagOption = /** Use the setting from the remote's configuration */
511
- 'Unspecified' | /** Ask the server for tags pointing to objects we're already downloading */
512
- 'Auto' | /** Don't ask for any tags beyond the refspecs */
513
- 'None' | /** Ask for all the tags */
514
- 'All';
797
+ export interface ProxyOptions {
798
+ /**
799
+ * Try to auto-detect the proxy from the git configuration.
800
+ *
801
+ * Note that this will override `url` specified before.
802
+ */
803
+ auto?: boolean
804
+ /**
805
+ * Specify the exact URL of the proxy to use.
806
+ *
807
+ * Note that this will override `auto` specified before.
808
+ */
809
+ url?: string
810
+ }
515
811
  /**
516
- * Remote redirection settings; whether redirects to another host are
517
- * permitted.
518
- *
519
- * By default, git will follow a redirect on the initial request
520
- * (`/info/refs`), but not subsequent requests.
812
+ * - `Unspecified` : Use the setting from the configuration.
813
+ * - `On` : Force pruning on.
814
+ * - `Off` : Force pruning off
815
+ */
816
+ export type FetchPrune = 'Unspecified' | 'On' | 'Off';
817
+ /**
818
+ * - `Unspecified` : Use the setting from the remote's configuration
819
+ * - `Auto` : Ask the server for tags pointing to objects we're already downloading
820
+ * - `None` : Don't ask for any tags beyond the refspecs
821
+ * - `All` : Ask for all the tags
521
822
  */
522
- export type RemoteRedirect = /** Do not follow any off-site redirects at any stage of the fetch or push. */
523
- 'None' | /**
524
- * Allow off-site redirects only upon the initial request. This is the
525
- * default.
823
+ export type AutotagOption = 'Unspecified' | 'Auto' | 'None' | 'All';
824
+ /**
825
+ * - `None` : Do not follow any off-site redirects at any stage of the fetch or push.
826
+ * - `Initial` : Allow off-site redirects only upon the initial request. This is the default.
827
+ * - `All` : Allow redirects at any stage in the fetch or push.
526
828
  */
527
- 'Initial' | /** Allow redirects at any stage in the fetch or push. */
528
- 'All';
529
- /** Options which can be specified to various fetch operations. */
829
+ export type RemoteRedirect = 'None' | 'Initial' | 'All';
530
830
  export interface FetchOptions {
531
831
  credential?: Credential
532
832
  /** Set the proxy options to use for the fetch operation. */
@@ -587,67 +887,365 @@ export interface CreateRemoteOptions {
587
887
  fetchRefspec?: string
588
888
  }
589
889
  export interface FetchRemoteOptions {
890
+ /** Options which can be specified to various fetch operations. */
590
891
  fetch?: FetchOptions
591
892
  reflogMsg?: string
592
893
  }
593
894
  export interface PruneOptions {
594
895
  credential?: Credential
595
896
  }
596
- /** A listing of the possible states that a repository can be in. */
897
+ /**
898
+ * Available states are `Clean`, `Merge`, `Revert`, `RevertSequence`, `CherryPick`,
899
+ * `CherryPickSequence`, `Bisect`, `Rebase`, `RebaseInteractive`, `RebaseMerge`,
900
+ * `ApplyMailbox`, `ApplyMailboxOrRebase`.
901
+ */
597
902
  export type RepositoryState = 'Clean' | 'Merge' | 'Revert' | 'RevertSequence' | 'CherryPick' | 'CherryPickSequence' | 'Bisect' | 'Rebase' | 'RebaseInteractive' | 'RebaseMerge' | 'ApplyMailbox' | 'ApplyMailboxOrRebase';
903
+ /** Mode options for `RepositoryInitOptions`. */
904
+ export enum RepositoryInitMode {
905
+ /** Use permissions configured by umask (default) */
906
+ SharedUnmask = 0,
907
+ /**
908
+ * Use `--shared=group` behavior, chmod'ing the new repo to be
909
+ * group writable and "g+sx" for sticky group assignment.
910
+ */
911
+ SharedGroup = 1533,
912
+ /** Use `--shared=all` behavior, adding world readability. */
913
+ SharedAll = 1535
914
+ }
598
915
  export interface RepositoryInitOptions {
916
+ /**
917
+ * Create a bare repository with no working directory.
918
+ *
919
+ * Defaults to `false`.
920
+ */
599
921
  bare?: boolean
922
+ /**
923
+ * Return an error if the repository path appears to already be a git
924
+ * repository.
925
+ *
926
+ * Defaults to `false`.
927
+ */
928
+ noReinit?: boolean
929
+ /**
930
+ * Normally a '/.git/' will be appended to the repo path for non-bare repos
931
+ * (if it is not already there), but passing this flag prevents that
932
+ * behavior.
933
+ *
934
+ * Defaults to `false`.
935
+ */
936
+ noDotgitDir?: boolean
937
+ /**
938
+ * Make the repo path (and workdir path) as needed. The ".git" directory
939
+ * will always be created regardless of this flag.
940
+ *
941
+ * Defaults to `true`.
942
+ */
943
+ mkdir?: boolean
944
+ /**
945
+ * Make the repo path (and workdir path) as needed. The ".git" directory
946
+ * will always be created regardless of this flag.
947
+ *
948
+ * Defaults to `true`.
949
+ */
950
+ mkpath?: boolean
951
+ /** Set to one of the `RepositoryInit` constants, or a custom value. */
952
+ mode?: number
953
+ /**
954
+ * Enable or disable using external templates.
955
+ *
956
+ * If enabled, then the `template_path` option will be queried first, then
957
+ * `init.templatedir` from the global config, and finally
958
+ * `/usr/share/git-core-templates` will be used (if it exists).
959
+ *
960
+ * Defaults to `true`.
961
+ */
962
+ externalTemplate?: boolean
963
+ /**
964
+ * When the `externalTemplate` option is set, this is the first location
965
+ * to check for the template directory.
966
+ *
967
+ * If this is not configured, then the default locations will be searched
968
+ * instead.
969
+ */
970
+ templatePath?: string
971
+ /**
972
+ * The path to the working directory.
973
+ *
974
+ * If this is a relative path it will be evaluated relative to the repo
975
+ * path. If this is not the "natural" working directory, a .git gitlink
976
+ * file will be created here linking to the repo path.
977
+ */
978
+ workdirPath?: string
979
+ /**
980
+ * If set, this will be used to initialize the "description" file in the
981
+ * repository instead of using the template content.
982
+ */
983
+ description?: string
984
+ /**
985
+ * The name of the head to point HEAD at.
986
+ *
987
+ * If not configured, this will be taken from your git configuration.
988
+ * If this begins with `refs/` it will be used verbatim;
989
+ * otherwise `refs/heads/` will be prefixed.
990
+ */
600
991
  initialHead?: string
992
+ /**
993
+ * If set, then after the rest of the repository initialization is
994
+ * completed an `origin` remote will be added pointing to this URL.
995
+ */
601
996
  originUrl?: string
602
997
  }
603
998
  export interface RepositoryOpenOptions {
604
- flags: number
999
+ /**
1000
+ * If this option is `true`, the path must point directly to a repository; otherwise,
1001
+ * this may point to a subdirectory of a repository, and `open` will search up through parent
1002
+ * directories.
1003
+ */
1004
+ noSearch?: boolean
1005
+ /**
1006
+ * If this option is `true`, the search through parent directories will not cross
1007
+ * a filesystem boundary (detected when the stat st_dev field changes).
1008
+ */
1009
+ crossFs?: boolean
1010
+ /**
1011
+ * If this option is `true`, force opening the repository as bare event if it isn't, ignoring
1012
+ * any working directory, and defer loading the repository configuration for performance.
1013
+ */
1014
+ bare?: boolean
1015
+ /** If this options is `true`, don't try appending `/.git` to `path`. */
1016
+ noDotgit?: boolean
1017
+ /**
1018
+ * If this option is `true`, `open` will ignore other options and `ceilingDirs`, and respect
1019
+ * the same environment variables git does.
1020
+ * Note, however, that `path` overrides `$GIT_DIR`.
1021
+ */
1022
+ fromEnv?: boolean
1023
+ /**
1024
+ * ceiling_dirs specifies a list of paths that the search through parent
1025
+ * directories will stop before entering.
1026
+ */
605
1027
  ceilingDirs?: Array<string>
606
1028
  }
607
- export const enum RepositoryOpenFlags {
608
- /** Only open the specified path; don't walk upward searching. (1 << 0) */
609
- NoSearch = 1,
610
- /** Search across filesystem boundaries. (1 << 1) */
611
- CrossFS = 2,
612
- /** Force opening as a bare repository, and defer loading its config. (1 << 2) */
613
- Bare = 4,
614
- /** Don't try appending `/.git` to the specified repository path. (1 << 3) */
615
- NoDotGit = 8,
616
- /** Respect environment variables like `$GIT_DIR`. (1 << 4) */
617
- FromEnv = 16
618
- }
619
1029
  export interface RepositoryCloneOptions {
1030
+ /**
1031
+ * Indicate whether the repository will be cloned as a bare repository or
1032
+ * not.
1033
+ */
1034
+ bare?: boolean
1035
+ /**
1036
+ * Specify the name of the branch to check out after the clone.
1037
+ *
1038
+ * If not specified, the remote's default branch will be used.
1039
+ */
1040
+ branch?: string
1041
+ /**
1042
+ * Clone a remote repository, initialize and update its submodules
1043
+ * recursively.
1044
+ *
1045
+ * This is similar to `git clone --recursive`.
1046
+ */
620
1047
  recursive?: boolean
1048
+ /** Options which can be specified to various fetch operations. */
621
1049
  fetch?: FetchOptions
622
1050
  }
623
- /** Creates a new repository in the specified folder. */
624
- export declare function initRepository(path: string, options?: RepositoryInitOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
625
- /** Attempt to open an already-existing repository at `path`. */
626
- export declare function openRepository(path: string, options?: RepositoryOpenOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
627
1051
  /**
628
- * Attempt to open an already-existing repository at or above `path`
1052
+ * Creates a new repository in the specified folder.
629
1053
  *
630
- * This starts at `path` and looks up the filesystem hierarchy
631
- * until it finds a repository.
632
- */
633
- export declare function discoverRepository(path: string, signal?: AbortSignal | undefined | null): Promise<Repository>
634
- /**
635
- * Clone a remote repository.
1054
+ * @category Repository
1055
+ * @signature
1056
+ * ```ts
1057
+ * function initRepository(
1058
+ * path: string,
1059
+ * options?: RepositoryInitOptions,
1060
+ * signal?: AbortSignal,
1061
+ * ): Promise<Repository>;
1062
+ * ```
1063
+ *
1064
+ * @param {string} path - Directory path to create new repository.
1065
+ * @param {RepositoryInitOptions} [options] - Options which can be used to configure
1066
+ * how a repository is initialized.
1067
+ * @param {AbortSignal} [signal] - Abort signal.
1068
+ *
1069
+ * @returns A new repository.
1070
+ *
1071
+ * @example
1072
+ *
1073
+ * Basic example.
1074
+ *
1075
+ * ```ts
1076
+ * import { initRepository } from 'es-git';
1077
+ *
1078
+ * const repo = await iniRepository('/path/to/repo');
1079
+ * ```
1080
+ *
1081
+ * Create bare repository.
1082
+ *
1083
+ * ```ts
1084
+ * import { initRepository } from 'es-git';
1085
+ *
1086
+ * const repo = await iniRepository('/path/to/repo.git', {
1087
+ * bare: true,
1088
+ * });
1089
+ * ```
1090
+ */
1091
+ export declare function initRepository(path: string, options?: RepositoryInitOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
1092
+ /**
1093
+ * Attempt to open an already-existing repository at `path`.
1094
+ *
1095
+ * @category Repository
1096
+ * @signature
1097
+ * ```ts
1098
+ * function openRepository(
1099
+ * path: string,
1100
+ * options?: RepositoryOpenOptions,
1101
+ * signal?: AbortSignal,
1102
+ * ): Promise<Repository>;
1103
+ * ```
1104
+ *
1105
+ * @param {string} path - Directory path to repository already-existing.
1106
+ * @param {RepositoryOpenOptions} [options] - Options which can be used to configure
1107
+ * how a repository is initialized.
1108
+ * @param {AbortSignal} [signal] - Abort signal.
1109
+ *
1110
+ * @returns Opened repository.
1111
+ *
1112
+ * @example
1113
+ *
1114
+ * Basic example.
1115
+ *
1116
+ * ```ts
1117
+ * import { openRepository } from 'es-git';
1118
+ *
1119
+ * const repo = await openRepository('/path/to/repo');
1120
+ * ```
1121
+ *
1122
+ * Open bare repository.
1123
+ *
1124
+ * ```ts
1125
+ * import { openRepository } from 'es-git';
1126
+ *
1127
+ * const repo = await openRepository('/path/to/repo.git', {
1128
+ * bare: true,
1129
+ * });
1130
+ * ```
1131
+ */
1132
+ export declare function openRepository(path: string, options?: RepositoryOpenOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
1133
+ /**
1134
+ * Attempt to open an already-existing repository at or above `path`.
1135
+ *
1136
+ * This starts at `path` and looks up the filesystem hierarchy
1137
+ * until it finds a repository.
1138
+ *
1139
+ * @category Repository
1140
+ * @signature
1141
+ * ```ts
1142
+ * function discoverRepository(path: string, signal?: AbortSignal): Promise<Repository>;
1143
+ * ```
1144
+ *
1145
+ * @param {string} path - Directory path to discover repository.
1146
+ * @param {AbortSignal} [signal] - Abort signal.
1147
+ *
1148
+ * @returns Git repository.
1149
+ */
1150
+ export declare function discoverRepository(path: string, signal?: AbortSignal | undefined | null): Promise<Repository>
1151
+ /**
1152
+ * Clone a remote repository.
636
1153
  *
637
1154
  * This will use the options configured so far to clone the specified URL
638
1155
  * into the specified local path.
1156
+ *
1157
+ * @category Repository
1158
+ *
1159
+ * @signature
1160
+ * ```ts
1161
+ * function cloneRepository(
1162
+ * url: string,
1163
+ * path: string,
1164
+ * options?: RepositoryCloneOptions | null,
1165
+ * signal?: AbortSignal | null
1166
+ * ): Promise<Repository>;
1167
+ * ```
1168
+ *
1169
+ * @param {string} url - Remote URL for repository.
1170
+ * @param {string} path - Local path to clone repository.
1171
+ * @param {RepositoryCloneOptions|undefined|null} [options] - Clone options for repository.
1172
+ * @param {AbortSignal|undefined|null} [signal] - Abort signal.
1173
+ * @returns Repository instance
1174
+ *
1175
+ * @example
1176
+ *
1177
+ * Clone repository using `https://` protocol.
1178
+ *
1179
+ * ```ts
1180
+ * import { cloneRepository } from 'es-git';
1181
+ *
1182
+ * const repo = await cloneRepository(
1183
+ * 'https://github.com/toss/es-git',
1184
+ * '/path/to/clone',
1185
+ * );
1186
+ * ```
1187
+ *
1188
+ * Clone repository using `git://` protocol.
1189
+ *
1190
+ * ```ts
1191
+ * import { cloneRepository } from 'es-git';
1192
+ *
1193
+ * const repo = await cloneRepository(
1194
+ * 'git@github.com:toss/es-git',
1195
+ * '/path/to/clone',
1196
+ * );
1197
+ * ```
1198
+ *
1199
+ * Clone repository with authentication.
1200
+ *
1201
+ * ```ts
1202
+ * import { cloneRepository } from 'es-git';
1203
+ *
1204
+ * // Authenticate using ssh-agent
1205
+ * const repo = await cloneRepository('git@github.com:toss/es-git', '.', {
1206
+ * fetch: {
1207
+ * credential: {
1208
+ * type: 'SSHKeyFromAgent',
1209
+ * },
1210
+ * },
1211
+ * });
1212
+ * ```
639
1213
  */
640
1214
  export declare function cloneRepository(url: string, path: string, options?: RepositoryCloneOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
641
- /** Flags for the Revspec. */
642
- export const enum RevparseMode {
643
- /** The spec targeted a single object (1 << 0) */
1215
+ /**
1216
+ * Flags for the revparse.
1217
+ * - `Single` : The spec targeted a single object.
1218
+ * - `Range` : The spec targeted a range of commits.
1219
+ * - `MergeBase` : The spec used the `...` operator, which invokes special semantics.
1220
+ */
1221
+ export enum RevparseMode {
644
1222
  Single = 1,
645
- /** The spec targeted a range of commits (1 << 1) */
646
1223
  Range = 2,
647
- /** The spec used the `...` operator, which invokes special semantics. (1 << 2) */
648
1224
  MergeBase = 4
649
1225
  }
650
- /** Check revparse mode contains specific flags. */
1226
+ /**
1227
+ * Check revparse mode contains specific flags.
1228
+ *
1229
+ * @category Revparse
1230
+ * @signature
1231
+ * ```ts
1232
+ * function revparseModeContains(source: number, target: number): boolean;
1233
+ * ```
1234
+ *
1235
+ * @param {number} source - Source flags.
1236
+ * @param {number} target - Target flags.
1237
+ * @returns Returns `true` is source flags contains target flags.
1238
+ *
1239
+ * @example
1240
+ * ```ts
1241
+ * import { openRepository, revparseModeContains, RevparseMode } from 'es-git';
1242
+ *
1243
+ * const repo = await openRepository('.');
1244
+ * const spec = repo.revparse('main..other');
1245
+ *
1246
+ * console.assert(revparseModeContains(spec.mode, RevparseMode.Range));
1247
+ * ```
1248
+ */
651
1249
  export declare function revparseModeContains(source: number, target: number): boolean
652
1250
  /** A revspec represents a range of revisions within a repository. */
653
1251
  export interface Revspec {
@@ -658,42 +1256,15 @@ export interface Revspec {
658
1256
  /** Returns the intent of the revspec. */
659
1257
  mode: number
660
1258
  }
661
- /** Orderings that may be specified for Revwalk iteration. */
662
- export const enum RevwalkSort {
663
- /**
664
- * Sort the repository contents in no particular ordering.
665
- *
666
- * This sorting is arbitrary, implementation-specific, and subject to
667
- * change at any time. This is the default sorting for new walkers.
668
- */
1259
+ export enum RevwalkSort {
669
1260
  None = 0,
670
- /**
671
- * Sort the repository contents in topological order (children before
672
- * parents).
673
- *
674
- * This sorting mode can be combined with time sorting.
675
- * (1 << 0)
676
- */
677
1261
  Topological = 1,
678
- /**
679
- * Sort the repository contents by commit time.
680
- *
681
- * This sorting mode can be combined with topological sorting.
682
- * (1 << 1)
683
- */
684
1262
  Time = 2,
685
- /**
686
- * Iterate through the repository contents in reverse order.
687
- *
688
- * This sorting mode can be combined with any others.
689
- * (1 << 2)
690
- */
691
1263
  Reverse = 4
692
1264
  }
693
1265
  /**
694
1266
  * A Signature is used to indicate authorship of various actions throughout the
695
1267
  * library.
696
- *
697
1268
  * Signatures contain a name, email, and timestamp.
698
1269
  */
699
1270
  export interface Signature {
@@ -710,7 +1281,35 @@ export interface SignatureTimeOptions {
710
1281
  /** Timezone offset, in minutes */
711
1282
  offset?: number
712
1283
  }
713
- /** Create a new action signature. */
1284
+ /**
1285
+ * Create a new action signature.
1286
+ *
1287
+ * @category Signature
1288
+ * @signature
1289
+ * ```ts
1290
+ * function createSignature(
1291
+ * name: string,
1292
+ * email: string,
1293
+ * timeOptions?: SignatureTimeOptions,
1294
+ * ): Signature;
1295
+ * ```
1296
+ *
1297
+ * @param {string} name - Name on the signature.
1298
+ * @param {string} email - Email on the signature.
1299
+ * @param {SignatureTimeOptions} [timeOptions] - Time options for signature.
1300
+ *
1301
+ * @returns
1302
+ *
1303
+ * @example
1304
+ * ```ts
1305
+ * import { createSignature } from 'es-git';
1306
+ *
1307
+ * const author = createSignature(
1308
+ * 'Seokju Na',
1309
+ * 'seokju.me@toss.im',
1310
+ * );
1311
+ * ```
1312
+ */
714
1313
  export declare function createSignature(name: string, email: string, timeOptions?: SignatureTimeOptions | undefined | null): Signature
715
1314
  export interface SignaturePayload {
716
1315
  /** Name on the signature. */
@@ -723,6 +1322,15 @@ export interface SignaturePayload {
723
1322
  * Determine whether a tag name is valid, meaning that (when prefixed with refs/tags/) that
724
1323
  * it is a valid reference name, and that any additional tag name restrictions are imposed
725
1324
  * (eg, it cannot start with a -).
1325
+ *
1326
+ * @category Tag
1327
+ * @signature
1328
+ * ```ts
1329
+ * function isValidTagName(tagName: string): boolean;
1330
+ * ```
1331
+ *
1332
+ * @param {string} tagName - Tag name to check if it is valid.
1333
+ * @returns Returns `true` if tag name is valid.
726
1334
  */
727
1335
  export declare function isValidTagName(tagName: string): boolean
728
1336
  export interface CreateTagOptions {
@@ -733,6 +1341,7 @@ export interface CreateTagOptions {
733
1341
  * If there is no default signature set for the repository, an error will occur.
734
1342
  */
735
1343
  tagger?: SignaturePayload
1344
+ /** If `force` is true and a reference already exists with the given name, it'll be replaced. */
736
1345
  force?: boolean
737
1346
  }
738
1347
  export interface CreateAnnotationTagOptions {
@@ -745,19 +1354,126 @@ export interface CreateAnnotationTagOptions {
745
1354
  tagger?: SignaturePayload
746
1355
  }
747
1356
  export interface CreateLightweightTagOptions {
1357
+ /** If `force` is true and a reference already exists with the given name, it'll be replaced. */
748
1358
  force?: boolean
749
1359
  }
1360
+ /**
1361
+ * - `PreOrder` : Runs the traversal in pre-order.
1362
+ * - `PostOrder` : Runs the traversal in post-order.
1363
+ */
750
1364
  export type TreeWalkMode = 'PreOrder' | 'PostOrder';
751
1365
  /**
752
- * A structure to represent a git commit
753
- * @hideconstructor
1366
+ * A class to represent a git [blob][1].
1367
+ * [1]: https://git-scm.com/book/en/Git-Internals-Git-Objects
754
1368
  */
1369
+ export declare class Blob {
1370
+ /**
1371
+ * Get the id (SHA1) of a repository blob.
1372
+ *
1373
+ * @category Blob/Methods
1374
+ *
1375
+ * @signature
1376
+ * ```ts
1377
+ * class Blob {
1378
+ * id(): string;
1379
+ * }
1380
+ * ```
1381
+ *
1382
+ * @returns ID(SHA1) of a repository blob.
1383
+ */
1384
+ id(): string
1385
+ /**
1386
+ * Determine if the blob content is most certainly binary or not.
1387
+ *
1388
+ * @category Blob/Methods
1389
+ *
1390
+ * @signature
1391
+ * ```ts
1392
+ * class Blob {
1393
+ * isBinary(): boolean;
1394
+ * }
1395
+ * ```
1396
+ *
1397
+ * @returns `true` if blob content is binary.
1398
+ */
1399
+ isBinary(): boolean
1400
+ /**
1401
+ * Get the content of this blob.
1402
+ *
1403
+ * @category Blob/Methods
1404
+ *
1405
+ * @signature
1406
+ * ```ts
1407
+ * class Blob {
1408
+ * content(): Uint8Array;
1409
+ * }
1410
+ * ```
1411
+ *
1412
+ * @returns Content of this blob.
1413
+ */
1414
+ content(): Uint8Array
1415
+ /**
1416
+ * Get the size in bytes of the contents of this blob.
1417
+ *
1418
+ * @category Blob/Methods
1419
+ *
1420
+ * @signature
1421
+ * ```ts
1422
+ * class Blob {
1423
+ * size(): bigint;
1424
+ * }
1425
+ * ```
1426
+ *
1427
+ * @returns Size in bytes of the contents of this blob.
1428
+ */
1429
+ size(): bigint
1430
+ }
1431
+ /** A class to represent a git commit. */
755
1432
  export declare class Commit {
756
- /** Get the id (SHA1) of a repository commit */
1433
+ /**
1434
+ * Get the id (SHA1) of a repository commit
1435
+ *
1436
+ * @category Commit/Methods
1437
+ *
1438
+ * @signature
1439
+ * ```ts
1440
+ * class Commit {
1441
+ * id(): string;
1442
+ * }
1443
+ * ```
1444
+ *
1445
+ * @returns ID(SHA1) of a repository commit.
1446
+ */
757
1447
  id(): string
758
- /** Get the author of this commit. */
1448
+ /**
1449
+ * Get the author of this commit.
1450
+ *
1451
+ * @category Commit/Methods
1452
+ *
1453
+ * @signature
1454
+ * ```ts
1455
+ * class Commit {
1456
+ * author(): Signature;
1457
+ * }
1458
+ * ```
1459
+ *
1460
+ * @returns Author signature of this commit.
1461
+ */
759
1462
  author(): Signature
760
- /** Get the committer of this commit. */
1463
+ /**
1464
+ * Get the committer of this commit.
1465
+ *
1466
+ * @category Commit/Methods
1467
+ *
1468
+ * @signature
1469
+ * ```ts
1470
+ * class Commit {
1471
+ * committer(): Signature;
1472
+ * }
1473
+ * ```
1474
+ *
1475
+ * @returns Committer signature of this commit.
1476
+ */
761
1477
  committer(): Signature
762
1478
  /**
763
1479
  * Get the full message of a commit.
@@ -765,7 +1481,19 @@ export declare class Commit {
765
1481
  * The returned message will be slightly prettified by removing any
766
1482
  * potential leading newlines.
767
1483
  *
768
- * Throws error if the message is not valid utf-8
1484
+ * Throws error if the message is not valid utf-8.
1485
+ *
1486
+ * @category Commit/Methods
1487
+ *
1488
+ * @signature
1489
+ * ```ts
1490
+ * class Commit {
1491
+ * message(): string;
1492
+ * }
1493
+ * ```
1494
+ *
1495
+ * @returns Full message of this commit.
1496
+ * @throws If the message is not valid utf-8.
769
1497
  */
770
1498
  message(): string
771
1499
  /**
@@ -775,6 +1503,18 @@ export declare class Commit {
775
1503
  * paragraph of the message with whitespace trimmed and squashed.
776
1504
  *
777
1505
  * Throws error if the summary is not valid utf-8.
1506
+ *
1507
+ * @category Commit/Methods
1508
+ *
1509
+ * @signature
1510
+ * ```ts
1511
+ * class Commit {
1512
+ * summary(): string;
1513
+ * }
1514
+ * ```
1515
+ *
1516
+ * @returns Short summary of this commit message.
1517
+ * @throws If the summary is not valid utf-8.
778
1518
  */
779
1519
  summary(): string | null
780
1520
  /**
@@ -785,29 +1525,504 @@ export declare class Commit {
785
1525
  * are trimmed.
786
1526
  *
787
1527
  * Throws error if the summary is not valid utf-8.
1528
+ *
1529
+ * @category Commit/Methods
1530
+ *
1531
+ * @signature
1532
+ * ```ts
1533
+ * class Commit {
1534
+ * body(): string;
1535
+ * }
1536
+ * ```
1537
+ *
1538
+ * @returns Long body of this commit message.
1539
+ * @throws If the body is not valid utf-8.
788
1540
  */
789
1541
  body(): string | null
790
1542
  /**
791
1543
  * Get the commit time (i.e. committer time) of a commit.
792
1544
  *
793
- * The first element of the tuple is the time, in seconds, since the epoch.
794
- * The second element is the offset, in minutes, of the time zone of the
795
- * committer's preferred time zone.
1545
+ * @category Commit/Methods
1546
+ *
1547
+ * @signature
1548
+ * ```ts
1549
+ * class Commit {
1550
+ * time(): Date;
1551
+ * }
1552
+ * ```
1553
+ *
1554
+ * @returns Commit time of a commit.
796
1555
  */
797
1556
  time(): Date
798
- /** Get the tree pointed to by a commit. */
1557
+ /**
1558
+ * Get the tree pointed to by a commit.
1559
+ *
1560
+ * @category Commit/Methods
1561
+ *
1562
+ * @signature
1563
+ * ```ts
1564
+ * class Commit {
1565
+ * tree(): Tree;
1566
+ * }
1567
+ * ```
1568
+ *
1569
+ * @returns Tree pointed to by a commit.
1570
+ */
799
1571
  tree(): Tree
800
- /** Casts this Commit to be usable as an `GitObject` */
1572
+ /**
1573
+ * Casts this Commit to be usable as an `GitObject`.
1574
+ *
1575
+ * @category Commit/Methods
1576
+ *
1577
+ * @signature
1578
+ * ```ts
1579
+ * class Commit {
1580
+ * asObject(): GitObject;
1581
+ * }
1582
+ * ```
1583
+ *
1584
+ * @returns `GitObject` that casted from this commit.
1585
+ */
801
1586
  asObject(): GitObject
802
1587
  }
1588
+ /** An iterator over the `ConfigEntry` values of a config. */
1589
+ export declare class ConfigEntries {
1590
+ [Symbol.iterator](): Iterator<ConfigEntry, void, void>
1591
+ }
1592
+ export declare class Config {
1593
+ /**
1594
+ * Delete a config variable from the config file with the highest level
1595
+ * (usually the local one).
1596
+ *
1597
+ * @category Config/Methods
1598
+ * @signature
1599
+ * ```ts
1600
+ * class Config {
1601
+ * remove(name: string): void;
1602
+ * }
1603
+ * ```
1604
+ *
1605
+ * @param {string} name - The name of config entry.
1606
+ */
1607
+ remove(name: string): void
1608
+ /**
1609
+ * Remove multivar config variables in the config file with the highest level (usually the
1610
+ * local one).
1611
+ *
1612
+ * @category Config/Methods
1613
+ * @signature
1614
+ * ```ts
1615
+ * class Config {
1616
+ * removeMultivar(name: string, regexp: string): void;
1617
+ * }
1618
+ * ```
1619
+ *
1620
+ * @param {string} name - The name of config entry.
1621
+ * @param {string} regexp - The regular expression is applied case-sensitively on the value.
1622
+ */
1623
+ removeMultivar(name: string, regexp: string): void
1624
+ /**
1625
+ * Get the value of a boolean config variable.
1626
+ *
1627
+ * All config files will be looked into, in the order of their defined
1628
+ * level. A higher level means a higher priority. The first occurrence of
1629
+ * the variable will be returned here.
1630
+ *
1631
+ * @category Config/Methods
1632
+ * @signature
1633
+ * ```ts
1634
+ * class Config {
1635
+ * getBool(name: string): boolean;
1636
+ * }
1637
+ * ```
1638
+ *
1639
+ * @param {string} name - The name of config entry.
1640
+ * @returns The value of a boolean config variable.
1641
+ */
1642
+ getBool(name: string): boolean
1643
+ /**
1644
+ * Find the value of a boolean config variable.
1645
+ *
1646
+ * All config files will be looked into, in the order of their defined
1647
+ * level. A higher level means a higher priority. The first occurrence of
1648
+ * the variable will be returned here.
1649
+ *
1650
+ * @category Config/Methods
1651
+ * @signature
1652
+ * ```ts
1653
+ * class Config {
1654
+ * findBool(name: string): boolean | null;
1655
+ * }
1656
+ * ```
1657
+ *
1658
+ * @param {string} name - The name of config entry.
1659
+ * @returns The value of a boolean config variable.
1660
+ */
1661
+ findBool(name: string): boolean | null
1662
+ /**
1663
+ * Get the value of an integer config variable.
1664
+ *
1665
+ * All config files will be looked into, in the order of their defined
1666
+ * level. A higher level means a higher priority. The first occurrence of
1667
+ * the variable will be returned here.
1668
+ *
1669
+ * @category Config/Methods
1670
+ * @signature
1671
+ * ```ts
1672
+ * class Config {
1673
+ * getI32(name: string): number;
1674
+ * }
1675
+ * ```
1676
+ *
1677
+ * @param {string} name - The name of config entry.
1678
+ * @returns The value of an integer config variable.
1679
+ */
1680
+ getI32(name: string): number
1681
+ /**
1682
+ * Find the value of an integer config variable.
1683
+ *
1684
+ * All config files will be looked into, in the order of their defined
1685
+ * level. A higher level means a higher priority. The first occurrence of
1686
+ * the variable will be returned here.
1687
+ *
1688
+ * @category Config/Methods
1689
+ * @signature
1690
+ * ```ts
1691
+ * class Config {
1692
+ * findI32(name: string): number | null;
1693
+ * }
1694
+ * ```
1695
+ *
1696
+ * @param {string} name - The name of config entry.
1697
+ * @returns The value of an integer config variable.
1698
+ */
1699
+ findI32(name: string): number | null
1700
+ /**
1701
+ * Get the value of an integer config variable.
1702
+ *
1703
+ * All config files will be looked into, in the order of their defined
1704
+ * level. A higher level means a higher priority. The first occurrence of
1705
+ * the variable will be returned here.
1706
+ *
1707
+ * @category Config/Methods
1708
+ * @signature
1709
+ * ```ts
1710
+ * class Config {
1711
+ * getI64(name: string): number;
1712
+ * }
1713
+ * ```
1714
+ *
1715
+ * @param {string} name - The name of config entry.
1716
+ * @returns The value of an integer config variable.
1717
+ */
1718
+ getI64(name: string): number
1719
+ /**
1720
+ * Find the value of an integer config variable.
1721
+ *
1722
+ * All config files will be looked into, in the order of their defined
1723
+ * level. A higher level means a higher priority. The first occurrence of
1724
+ * the variable will be returned here.
1725
+ *
1726
+ * @category Config/Methods
1727
+ * @signature
1728
+ * ```ts
1729
+ * class Config {
1730
+ * findI64(name: string): number | null;
1731
+ * }
1732
+ * ```
1733
+ *
1734
+ * @param {string} name - The name of config entry.
1735
+ * @returns The value of an integer config variable.
1736
+ */
1737
+ findI64(name: string): number | null
1738
+ /**
1739
+ * Get the value of a string config variable as a byte slice.
1740
+ *
1741
+ * @category Config/Methods
1742
+ * @signature
1743
+ * ```ts
1744
+ * class Config {
1745
+ * getBytes(name: string): Uint8Array;
1746
+ * }
1747
+ * ```
1748
+ *
1749
+ * @param {string} name - The name of config entry.
1750
+ * @returns The value of a string config variable as a byte slice.
1751
+ */
1752
+ getBytes(name: string): Uint8Array
1753
+ /**
1754
+ * Find the value of a string config variable as a byte slice.
1755
+ *
1756
+ * @category Config/Methods
1757
+ * @signature
1758
+ * ```ts
1759
+ * class Config {
1760
+ * findBytes(name: string): Uint8Array | null;
1761
+ * }
1762
+ * ```
1763
+ *
1764
+ * @param {string} name - The name of config entry.
1765
+ * @returns The value of a string config variable as a byte slice.
1766
+ */
1767
+ findBytes(name: string): Uint8Array | null
1768
+ /**
1769
+ * Get the value of a string config variable as an owned string.
1770
+ *
1771
+ * All config files will be looked into, in the order of their
1772
+ * defined level. A higher level means a higher priority. The
1773
+ * first occurrence of the variable will be returned here.
1774
+ *
1775
+ * @category Config/Methods
1776
+ * @signature
1777
+ * ```ts
1778
+ * class Config {
1779
+ * getString(name: string): string;
1780
+ * }
1781
+ * ```
1782
+ *
1783
+ * @param {string} name - The name of config entry.
1784
+ * @returns The value of a string config variable.
1785
+ * @throws An error will be returned if the config value is not valid utf-8.
1786
+ */
1787
+ getString(name: string): string
1788
+ /**
1789
+ * Find the value of a string config variable as an owned string.
1790
+ *
1791
+ * All config files will be looked into, in the order of their
1792
+ * defined level. A higher level means a higher priority. The
1793
+ * first occurrence of the variable will be returned here.
1794
+ *
1795
+ * @category Config/Methods
1796
+ * @signature
1797
+ * ```ts
1798
+ * class Config {
1799
+ * findString(name: string): string | null;
1800
+ * }
1801
+ * ```
1802
+ *
1803
+ * @param {string} name - The name of config entry.
1804
+ * @returns The value of a string config variable.
1805
+ */
1806
+ findString(name: string): string | null
1807
+ /**
1808
+ * Get the value of a path config variable.
1809
+ *
1810
+ * A leading '~' will be expanded to the global search path (which
1811
+ * defaults to the user's home directory but can be overridden via
1812
+ * [`git_libgit2_opts`][1].
1813
+ *
1814
+ * [1]: https://libgit2.org/docs/reference/v1.9.0/common/git_libgit2_opts.html
1815
+ *
1816
+ * All config files will be looked into, in the order of their
1817
+ * defined level. A higher level means a higher priority. The
1818
+ * first occurrence of the variable will be returned here.
1819
+ *
1820
+ * @category Config/Methods
1821
+ * @signature
1822
+ * ```ts
1823
+ * class Config {
1824
+ * getPath(name: string): string;
1825
+ * }
1826
+ * ```
1827
+ *
1828
+ * @param {string} name - The name of config entry.
1829
+ * @returns The value of a path config variable.
1830
+ */
1831
+ getPath(name: string): string
1832
+ /**
1833
+ * Find the value of a path config variable.
1834
+ *
1835
+ * A leading '~' will be expanded to the global search path (which
1836
+ * defaults to the user's home directory but can be overridden via
1837
+ * [`git_libgit2_opts`][1].
1838
+ *
1839
+ * [1]: https://libgit2.org/docs/reference/v1.9.0/common/git_libgit2_opts.html
1840
+ *
1841
+ * All config files will be looked into, in the order of their
1842
+ * defined level. A higher level means a higher priority. The
1843
+ * first occurrence of the variable will be returned here.
1844
+ *
1845
+ * @category Config/Methods
1846
+ * @signature
1847
+ * ```ts
1848
+ * class Config {
1849
+ * findPath(name: string): string | null;
1850
+ * }
1851
+ * ```
1852
+ *
1853
+ * @param {string} name - The name of config entry.
1854
+ * @returns The value of a path config variable.
1855
+ */
1856
+ findPath(name: string): string | null
1857
+ /**
1858
+ * Get the entry for a config variable.
1859
+ *
1860
+ * @category Config/Methods
1861
+ * @signature
1862
+ * ```ts
1863
+ * class Config {
1864
+ * getEntry(name: string): ConfigEntry;
1865
+ * }
1866
+ * ```
1867
+ *
1868
+ * @param {string} name - The name of config entry.
1869
+ * @returns `ConfigEntry` object representing a certain entry owned by a `Config` instance.
1870
+ */
1871
+ getEntry(name: string): ConfigEntry
1872
+ /**
1873
+ * Find the entry for a config variable.
1874
+ *
1875
+ * @category Config/Methods
1876
+ * @signature
1877
+ * ```ts
1878
+ * class Config {
1879
+ * findEntry(name: string): ConfigEntry | null;
1880
+ * }
1881
+ * ```
1882
+ *
1883
+ * @param {string} name - The name of config entry.
1884
+ * @returns `ConfigEntry` object representing a certain entry owned by a `Config` instance.
1885
+ */
1886
+ findEntry(name: string): ConfigEntry | null
1887
+ /**
1888
+ * Iterate over all the config variables.
1889
+ *
1890
+ * @category Config/Methods
1891
+ * @signature
1892
+ * ```ts
1893
+ * class Config {
1894
+ * entries(glob?: string): ConfigEntries;
1895
+ * }
1896
+ * ```
1897
+ *
1898
+ * @param {string} [glob] - If `glob` is provided, then the iterator will only iterate over all
1899
+ * variables whose name matches the pattern.
1900
+ * The regular expression is applied case-sensitively on the normalized form of
1901
+ * the variable name: the section and variable parts are lower-cased. The
1902
+ * subsection is left unchanged.
1903
+ *
1904
+ * @returns An iterator over the `ConfigEntry` values of a config.
1905
+ * @example
1906
+ *
1907
+ * ```ts
1908
+ * import { openDefaultConfig } from 'es-git';
1909
+ *
1910
+ * const config = openDefaultConfig();
1911
+ * for (const entry of config.entries()) {
1912
+ * console.log(entry.name, entry.value);
1913
+ * }
1914
+ * ```
1915
+ */
1916
+ entries(glob?: string | undefined | null): ConfigEntries
1917
+ /**
1918
+ * Iterate over the values of a multivar.
1919
+ *
1920
+ * @category Config/Methods
1921
+ * @signature
1922
+ * ```ts
1923
+ * class Config {
1924
+ * multivar(name: string, regexp?: string): ConfigEntries;
1925
+ * }
1926
+ * ```
1927
+ *
1928
+ * @param {string} name - The name of config entry.
1929
+ * @param {string} [regexp] - If `regexp` is provided, then the iterator will only iterate over all
1930
+ * values which match the pattern.
1931
+ * The regular expression is applied case-sensitively on the normalized form of
1932
+ * the variable name: the section and variable parts are lower-cased. The
1933
+ * subsection is left unchanged.
1934
+ *
1935
+ * @returns An iterator over the `ConfigEntry` values of a config.
1936
+ */
1937
+ multivar(name: string, regexp?: string | undefined | null): ConfigEntries
1938
+ /**
1939
+ * Set the value of a boolean config variable in the config file with the
1940
+ * highest level (usually the local one).
1941
+ *
1942
+ * @category Config/Methods
1943
+ * @signature
1944
+ * ```ts
1945
+ * class Config {
1946
+ * setBool(name: string, value: boolean): void;
1947
+ * }
1948
+ * ```
1949
+ *
1950
+ * @param {string} name - The name of config entry.
1951
+ * @param {boolean} value - The value of config entry.
1952
+ */
1953
+ setBool(name: string, value: boolean): void
1954
+ /**
1955
+ * Set the value of an integer config variable in the config file with the
1956
+ * highest level (usually the local one).
1957
+ *
1958
+ * @category Config/Methods
1959
+ * @signature
1960
+ * ```ts
1961
+ * class Config {
1962
+ * setI32(name: string, value: number): void;
1963
+ * }
1964
+ * ```
1965
+ *
1966
+ * @param {string} name - The name of config entry.
1967
+ * @param {number} value - The value of config entry.
1968
+ */
1969
+ setI32(name: string, value: number): void
1970
+ /**
1971
+ * Set the value of an integer config variable in the config file with the
1972
+ * highest level (usually the local one).
1973
+ *
1974
+ * @category Config/Methods
1975
+ * @signature
1976
+ * ```ts
1977
+ * class Config {
1978
+ * setI64(name: string, value: number): void;
1979
+ * }
1980
+ * ```
1981
+ *
1982
+ * @param {string} name - The name of config entry.
1983
+ * @param {number} value - The value of config entry.
1984
+ */
1985
+ setI64(name: string, value: number): void
1986
+ /**
1987
+ * Set the value of an multivar config variable in the config file with the
1988
+ * highest level (usually the local one).
1989
+ *
1990
+ * @category Config/Methods
1991
+ * @signature
1992
+ * ```ts
1993
+ * class Config {
1994
+ * setMultivar(name: string, regexp: string, value: string): void;
1995
+ * }
1996
+ * ```
1997
+ *
1998
+ * @param {string} name - The name of config entry.
1999
+ * @param {string} regexp - The regular expression is applied case-sensitively on the value.
2000
+ * @param {string} value - The value of config entry.
2001
+ */
2002
+ setMultivar(name: string, regexp: string, value: string): void
2003
+ /**
2004
+ * Set the value of a string config variable in the config file with the
2005
+ * highest level (usually the local one).
2006
+ *
2007
+ * @category Config/Methods
2008
+ * @signature
2009
+ * ```ts
2010
+ * class Config {
2011
+ * setString(name: string, value: string): void;
2012
+ * }
2013
+ * ```
2014
+ *
2015
+ * @param {string} name - The name of config entry.
2016
+ * @param {string} value - The value of config entry.
2017
+ */
2018
+ setString(name: string, value: string): void
2019
+ }
803
2020
  /**
804
2021
  * The diff object that contains all individual file deltas.
805
2022
  *
806
2023
  * This is an opaque structure which will be allocated by one of the diff
807
- * generator functions on the `Repository` structure (e.g. `diff_tree_to_tree`
808
- * or other `diff_*` functions).
809
- *
810
- * @hideconstructor
2024
+ * generator functions on the `Repository` class (e.g. `diffTreeToTree`
2025
+ * or other `diff*` functions).
811
2026
  */
812
2027
  export declare class Diff {
813
2028
  /**
@@ -819,59 +2034,211 @@ export declare class Diff {
819
2034
  * as if the old version was from the "onto" list and the new version
820
2035
  * is from the "from" list (with the exception that if the item has a
821
2036
  * pending DELETE in the middle, then it will show as deleted).
2037
+ *
2038
+ * @category Diff/Methods
2039
+ * @signature
2040
+ * ```ts
2041
+ * class Diff {
2042
+ * merge(diff: Diff): void;
2043
+ * }
2044
+ * ```
2045
+ *
2046
+ * @param {Diff} diff - Another diff to merge.
822
2047
  */
823
2048
  merge(diff: Diff): void
824
- /** Returns an iterator over the deltas in this diff. */
2049
+ /**
2050
+ * Returns an iterator over the deltas in this diff.
2051
+ *
2052
+ * @category Diff/Methods
2053
+ * @signature
2054
+ * ```ts
2055
+ * class Diff {
2056
+ * deltas(): Deltas;
2057
+ * }
2058
+ * ```
2059
+ *
2060
+ * @returns An iterator over the deltas in this diff.
2061
+ */
825
2062
  deltas(): Deltas
826
- /** Check if deltas are sorted case sensitively or insensitively. */
2063
+ /**
2064
+ * Check if deltas are sorted case sensitively or insensitively.
2065
+ *
2066
+ * @category Diff/Methods
2067
+ * @signature
2068
+ * ```ts
2069
+ * class Diff {
2070
+ * isSortedIcase(): boolean;
2071
+ * }
2072
+ * ```
2073
+ *
2074
+ * @returns Returns `true` if deltas are sorted case insensitively.
2075
+ */
827
2076
  isSortedIcase(): boolean
828
- /** Accumulate diff statistics for all patches. */
2077
+ /**
2078
+ * Accumulate diff statistics for all patches.
2079
+ *
2080
+ * @category Diff/Methods
2081
+ * @signature
2082
+ * ```ts
2083
+ * class Diff {
2084
+ * stats(): DiffStats;
2085
+ * }
2086
+ * ```
2087
+ *
2088
+ * @returns Diff statistics for all patches.
2089
+ */
829
2090
  stats(): DiffStats
830
- /** Iterate over a diff generating formatted text output. */
2091
+ /**
2092
+ * Iterate over a diff generating formatted text output.
2093
+ *
2094
+ * @category Diff/Methods
2095
+ * @signature
2096
+ * ```ts
2097
+ * class Diff {
2098
+ * print(options?: DiffPrintOptions | null): string;
2099
+ * }
2100
+ * ```
2101
+ *
2102
+ * @param {DiffPrintOptions} [options] - Print options for diff.
2103
+ * @returns Formatted text output.
2104
+ */
831
2105
  print(options?: DiffPrintOptions | undefined | null): string
2106
+ /**
2107
+ * Transform a diff marking file renames, copies, etc.
2108
+ *
2109
+ * This modifies a diff in place, replacing old entries that look like
2110
+ * renames or copies with new entries reflecting those changes. This also
2111
+ * will, if requested, break modified files into add/remove pairs if the
2112
+ * amount of change is above a threshold.
2113
+ *
2114
+ * @category Diff/Methods
2115
+ * @signature
2116
+ * ```ts
2117
+ * class Diff {
2118
+ * findSimilar(options?: DiffFindOptions): void;
2119
+ * }
2120
+ * ```
2121
+ *
2122
+ * @param {DiffFindOptions} [options] - Options for finding diff.
2123
+ */
2124
+ findSimilar(options?: DiffFindOptions | undefined | null): void
832
2125
  }
833
- /**
834
- * Structure describing a hunk of a diff.
835
- *
836
- * @hideconstructor
837
- */
2126
+ /** A class describing a hunk of a diff. */
838
2127
  export declare class DiffStats {
839
- /** Get the total number of files changed in a diff. */
2128
+ /**
2129
+ * Get the total number of files changed in a diff.
2130
+ *
2131
+ * @category Diff/DiffStats
2132
+ * @signature
2133
+ * ```ts
2134
+ * class DiffStats {
2135
+ * get filesChanged(): bigint;
2136
+ * }
2137
+ * ```
2138
+ *
2139
+ * @returns Total number of files changed in a diff.
2140
+ */
840
2141
  get filesChanged(): bigint
841
- /** Get the total number of insertions in a diff */
2142
+ /**
2143
+ * Get the total number of insertions in a diff
2144
+ *
2145
+ * @category Diff/DiffStats
2146
+ * @signature
2147
+ * ```ts
2148
+ * class DiffStats {
2149
+ * get insertions(): bigint;
2150
+ * }
2151
+ * ```
2152
+ *
2153
+ * @returns Total number of insertions in a diff.
2154
+ */
842
2155
  get insertions(): bigint
843
- /** Get the total number of deletions in a diff */
2156
+ /**
2157
+ * Get the total number of deletions in a diff
2158
+ *
2159
+ * @category Diff/DiffStats
2160
+ * @signature
2161
+ * ```ts
2162
+ * class DiffStats {
2163
+ * get deletions(): bigint;
2164
+ * }
2165
+ * ```
2166
+ *
2167
+ * @returns Total number of deletions in a diff.
2168
+ */
844
2169
  get deletions(): bigint
845
2170
  }
846
- /**
847
- * An iterator over the diffs in a delta
848
- *
849
- * @hideconstructor
850
- */
2171
+ /** An iterator over the diffs in a delta. */
851
2172
  export declare class Deltas {
852
2173
  [Symbol.iterator](): Iterator<DiffDelta, void, void>
853
2174
  }
854
- /**
855
- * Description of changes to one entry.
856
- *
857
- * @hideconstructor
858
- */
2175
+ /** Description of changes to one entry. */
859
2176
  export declare class DiffDelta {
860
2177
  /**
861
2178
  * Returns the flags on the delta.
862
2179
  *
863
- * For more information, see `DiffFlags`'s documentation.
2180
+ * @category Diff/DiffDelta
2181
+ * @signature
2182
+ * ```ts
2183
+ * class DiffDelta {
2184
+ * flags(): number;
2185
+ * }
2186
+ * ```
2187
+ *
2188
+ * @returns The flags on the delta.
2189
+ *
2190
+ * @example
2191
+ * ```ts
2192
+ * import { DiffDelta, DiffFlags, diffFlagsContains } from 'es-git';
2193
+ *
2194
+ * const delta: DiffDelta;
2195
+ * console.assert(diffFlagsContains(delta.flags(), DiffFlags.Binary | DiffFlags.ValidId));
2196
+ * ```
864
2197
  */
865
2198
  flags(): number
866
- /** Returns the number of files in this delta. */
2199
+ /**
2200
+ * Returns the number of files in this delta.
2201
+ *
2202
+ * @category Diff/DiffDelta
2203
+ * @signature
2204
+ * ```ts
2205
+ * class DiffDelta {
2206
+ * numFiles(): number;
2207
+ * }
2208
+ * ```
2209
+ *
2210
+ * @returns The number of files in this delta.
2211
+ */
867
2212
  numFiles(): number
868
- /** Returns the status of this entry */
2213
+ /**
2214
+ * Returns the status of this entry.
2215
+ *
2216
+ * @category Diff/DiffDelta
2217
+ * @signature
2218
+ * ```ts
2219
+ * class DiffDelta {
2220
+ * status(): DeltaType;
2221
+ * }
2222
+ * ```
2223
+ *
2224
+ * @returns The status of this entry.
2225
+ */
869
2226
  status(): DeltaType
870
2227
  /**
871
2228
  * Return the file which represents the "from" side of the diff.
872
2229
  *
873
2230
  * What side this means depends on the function that was used to generate
874
2231
  * the diff and will be documented on the function itself.
2232
+ *
2233
+ * @category Diff/DiffDelta
2234
+ * @signature
2235
+ * ```ts
2236
+ * class DiffDelta {
2237
+ * oldFile(): DiffFile;
2238
+ * }
2239
+ * ```
2240
+ *
2241
+ * @returns The file which represents the "from" side of the diff.
875
2242
  */
876
2243
  oldFile(): DiffFile
877
2244
  /**
@@ -879,6 +2246,16 @@ export declare class DiffDelta {
879
2246
  *
880
2247
  * What side this means depends on the function that was used to generate
881
2248
  * the diff and will be documented on the function itself.
2249
+ *
2250
+ * @category Diff/DiffDelta
2251
+ * @signature
2252
+ * ```ts
2253
+ * class DiffDelta {
2254
+ * newFile(): DiffFile;
2255
+ * }
2256
+ * ```
2257
+ *
2258
+ * @returns The file which represents the "to" side of the diff.
882
2259
  */
883
2260
  newFile(): DiffFile
884
2261
  }
@@ -888,44 +2265,130 @@ export declare class DiffDelta {
888
2265
  * Although this is called a "file" it could represent a file, a symbolic
889
2266
  * link, a submodule commit id, or even a tree (although that only happens if
890
2267
  * you are tracking type changes or ignored/untracked directories).
891
- *
892
- * @hideconstructor
893
2268
  */
894
2269
  export declare class DiffFile {
895
2270
  /**
896
2271
  * Returns the Oid of this item.
897
2272
  *
898
- * If this entry represents an absent side of a diff (e.g. the `old_file`
2273
+ * If this entry represents an absent side of a diff (e.g. the `oldFile`
899
2274
  * of a `Added` delta), then the oid returned will be zeroes.
2275
+ *
2276
+ * @category Diff/DiffFile
2277
+ * @signature
2278
+ * ```ts
2279
+ * class DiffFile {
2280
+ * id(): string;
2281
+ * }
2282
+ * ```
2283
+ *
2284
+ * @returns The Oid of this item.
900
2285
  */
901
2286
  id(): string
902
2287
  /**
903
2288
  * Returns the path of the entry relative to the working directory of the
904
2289
  * repository.
2290
+ *
2291
+ * @category Diff/DiffFile
2292
+ * @signature
2293
+ * ```ts
2294
+ * class DiffFile {
2295
+ * path(): string | null;
2296
+ * }
2297
+ * ```
2298
+ *
2299
+ * @returns Ths path of the entry relative to the working directory of the repository.
905
2300
  */
906
2301
  path(): string | null
907
- /** Returns the size of this entry, in bytes */
2302
+ /**
2303
+ * Returns the size of this entry, in bytes.
2304
+ *
2305
+ * @category Diff/DiffFile
2306
+ * @signature
2307
+ * ```ts
2308
+ * class DiffFile {
2309
+ * size(): bigint;
2310
+ * }
2311
+ * ```
2312
+ *
2313
+ * @returns The size of this entry, in bytes.
2314
+ */
908
2315
  size(): bigint
909
- /** Returns `true` if file(s) are treated as binary data. */
2316
+ /**
2317
+ * Returns `true` if file(s) are treated as binary data.
2318
+ *
2319
+ * @category Diff/DiffFile
2320
+ * @signature
2321
+ * ```ts
2322
+ * class DiffFile {
2323
+ * isBinary(): boolean;
2324
+ * }
2325
+ * ```
2326
+ *
2327
+ * @returns Returns `true` if file(s) are treated as binary data.
2328
+ */
910
2329
  isBinary(): boolean
911
- /** Returns `true` if `id` value is known correct. */
2330
+ /**
2331
+ * Returns `true` if `id` value is known correct.
2332
+ *
2333
+ * @category Diff/DiffFile
2334
+ * @signature
2335
+ * ```ts
2336
+ * class DiffFile {
2337
+ * isValidId(): boolean;
2338
+ * }
2339
+ * ```
2340
+ *
2341
+ * @returns Returns `true` if `id` value is known correct.
2342
+ */
912
2343
  isValidId(): boolean
913
- /** Returns `true` if file exists at this side of the delta. */
2344
+ /**
2345
+ * Returns `true` if file exists at this side of the delta.
2346
+ *
2347
+ * @category Diff/DiffFile
2348
+ * @signature
2349
+ * ```ts
2350
+ * class DiffFile {
2351
+ * exists(): boolean;
2352
+ * }
2353
+ * ```
2354
+ *
2355
+ * @returns Returns `true` if file exists at this side of the delta.
2356
+ */
914
2357
  exists(): boolean
915
- /** Returns file mode. */
2358
+ /**
2359
+ * Returns file mode.
2360
+ *
2361
+ * @category Diff/DiffFile
2362
+ * @signature
2363
+ * ```ts
2364
+ * class DiffFile {
2365
+ * mode(): FileMode;
2366
+ * }
2367
+ * ```
2368
+ *
2369
+ * @returns
2370
+ */
916
2371
  mode(): FileMode
917
2372
  }
918
2373
  /**
919
- * A structure to represent a git [index][1]
920
- * @hideconstructor
2374
+ * A class to represent a git [index][1].
921
2375
  *
922
- * [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects
2376
+ * [1]: https://git-scm.com/book/en/Git-Internals-Git-Objects
923
2377
  */
924
2378
  export declare class Index {
925
2379
  /**
926
2380
  * Get index on-disk version.
927
2381
  *
928
- * Valid return values are 2, 3, or 4. If 3 is returned, an index
2382
+ * @category Index/Methods
2383
+ * @signature
2384
+ * ```ts
2385
+ * class Index {
2386
+ * version(): number;
2387
+ * }
2388
+ * ```
2389
+ *
2390
+ * @returns Index on-disk version.
2391
+ * Valid return values are 2, 3, or 4. If 3 is returned, an index
929
2392
  * with version 2 may be written instead, if the extension data in
930
2393
  * version 3 is not necessary.
931
2394
  */
@@ -933,20 +2396,38 @@ export declare class Index {
933
2396
  /**
934
2397
  * Set index on-disk version.
935
2398
  *
936
- * Valid values are 2, 3, or 4. If 2 is given, git_index_write may
2399
+ * @category Index/Methods
2400
+ * @signature
2401
+ * ```ts
2402
+ * class Index {
2403
+ * setVersion(version: number): number;
2404
+ * }
2405
+ * ```
2406
+ *
2407
+ * @param {string} version - Version to set.
2408
+ * Valid values are 2, 3, or 4. If 2 is given, git_index_write may
937
2409
  * write an index with version 3 instead, if necessary to accurately
938
2410
  * represent the index.
939
2411
  */
940
2412
  setVersion(version: number): void
941
- /** Get one of the entries in the index by its path. */
942
- getByPath(path: string, stage?: IndexStage | undefined | null): IndexEntry | null
943
2413
  /**
944
- * Add or update an index entry from a file on disk
2414
+ * Get one of the entries in the index by its path.
945
2415
  *
946
- * The file path must be relative to the repository's working folder and
947
- * must be readable.
2416
+ * @category Index/Methods
2417
+ * @signature
2418
+ * ```ts
2419
+ * class Index {
2420
+ * getByPath(path: string, stage?: IndexStage): IndexEntry | null;
2421
+ * }
2422
+ * ```
948
2423
  *
949
- * This method will fail in bare index instances.
2424
+ * @param {string} path - Path to lookup entry.
2425
+ * @param {IndexStage} [stage] - Git index stage states.
2426
+ * @returns Index entry for the path.
2427
+ */
2428
+ getByPath(path: string, stage?: IndexStage | undefined | null): IndexEntry | null
2429
+ /**
2430
+ * Add or update an index entry from a file on disk.
950
2431
  *
951
2432
  * This forces the file to be added to the index, not looking at gitignore
952
2433
  * rules.
@@ -954,17 +2435,38 @@ export declare class Index {
954
2435
  * If this file currently is the result of a merge conflict, this file will
955
2436
  * no longer be marked as conflicting. The data about the conflict will be
956
2437
  * moved to the "resolve undo" (REUC) section.
2438
+ *
2439
+ * @category Index/Methods
2440
+ * @signature
2441
+ * ```ts
2442
+ * class Index {
2443
+ * addPath(path: string): void;
2444
+ * }
2445
+ * ```
2446
+ *
2447
+ * @param {string} path - Relative file path to the repository's working directory and must be
2448
+ * readable.
2449
+ *
2450
+ * @throws This method will fail in bare index instances.
957
2451
  */
958
2452
  addPath(path: string): void
959
2453
  /**
960
2454
  * Add or update index entries matching files in the working directory.
961
2455
  *
962
- * This method will fail in bare index instances.
2456
+ * @category Index/Methods
2457
+ * @signature
2458
+ * ```ts
2459
+ * class Index {
2460
+ * addAll(pathspecs: string[], options?: IndexAddAllOptions): void;
2461
+ * }
2462
+ * ```
963
2463
  *
964
- * The `pathspecs` are a list of file names or shell glob patterns that
965
- * will matched against files in the repository's working directory. Each
966
- * file that matches will be added to the index (either updating an
967
- * existing entry or adding a new entry).
2464
+ * @param {string[]} pathspecs - A List of file names of shell glob patterns that will matched
2465
+ * against files in the repository's working directory. Each file that matches will be added
2466
+ * to the index (either updating an existing entry or adding a new entry).
2467
+ * @param {IndexAddAllOptions} [options] - Options for add or update index entries.
2468
+ *
2469
+ * @throws This method will fail in bare index instances.
968
2470
  *
969
2471
  * @example
970
2472
  *
@@ -984,11 +2486,19 @@ export declare class Index {
984
2486
  * Update the contents of an existing index object in memory by reading
985
2487
  * from the hard disk.
986
2488
  *
987
- * If force is true, this performs a "hard" read that discards in-memory
988
- * changes and always reloads the on-disk index data. If there is no
989
- * on-disk version, the index will be cleared.
2489
+ * @category Index/Methods
2490
+ * @signature
2491
+ * ```ts
2492
+ * class Index {
2493
+ * read(force?: boolean): void;
2494
+ * }
2495
+ * ```
2496
+ *
2497
+ * @param {boolean} [force] - If force is `true`, this performs a "hard" read that discards
2498
+ * in-memory changes and always reloads the on-disk index data. If there is no on-disk version,
2499
+ * the index will be cleared.
990
2500
  *
991
- * If force is false, this does a "soft" read that reloads the index data
2501
+ * If force is `false`, this does a "soft" read that reloads the index data
992
2502
  * from disk only if it has changed since the last time it was loaded.
993
2503
  * Purely in-memory index data will be untouched. Be aware: if there are
994
2504
  * changes on disk, unwritten in-memory changes are discarded.
@@ -997,6 +2507,14 @@ export declare class Index {
997
2507
  /**
998
2508
  * Write an existing index object from memory back to disk using an atomic
999
2509
  * file lock.
2510
+ *
2511
+ * @category Index/Methods
2512
+ * @signature
2513
+ * ```ts
2514
+ * class Index {
2515
+ * write(): void;
2516
+ * }
2517
+ * ```
1000
2518
  */
1001
2519
  write(): void
1002
2520
  /**
@@ -1011,96 +2529,248 @@ export declare class Index {
1011
2529
  * existing repository.
1012
2530
  *
1013
2531
  * The index must not contain any file in conflict.
2532
+ *
2533
+ * @category Index/Methods
2534
+ * @signature
2535
+ * ```ts
2536
+ * class Index {
2537
+ * writeTree(): void;
2538
+ * }
2539
+ * ```
1014
2540
  */
1015
2541
  writeTree(): string
1016
2542
  /**
1017
2543
  * Remove an index entry corresponding to a file on disk.
1018
2544
  *
1019
- * The file path must be relative to the repository's working folder. It
1020
- * may exist.
1021
- *
1022
2545
  * If this file currently is the result of a merge conflict, this file will
1023
2546
  * no longer be marked as conflicting. The data about the conflict will be
1024
2547
  * moved to the "resolve undo" (REUC) section.
2548
+ *
2549
+ * @category Index/Methods
2550
+ * @signature
2551
+ * ```ts
2552
+ * class Index {
2553
+ * removePath(path: string, options?: IndexRemoveOptions): void;
2554
+ * }
2555
+ * ```
2556
+ *
2557
+ * @param {string} path - Relative file path to the repository's working directory.
2558
+ * @param {IndexRemoveOptions} options - Options for remove an index entry.
1025
2559
  */
1026
2560
  removePath(path: string, options?: IndexRemoveOptions | undefined | null): void
1027
- /** Remove all matching index entries. */
1028
- removeAll(pathspecs: Array<string>, options?: IndexRemoveAllOptions | undefined | null): void
1029
2561
  /**
1030
- * Update all index entries to match the working directory
2562
+ * Remove all matching index entries.
2563
+ *
2564
+ * @category Index/Methods
2565
+ * @signature
2566
+ * ```ts
2567
+ * class Index {
2568
+ * removeAll(pathspecs: string[], options?: IndexRemoveAllOptions): void;
2569
+ * }
2570
+ * ```
1031
2571
  *
1032
- * This method will fail in bare index instances.
2572
+ * @param {string[]} pathspecs - A List of file names of shell glob patterns that will matched
2573
+ * against files in the repository's working directory
2574
+ * @param {IndexRemoveAllOptions} options - Options for remove all matching index entry.
2575
+ */
2576
+ removeAll(pathspecs: Array<string>, options?: IndexRemoveAllOptions | undefined | null): void
2577
+ /**
2578
+ * Update all index entries to match the working directory.
1033
2579
  *
1034
2580
  * This scans the existing index entries and synchronizes them with the
1035
2581
  * working directory, deleting them if the corresponding working directory
1036
2582
  * file no longer exists otherwise updating the information (including
1037
2583
  * adding the latest version of file to the ODB if needed).
2584
+ *
2585
+ * @category Index/Methods
2586
+ * @signature
2587
+ * ```ts
2588
+ * class Index {
2589
+ * updateAll(pathspecs: string[], options?: IndexUpdateAllOptions): void;
2590
+ * }
2591
+ * ```
2592
+ *
2593
+ * @param {string[]} pathspecs - A List of file names of shell glob patterns that will matched
2594
+ * against files in the repository's working directory
2595
+ * @param {IndexUpdateAllOptions} options - Options for update all matching index entry.
2596
+ *
2597
+ * @throws This method will fail in bare index instances.
1038
2598
  */
1039
2599
  updateAll(pathspecs: Array<string>, options?: IndexUpdateAllOptions | undefined | null): void
1040
- /** Get the count of entries currently in the index */
2600
+ /**
2601
+ * Get the count of entries currently in the index.
2602
+ *
2603
+ * @category Index/Methods
2604
+ * @signature
2605
+ * ```ts
2606
+ * class Index {
2607
+ * count(): number;
2608
+ * }
2609
+ * ```
2610
+ *
2611
+ * @returns The count of entries currently in the index.
2612
+ */
1041
2613
  count(): number
1042
- /** Return `true` is there is no entry in the index */
2614
+ /**
2615
+ * Return `true` is there is no entry in the index.
2616
+ *
2617
+ * @category Index/Methods
2618
+ * @signature
2619
+ * ```ts
2620
+ * class Index {
2621
+ * isEmpty(): boolean;
2622
+ * }
2623
+ * ```
2624
+ *
2625
+ * @returns Return `true` is there is no entry in the index.
2626
+ */
1043
2627
  isEmpty(): boolean
1044
2628
  /**
1045
2629
  * Get the full path to the index file on disk.
1046
2630
  *
1047
- * Returns `None` if this is an in-memory index.
2631
+ * @category Index/Methods
2632
+ * @signature
2633
+ * ```ts
2634
+ * class Index {
2635
+ * path(): string | null;
2636
+ * }
2637
+ * ```
2638
+ *
2639
+ * @returns Returns `null` if this is an in-memory index.
1048
2640
  */
1049
2641
  path(): string | null
1050
2642
  /**
1051
2643
  * Does this index have conflicts?
1052
2644
  *
1053
- * Returns `true` if the index contains conflicts, `false` if it does not.
2645
+ * @category Index/Methods
2646
+ * @signature
2647
+ * ```ts
2648
+ * class Index {
2649
+ * hasConflicts(): boolean;
2650
+ * }
2651
+ * ```
2652
+ *
2653
+ * @returns Returns `true` if the index contains conflicts, `false` if it does not.
1054
2654
  */
1055
2655
  hasConflicts(): boolean
1056
- /** Get an iterator over the entries in this index. */
2656
+ /**
2657
+ * Get an iterator over the entries in this index.
2658
+ *
2659
+ * @category Index/Methods
2660
+ * @signature
2661
+ * ```ts
2662
+ * class Index {
2663
+ * entries(): IndexEntries;
2664
+ * }
2665
+ * ```
2666
+ *
2667
+ * @returns An iterator over the entries in this index.
2668
+ */
1057
2669
  entries(): IndexEntries
1058
2670
  }
1059
- /**
1060
- * An iterator over the entries in an index
1061
- *
1062
- * @hideconstructor
1063
- */
2671
+ /** An iterator over the entries in an index. */
1064
2672
  export declare class IndexEntries {
1065
2673
  [Symbol.iterator](): Iterator<IndexEntry, void, void>
1066
2674
  }
1067
2675
  /**
1068
- * A structure to represent a git [object][1]
1069
- * @hideconstructor
2676
+ * A class to represent a git [object][1].
1070
2677
  *
1071
- * [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects
2678
+ * [1]: https://git-scm.com/book/en/Git-Internals-Git-Objects
1072
2679
  */
1073
2680
  export declare class GitObject {
1074
- /** Get the id (SHA1) of a repository object */
2681
+ /**
2682
+ * Get the id (SHA1) of a repository object.
2683
+ *
2684
+ * @category Object/Methods
2685
+ * @signature
2686
+ * ```ts
2687
+ * class GitObject {
2688
+ * id(): string;
2689
+ * }
2690
+ * ```
2691
+ *
2692
+ * @returns ID(SHA1) of a repository object.
2693
+ */
1075
2694
  id(): string
1076
2695
  /**
1077
2696
  * Get the object type of object.
1078
2697
  *
1079
- * If the type is unknown, then `null` is returned.
2698
+ * @category Object/Methods
2699
+ * @signature
2700
+ * ```ts
2701
+ * class GitObject {
2702
+ * type(): ObjectType | null;
2703
+ * }
2704
+ * ```
2705
+ *
2706
+ * @returns If the type is unknown, then `null` is returned.
1080
2707
  */
1081
2708
  type(): ObjectType | null
1082
2709
  /**
1083
2710
  * Recursively peel an object until an object of the specified type is met.
1084
2711
  *
1085
- * If you pass `Any` as the target type, then the object will be
2712
+ * @category Object/Methods
2713
+ * @signature
2714
+ * ```ts
2715
+ * class GitObject {
2716
+ * peel(objType: ObjectType): GitObject;
2717
+ * }
2718
+ * ```
2719
+ *
2720
+ * @param {ObjectType} objType - If you pass `Any` as the target type, then the object will be
1086
2721
  * peeled until the type changes (e.g. a tag will be chased until the
1087
2722
  * referenced object is no longer a tag).
2723
+ *
2724
+ * @returns Git object which recursively peeled.
1088
2725
  */
1089
2726
  peel(objType: ObjectType): GitObject
1090
- /** Recursively peel an object until a commit is found */
2727
+ /**
2728
+ * Recursively peel an object until a commit is found.
2729
+ *
2730
+ * @category Object/Methods
2731
+ * @signature
2732
+ * ```ts
2733
+ * class GitObject {
2734
+ * peelToCommit(): Commit;
2735
+ * }
2736
+ * ```
2737
+ *
2738
+ * @returns Git commit.
2739
+ */
1091
2740
  peelToCommit(): Commit
2741
+ /**
2742
+ * Recursively peel an object until a blob is found.
2743
+ *
2744
+ * @category Object/Methods
2745
+ * @signature
2746
+ * ```ts
2747
+ * class GitObject {
2748
+ * peelToBlob(): Blob;
2749
+ * }
2750
+ * ```
2751
+ *
2752
+ * @returns Git blob.
2753
+ */
2754
+ peelToBlob(): Blob
1092
2755
  /**
1093
2756
  * Attempt to view this object as a commit.
1094
2757
  *
1095
- * Returns `null` if the object is not actually a commit.
2758
+ * @category Object/Methods
2759
+ * @signature
2760
+ * ```ts
2761
+ * class GitObject {
2762
+ * asCommit(): Commit | null;
2763
+ * }
2764
+ * ```
2765
+ *
2766
+ * @returns Returns `null` if the object is not actually a commit.
1096
2767
  */
1097
2768
  asCommit(): Commit | null
1098
2769
  }
1099
2770
  /**
1100
- * A structure to represent a git [reference][1].
1101
- * @hideconstructor
2771
+ * A class to represent a git [reference][1].
1102
2772
  *
1103
- * [1]: http://git-scm.com/book/en/Git-Internals-Git-References
2773
+ * [1]: https://git-scm.com/book/en/Git-Internals-Git-References
1104
2774
  */
1105
2775
  export declare class Reference {
1106
2776
  /**
@@ -1109,28 +2779,101 @@ export declare class Reference {
1109
2779
  * This method works for both direct and symbolic references. The reference
1110
2780
  * will be immediately removed on disk.
1111
2781
  *
1112
- * This function will return an error if the reference has changed from the
2782
+ * @category Reference/Methods
2783
+ * @signature
2784
+ * ```ts
2785
+ * class Reference {
2786
+ * delete(): void;
2787
+ * }
2788
+ * ```
2789
+ *
2790
+ * @throws This method will throws an error if the reference has changed from the
1113
2791
  * time it was looked up.
1114
2792
  */
1115
2793
  delete(): void
1116
- /** Check if a reference is a local branch. */
2794
+ /**
2795
+ * Check if a reference is a local branch.
2796
+ *
2797
+ * @category Reference/Methods
2798
+ * @signature
2799
+ * ```ts
2800
+ * class Reference {
2801
+ * isBranch(): boolean;
2802
+ * }
2803
+ * ```
2804
+ *
2805
+ * @returns Returns `true` if a reference is a local branch.
2806
+ */
1117
2807
  isBranch(): boolean
1118
- /** Check if a reference is a note. */
2808
+ /**
2809
+ * Check if a reference is a note.
2810
+ *
2811
+ * @category Reference/Methods
2812
+ * @signature
2813
+ * ```ts
2814
+ * class Reference {
2815
+ * isNote(): boolean;
2816
+ * }
2817
+ * ```
2818
+ *
2819
+ * @returns Returns `true` if a reference is a note.
2820
+ */
1119
2821
  isNote(): boolean
1120
- /** Check if a reference is a remote tracking branch */
2822
+ /**
2823
+ * Check if a reference is a remote tracking branch.
2824
+ *
2825
+ * @category Reference/Methods
2826
+ * @signature
2827
+ * ```ts
2828
+ * class Reference {
2829
+ * isRemote(): boolean;
2830
+ * }
2831
+ * ```
2832
+ *
2833
+ * @returns Returns `true` if a reference is a remote tracking branch.
2834
+ */
1121
2835
  isRemote(): boolean
1122
- /** Check if a reference is a tag */
2836
+ /**
2837
+ * Check if a reference is a tag.
2838
+ *
2839
+ * @category Reference/Methods
2840
+ * @signature
2841
+ * ```ts
2842
+ * class Reference {
2843
+ * isTag(): boolean;
2844
+ * }
2845
+ * ```
2846
+ *
2847
+ * @returns Returns `true` if a reference is a tag.
2848
+ */
1123
2849
  isTag(): boolean
1124
2850
  /**
1125
2851
  * Get the reference type of a reference.
1126
2852
  *
1127
- * If the type is unknown, then `null` is returned.
2853
+ * @category Reference/Methods
2854
+ * @signature
2855
+ * ```ts
2856
+ * class Reference {
2857
+ * type(): ReferenceType | null;
2858
+ * }
2859
+ * ```
2860
+ *
2861
+ * @returns Returns `null` if the type is unknown.
1128
2862
  */
1129
2863
  type(): ReferenceType | null
1130
2864
  /**
1131
2865
  * Get the full name of a reference.
1132
2866
  *
1133
- * Throws error if the name is not valid utf-8.
2867
+ * @category Reference/Methods
2868
+ * @signature
2869
+ * ```ts
2870
+ * class Reference {
2871
+ * name(): string;
2872
+ * }
2873
+ * ```
2874
+ *
2875
+ * @returns Full name of a reference.
2876
+ * @throws Throws error if the name is not valid utf-8.
1134
2877
  */
1135
2878
  name(): string
1136
2879
  /**
@@ -1139,7 +2882,16 @@ export declare class Reference {
1139
2882
  * This will transform the reference name into a name "human-readable"
1140
2883
  * version. If no shortname is appropriate, it will return the full name.
1141
2884
  *
1142
- * Throws error if the shorthand is not valid utf-8.
2885
+ * @category Reference/Methods
2886
+ * @signature
2887
+ * ```ts
2888
+ * class Reference {
2889
+ * shorthand(): string;
2890
+ * }
2891
+ * ```
2892
+ *
2893
+ * @returns Full shorthand of a reference.
2894
+ * @throws Throws error if the shorthand is not valid utf-8.
1143
2895
  */
1144
2896
  shorthand(): string
1145
2897
  /**
@@ -1147,26 +2899,65 @@ export declare class Reference {
1147
2899
  *
1148
2900
  * Only available if the reference is direct (i.e. an object id reference,
1149
2901
  * not a symbolic one).
2902
+ *
2903
+ * @category Reference/Methods
2904
+ * @signature
2905
+ * ```ts
2906
+ * class Reference {
2907
+ * target(): string | null;
2908
+ * }
2909
+ * ```
2910
+ *
2911
+ * @returns OID pointed to by a direct reference.
1150
2912
  */
1151
2913
  target(): string | null
1152
2914
  /**
1153
2915
  * Return the peeled OID target of this reference.
1154
2916
  *
1155
- * This peeled OID only applies to direct references that point to a hard
1156
- * Tag object: it is the result of peeling such Tag.
2917
+ * This peeled OID only applies to direct references that point to a hard.
2918
+ *
2919
+ * @category Reference/Methods
2920
+ * @signature
2921
+ * ```ts
2922
+ * class Reference {
2923
+ * targetPeel(): string | null;
2924
+ * }
2925
+ * ```
2926
+ *
2927
+ * @returns Peeled OID of this reference.
1157
2928
  */
1158
2929
  targetPeel(): string | null
1159
2930
  /**
1160
- * Peel a reference to a tree
2931
+ * Peel a reference to a tree.
1161
2932
  *
1162
2933
  * This method recursively peels the reference until it reaches
1163
2934
  * a tree.
2935
+ *
2936
+ * @category Reference/Methods
2937
+ * @signature
2938
+ * ```ts
2939
+ * class Reference {
2940
+ * peelToTree(): Tree;
2941
+ * }
2942
+ * ```
2943
+ *
2944
+ * @returns Peeled `Tree` of this reference.
1164
2945
  */
1165
2946
  peelToTree(): Tree
1166
2947
  /**
1167
2948
  * Get full name to the reference pointed to by a symbolic reference.
1168
2949
  *
1169
2950
  * Only available if the reference is symbolic.
2951
+ *
2952
+ * @category Reference/Methods
2953
+ * @signature
2954
+ * ```ts
2955
+ * class Reference {
2956
+ * symbolicTarget(): string | null;
2957
+ * }
2958
+ * ```
2959
+ *
2960
+ * @returns Full name of the reference pointed to by a symbolic reference.
1170
2961
  */
1171
2962
  symbolicTarget(): string | null
1172
2963
  /**
@@ -1177,6 +2968,16 @@ export declare class Reference {
1177
2968
  *
1178
2969
  * If a direct reference is passed as an argument, a copy of that
1179
2970
  * reference is returned.
2971
+ *
2972
+ * @category Reference/Methods
2973
+ * @signature
2974
+ * ```ts
2975
+ * class Reference {
2976
+ * resolve(): Reference;
2977
+ * }
2978
+ * ```
2979
+ *
2980
+ * @returns Resolved reference.
1180
2981
  */
1181
2982
  resolve(): Reference
1182
2983
  /**
@@ -1184,146 +2985,414 @@ export declare class Reference {
1184
2985
  *
1185
2986
  * This method works for both direct and symbolic references.
1186
2987
  *
1187
- * If the force flag is not enabled, and there's already a reference with
1188
- * the given name, the renaming will fail.
2988
+ * @category Reference/Methods
2989
+ * @signature
2990
+ * ```ts
2991
+ * class Reference {
2992
+ * rename(newName: string, options?: RenameReferenceOptions): Reference;
2993
+ * }
2994
+ * ```
2995
+ *
2996
+ * @param {string} newName - Name to rename an existing reference.
2997
+ * @param {RenameReferenceOptions} [options] - Options to rename an existing reference.
2998
+ * @returns Renamed reference.
1189
2999
  */
1190
3000
  rename(newName: string, options?: RenameReferenceOptions | undefined | null): Reference
1191
3001
  }
1192
3002
  /**
1193
- * A structure representing a [remote][1] of a git repository.
1194
- * @hideconstructor
3003
+ * A class representing a [remote][1] of a git repository.
1195
3004
  *
1196
- * [1]: http://git-scm.com/book/en/Git-Basics-Working-with-Remotes
3005
+ * [1]: https://git-scm.com/book/en/Git-Basics-Working-with-Remotes
1197
3006
  */
1198
3007
  export declare class Remote {
1199
3008
  /**
1200
3009
  * Get the remote's name.
1201
3010
  *
1202
- * Returns `null` if this remote has not yet been named, and
1203
- * Throws error if the URL is not valid utf-8
3011
+ * @category Remote/Methods
3012
+ * @signature
3013
+ * ```ts
3014
+ * class Remote {
3015
+ * name(): string | null;
3016
+ * }
3017
+ * ```
3018
+ *
3019
+ * @returns Returns `null` if this remote has not yet been named.
3020
+ * @throws Throws error if the name is not valid utf-8.
1204
3021
  */
1205
3022
  name(): string | null
1206
3023
  /**
1207
3024
  * Get the remote's URL.
1208
3025
  *
1209
- * Throws error if the URL is not valid utf-8
3026
+ * @category Remote/Methods
3027
+ * @signature
3028
+ * ```ts
3029
+ * class Remote {
3030
+ * url(): string;
3031
+ * }
3032
+ * ```
3033
+ *
3034
+ * @throws Throws error if the URL is not valid utf-8.
1210
3035
  */
1211
3036
  url(): string
1212
3037
  /**
1213
3038
  * Get the remote's URL.
1214
3039
  *
1215
- * Returns `null` if push url not exists, and
1216
- * Throws error if the URL is not valid utf-8
3040
+ * @category Remote/Methods
3041
+ * @signature
3042
+ * ```ts
3043
+ * class Remote {
3044
+ * pushurl(): string | null;
3045
+ * }
3046
+ * ```
3047
+ *
3048
+ * @returns Returns `null` if push url not exists.
3049
+ * @throws Throws error if the URL is not valid utf-8.
1217
3050
  */
1218
3051
  pushurl(): string | null
1219
3052
  /**
1220
3053
  * List all refspecs.
1221
3054
  *
1222
- * Filter refspec if has not valid src or dst with utf-8
3055
+ * Filter refspec if has not valid `src` or `dst` with utf-8.
3056
+ *
3057
+ * @category Remote/Methods
3058
+ * @signature
3059
+ * ```ts
3060
+ * class Remote {
3061
+ * refspecs(): Refspec[];
3062
+ * }
3063
+ * ```
3064
+ *
3065
+ * @returns List all refspecs.
3066
+ *
3067
+ * @example
3068
+ * ```ts
3069
+ * import { openRepository } from 'es-git';
3070
+ *
3071
+ * const repo = await openRepository('/path/to/repo');
3072
+ * const remote = repo.getRemote('origin');
3073
+ *
3074
+ * // Retrieving the Refspecs configured for this remote
3075
+ * const refspecs = remote.refspecs();
3076
+ * console.log(refspecs[0]);
3077
+ * // For the "+refs/heads/*:refs/remotes/origin/*" Refspec
3078
+ * // {
3079
+ * // "direction": "Fetch",
3080
+ * // "src": "refs/heads/*",
3081
+ * // "dst": "refs/remotes/origin/*",
3082
+ * // "force": true
3083
+ * // }
3084
+ * ```
1223
3085
  */
1224
- refspecs(): Array<RefspecObject>
3086
+ refspecs(): Array<Refspec>
1225
3087
  /**
1226
- * Download new data and update tips
3088
+ * Download new data and update tips.
1227
3089
  *
1228
3090
  * Convenience function to connect to a remote, download the data, disconnect and update the remote-tracking branches.
3091
+ *
3092
+ * @category Remote/Methods
3093
+ * @signature
3094
+ * ```ts
3095
+ * class Remote {
3096
+ * fetch(
3097
+ * refspecs: string[],
3098
+ * options?: FetchRemoteOptions,
3099
+ * signal?: AbortSignal,
3100
+ * ): Promise<void>;
3101
+ * }
3102
+ * ```
3103
+ *
3104
+ * @param {string[]} refspecs - Refspecs to fetch from remote.
3105
+ * @param {FetchRemoteOptions} [options] - Options for fetch remote.
3106
+ * @param {AbortSignal} [signal] Abort signal.
3107
+ *
3108
+ * @example
3109
+ * ```ts
3110
+ * import { openRepository } from 'es-git';
3111
+ *
3112
+ * const repo = await openRepository('/path/to/repo');
3113
+ * const remote = repo.getRemote('origin');
3114
+ *
3115
+ * // Fetching data from the "main" branch
3116
+ * await remote.fetch(['main']);
3117
+ *
3118
+ * // Providing an empty array fetches data using the default Refspec configured for the remote
3119
+ * await remote.fetch([]);
3120
+ * ```
1229
3121
  */
1230
3122
  fetch(refspecs: Array<string>, options?: FetchRemoteOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<void>
1231
3123
  /**
1232
- * Perform a push
3124
+ * Perform a push.
1233
3125
  *
1234
3126
  * Perform all the steps for a push.
1235
3127
  * If no refspecs are passed, then the configured refspecs will be used.
3128
+ *
3129
+ * @category Remote/Methods
3130
+ * @signature
3131
+ * ```ts
3132
+ * class Remote {
3133
+ * push(
3134
+ * refspecs: string[],
3135
+ * options?: PushOptions,
3136
+ * signal?: AbortSignal,
3137
+ * ): Promise<void>;
3138
+ * }
3139
+ * ```
3140
+ *
3141
+ * @param {string[]} refspecs - Refspecs to push to remote.
3142
+ * @param {FetchRemoteOptions} [options] - Options for push remote.
3143
+ * @param {AbortSignal} [signal] Abort signal.
3144
+ *
3145
+ * @example
3146
+ * ```ts
3147
+ * import { openRepository } from 'es-git';
3148
+ *
3149
+ * const repo = await openRepository('/path/to/repo');
3150
+ * const remote = repo.getRemote('origin');
3151
+ *
3152
+ * // Push the local "main" branch to the remote "other" branch
3153
+ * await remote.push(['refs/heads/main:refs/heads/other']);
3154
+ *
3155
+ * // Push with credential.
3156
+ * await remote.push(['refs/heads/main:refs/heads/other'], {
3157
+ * credential: {
3158
+ * type: 'Plain',
3159
+ * password: '<personal access token>',
3160
+ * },
3161
+ * });
3162
+ * ```
1236
3163
  */
1237
3164
  push(refspecs: Array<string>, options?: PushOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<void>
1238
- /** Prune tracking refs that are no longer present on remote */
3165
+ /**
3166
+ * Prune tracking refs that are no longer present on remote.
3167
+ *
3168
+ * @category Remote/Methods
3169
+ * @signature
3170
+ * ```ts
3171
+ * class Remote {
3172
+ * prune(options?: PruneOptions, signal?: AbortSignal): Promise<void>;
3173
+ * }
3174
+ * ```
3175
+ *
3176
+ * @param {PruneOptions} [options] - Options for prune remote.
3177
+ * @param {AbortSignal} [signal] Abort signal.
3178
+ */
1239
3179
  prune(options?: PruneOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<void>
1240
- /** Get the remote’s default branch. */
3180
+ /**
3181
+ * Get the remote’s default branch.
3182
+ *
3183
+ * The `fetch` operation from the remote is also performed.
3184
+ *
3185
+ * @category Remote/Methods
3186
+ * @signature
3187
+ * ```ts
3188
+ * class Remote {
3189
+ * defaultBranch(signal?: AbortSignal): Promise<string>;
3190
+ * }
3191
+ * ```
3192
+ *
3193
+ * @param {AbortSignal} [signal] Abort signal.
3194
+ * @returns Default branch name.
3195
+ *
3196
+ * @example
3197
+ * ```ts
3198
+ * import { openRepository } from 'es-git';
3199
+ *
3200
+ * const repo = await openRepository('/path/to/repo');
3201
+ * const remote = repo.getRemote('origin');
3202
+ *
3203
+ * const branch = await remote.defaultBranch();
3204
+ * console.log(branch); // "refs/heads/main"
3205
+ * ```
3206
+ */
1241
3207
  defaultBranch(signal?: AbortSignal | undefined | null): Promise<string>
1242
3208
  }
1243
3209
  /**
1244
3210
  * An owned git repository, representing all state associated with the
1245
3211
  * underlying filesystem.
1246
3212
  *
1247
- * This structure corresponds to a `git_repository` in libgit2.
1248
- *
1249
- * When a repository goes out of scope, it is freed in memory but not deleted
1250
- * from the filesystem.
1251
- *
1252
- * @hideconstructor
3213
+ * This class corresponds to a git repository in libgit2.
1253
3214
  */
1254
3215
  export declare class Repository {
1255
3216
  /**
1256
3217
  * Lookup a reference to one of the commits in a repository.
1257
3218
  *
1258
3219
  * Returns `null` if the commit does not exist.
3220
+ *
3221
+ * @category Repository/Methods
3222
+ *
3223
+ * @signature
3224
+ * ```ts
3225
+ * class Repository {
3226
+ * findCommit(oid: string): Commit | null;
3227
+ * }
3228
+ * ```
3229
+ * @param {string} oid - Commit ID(SHA1) to lookup.
3230
+ * @returns Commit instance found by oid. Returns `null` if the commit does not exist.
1259
3231
  */
1260
3232
  findCommit(oid: string): Commit | null
1261
- /** Lookup a reference to one of the commits in a repository. */
3233
+ /**
3234
+ * Lookup a reference to one of the commits in a repository.
3235
+ *
3236
+ * @category Repository/Methods
3237
+ *
3238
+ * @signature
3239
+ * ```ts
3240
+ * class Repository {
3241
+ * getCommit(oid: string): Commit;
3242
+ * }
3243
+ * ```
3244
+ *
3245
+ * @param {string} oid - Commit ID(SHA1) to lookup.
3246
+ * @returns Commit instance found by oid.
3247
+ * @throws Throws error if the commit does not exist.
3248
+ */
1262
3249
  getCommit(oid: string): Commit
1263
3250
  /**
1264
- * Create new commit in the repository
3251
+ * Create new commit in the repository.
1265
3252
  *
1266
- * If the `update_ref` is not `null`, name of the reference that will be
3253
+ * If the `updateRef` is not `null`, name of the reference that will be
1267
3254
  * updated to point to this commit. If the reference is not direct, it will
1268
3255
  * be resolved to a direct reference. Use "HEAD" to update the HEAD of the
1269
3256
  * current branch and make it point to this commit. If the reference
1270
3257
  * doesn't exist yet, it will be created. If it does exist, the first
1271
3258
  * parent must be the tip of this branch.
3259
+ *
3260
+ * @category Repository/Methods
3261
+ *
3262
+ * @signature
3263
+ * ```ts
3264
+ * class Repository {
3265
+ * commit(tree: Tree, message: string, options?: CommitOptions | null): string;
3266
+ * }
3267
+ * ```
3268
+ *
3269
+ * @returns ID(SHA1) of created commit.
1272
3270
  */
1273
3271
  commit(tree: Tree, message: string, options?: CommitOptions | undefined | null): string
3272
+ /**
3273
+ * Get the configuration file for this repository.
3274
+ *
3275
+ * @category Repository/Methods
3276
+ * @signature
3277
+ * ```ts
3278
+ * class Repository {
3279
+ * config(): Config;
3280
+ * }
3281
+ * ```
3282
+ *
3283
+ * @returns If a configuration file has not been set, the default config set for the
3284
+ * repository will be returned, including global and system configurations
3285
+ * (if they are available).
3286
+ */
3287
+ config(): Config
1274
3288
  /**
1275
3289
  * Create a diff with the difference between two tree objects.
1276
3290
  *
1277
- * This is equivalent to `git diff <old-tree> <new-tree>`
3291
+ * This is equivalent to `git diff <old-tree> <new-tree>`.
3292
+ *
3293
+ * @category Repository/Methods
3294
+ * @signature
3295
+ * ```ts
3296
+ * class Repository {
3297
+ * diffTreeToTree(
3298
+ * oldTree?: Tree,
3299
+ * newTree?: Tree,
3300
+ * options?: DiffOptions,
3301
+ * ): Diff;
3302
+ * }
3303
+ * ```
3304
+ *
3305
+ * @param {Tree} [oldTree] - Tree used for the "oldFile" side of the delta. If you not pass,
3306
+ * then an empty tree is used.
3307
+ * @param {Tree} [newTree] - Tree used for the "newFile" side of the delta. If you not pass,
3308
+ * then an empty tree is used.
3309
+ * @param {DiffOptions} [options] - Describing options about how the diff should be executed.
1278
3310
  *
1279
- * The first tree will be used for the "old_file" side of the delta and the
1280
- * second tree will be used for the "new_file" side of the delta. You can
1281
- * pass `null` to indicate an empty tree, although it is an error to pass
1282
- * `null` for both the `oldTree` and `newTree`.
3311
+ * @returns {Diff} Diff between two tree objects.
3312
+ * @throws Throws error if the `oldTree` and `newTree` is `null`.
1283
3313
  */
1284
3314
  diffTreeToTree(oldTree?: Tree | undefined | null, newTree?: Tree | undefined | null, options?: DiffOptions | undefined | null): Diff
1285
3315
  /**
1286
3316
  * Create a diff between two index objects.
1287
3317
  *
1288
- * The first index will be used for the "old_file" side of the delta, and
1289
- * the second index will be used for the "new_file" side of the delta.
3318
+ * @category Repository/Methods
3319
+ * @signature
3320
+ * ```ts
3321
+ * class Repository {
3322
+ * diffIndexToIndex(
3323
+ * oldIndex: Index,
3324
+ * newIndex: Index,
3325
+ * options?: DiffOptions,
3326
+ * ): Diff;
3327
+ * }
3328
+ * ```
3329
+ *
3330
+ * @param {Index} [oldIndex] - Index used for the "oldFile" side of the delta.
3331
+ * @param {Index} [newIndex] - Index used for the "newFile" side of the delta.
3332
+ * @param {DiffOptions} [options] - Describing options about how the diff should be executed.
3333
+ *
3334
+ * @returns {Diff} Diff between two index objects.
1290
3335
  */
1291
3336
  diffIndexToIndex(oldIndex: Index, newIndex: Index, options?: DiffOptions | undefined | null): Diff
1292
3337
  /**
1293
3338
  * Create a diff between the repository index and the workdir directory.
1294
3339
  *
1295
3340
  * This matches the `git diff` command. See the note below on
1296
- * `tree_to_workdir` for a discussion of the difference between
3341
+ * `diffTreeToWorkdir` for a discussion of the difference between
1297
3342
  * `git diff` and `git diff HEAD` and how to emulate a `git diff <treeish>`
1298
3343
  * using libgit2.
1299
3344
  *
1300
- * The index will be used for the "old_file" side of the delta, and the
1301
- * working directory will be used for the "new_file" side of the delta.
3345
+ * @category Repository/Methods
3346
+ * @signature
3347
+ * ```ts
3348
+ * class Repository {
3349
+ * diffIndexToWorkdir(index?: Index, options?: DiffOptions): Diff;
3350
+ * }
3351
+ * ```
3352
+ *
3353
+ * @param {Index} [index] - Index used for the "oldFile" side of the delta. The working directory
3354
+ * will be used for the "newFile" side of the delta.
1302
3355
  *
1303
- * If you pass `null` for the index, then the existing index of the `repo`
1304
- * will be used. In this case, the index will be refreshed from disk
1305
- * (if it has changed) before the diff is generated.
3356
+ * If not you pass, then the existing index of the repository will be used. In this case,
3357
+ * the index will be refreshed from disk (if it has changed) before the diff is generated.
3358
+ *
3359
+ * @param {DiffOptions} [options] - Describing options about how the diff should be executed.
3360
+ *
3361
+ * @returns {Diff} Diff between the repository index and the workdir directory.
1306
3362
  */
1307
3363
  diffIndexToWorkdir(index?: Index | undefined | null, options?: DiffOptions | undefined | null): Diff
1308
3364
  /**
1309
3365
  * Create a diff between a tree and the working directory.
1310
3366
  *
1311
- * The tree you provide will be used for the "old_file" side of the delta,
1312
- * and the working directory will be used for the "new_file" side.
3367
+ * The tree you provide will be used for the "oldFile" side of the delta,
3368
+ * and the working directory will be used for the "newFile" side.
1313
3369
  *
1314
3370
  * This is not the same as `git diff <treeish>` or `git diff-index <treeish>`.
1315
3371
  * Those commands use information from the index, whereas this
1316
3372
  * function strictly returns the differences between the tree and the files
1317
- * in the working directory, regardless of the state of the index. Use
1318
- * `tree_to_workdir_with_index` to emulate those commands.
3373
+ * in the working directory, regardless of the state of the index. Use
3374
+ * `diffTreeToWorkdirWithIndex` to emulate those commands.
1319
3375
  *
1320
- * To see difference between this and `tree_to_workdir_with_index`,
3376
+ * To see difference between this and `diffTreeToWorkdirWithIndex`,
1321
3377
  * consider the example of a staged file deletion where the file has then
1322
- * been put back into the working dir and further modified. The
3378
+ * been put back into the working dir and further modified. The
1323
3379
  * tree-to-workdir diff for that file is 'modified', but `git diff` would
1324
3380
  * show status 'deleted' since there is a staged delete.
1325
3381
  *
1326
- * If `null` is passed for `tree`, then an empty tree is used.
3382
+ * @category Repository/Methods
3383
+ * @signature
3384
+ * ```ts
3385
+ * class Repository {
3386
+ * diffTreeToWorkdir(oldTree?: Tree, options?: DiffOptions): Diff;
3387
+ * }
3388
+ * ```
3389
+ *
3390
+ * @param {Tree} [oldTree] - Tree used for the "oldFile" side of the delta. If you not pass,
3391
+ * then an empty tree is used.
3392
+ *
3393
+ * @param {DiffOptions} [options] - Describing options about how the diff should be executed.
3394
+ *
3395
+ * @returns {Diff} Diff between a tree and the working directory.
1327
3396
  */
1328
3397
  diffTreeToWorkdir(oldTree?: Tree | undefined | null, options?: DiffOptions | undefined | null): Diff
1329
3398
  /**
@@ -1333,131 +3402,527 @@ export declare class Repository {
1333
3402
  * This emulates `git diff <tree>` by diffing the tree to the index and
1334
3403
  * the index to the working directory and blending the results into a
1335
3404
  * single diff that includes staged deleted, etc.
3405
+ *
3406
+ * @category Repository/Methods
3407
+ * @signature
3408
+ * ```ts
3409
+ * class Repository {
3410
+ * diffTreeToWorkdirWithIndex(oldTree?: Tree, options?: DiffOptions): Diff;
3411
+ * }
3412
+ * ```
3413
+ *
3414
+ * @param {Tree} [oldTree] - Tree used for the "oldFile" side of the delta. If you not pass,
3415
+ * then an empty tree is used.
3416
+ *
3417
+ * @param {DiffOptions} [options] - Describing options about how the diff should be executed.
3418
+ *
3419
+ * @returns {Diff} Diff between a tree and the working directory using index data to account for
3420
+ * staged deletes, tracked files, etc.
1336
3421
  */
1337
3422
  diffTreeToWorkdirWithIndex(oldTree?: Tree | undefined | null, options?: DiffOptions | undefined | null): Diff
1338
3423
  /**
1339
3424
  * Get the Index file for this repository.
1340
3425
  *
1341
3426
  * If a custom index has not been set, the default index for the repository
1342
- * will be returned (the one located in .git/index).
3427
+ * will be returned (the one located in `.git/index`).
3428
+ *
3429
+ * @category Repository/Methods
3430
+ * @signature
3431
+ * ```ts
3432
+ * class Repository {
3433
+ * index(): Index;
3434
+ * }
3435
+ * ```
1343
3436
  *
1344
- * **Caution**: If the [`git2::Repository`] of this index is dropped, then this
1345
- * [`git2::Index`] will become detached, and most methods on it will fail. See
1346
- * [`git2::Index::open`]. Be sure the repository has a binding such as a local
1347
- * variable to keep it alive at least as long as the index.
3437
+ * @returns The index file for this repository.
1348
3438
  */
1349
3439
  index(): Index
1350
3440
  /**
1351
3441
  * Lookup a reference to one of the objects in a repository.
1352
3442
  *
1353
- * Returns `null` if the object does not exist.
3443
+ * @category Repository/Methods
3444
+ * @signature
3445
+ * ```ts
3446
+ * class Repository {
3447
+ * findObject(oid: string): GitObject | null;
3448
+ * }
3449
+ * ```
3450
+ *
3451
+ * @param {string} oid - Git object ID(SHA1) to lookup.
3452
+ * @returns Git object. Returns `null` if the object does not exist.
1354
3453
  */
1355
3454
  findObject(oid: string): GitObject | null
1356
- /** Lookup a reference to one of the objects in a repository. */
3455
+ /**
3456
+ * Lookup a reference to one of the objects in a repository.
3457
+ *
3458
+ * @category Repository/Methods
3459
+ * @signature
3460
+ * ```ts
3461
+ * class Repository {
3462
+ * getObject(oid: string): GitObject;
3463
+ * }
3464
+ * ```
3465
+ *
3466
+ * @param {string} oid - Git object ID(SHA1) to lookup.
3467
+ * @returns Git object.
3468
+ * @throws Throws error if the object does not exist.
3469
+ */
1357
3470
  getObject(oid: string): GitObject
1358
- /** Lookup a reference to one of the objects in a repository. */
3471
+ /**
3472
+ * Lookup a reference to one of the objects in a repository.
3473
+ *
3474
+ * @category Repository/Methods
3475
+ * @signature
3476
+ * ```ts
3477
+ * class Repository {
3478
+ * findReference(name: string): Reference | null;
3479
+ * }
3480
+ * ```
3481
+ *
3482
+ * @param {string} name - Reference name to lookup.
3483
+ * @returns Returns `null` if the reference does not exist.
3484
+ *
3485
+ * @example
3486
+ *
3487
+ * Get `HEAD` reference from the repository.
3488
+ *
3489
+ * ```ts
3490
+ * import { openRepository } from 'es-git';
3491
+ *
3492
+ * const repo = await openRepository('.');
3493
+ * const reference = repo.findReference('HEAD');
3494
+ * ```
3495
+ */
1359
3496
  findReference(name: string): Reference | null
1360
- /** Lookup a reference to one of the objects in a repository. */
3497
+ /**
3498
+ * Lookup a reference to one of the objects in a repository.
3499
+ *
3500
+ * @category Repository/Methods
3501
+ * @signature
3502
+ * ```ts
3503
+ * class Repository {
3504
+ * getReference(name: string): Reference;
3505
+ * }
3506
+ * ```
3507
+ *
3508
+ * @param {string} name - Reference name to lookup.
3509
+ * @returns Git reference.
3510
+ * @throws Throws error if the reference does not exist.
3511
+ *
3512
+ * @example
3513
+ *
3514
+ * Get `HEAD` reference from the repository.
3515
+ *
3516
+ * ```ts
3517
+ * import { openRepository } from 'es-git';
3518
+ *
3519
+ * const repo = await openRepository('.');
3520
+ * const reference = repo.getReference('HEAD');
3521
+ * ```
3522
+ */
1361
3523
  getReference(name: string): Reference
1362
- /** List all remotes for a given repository */
3524
+ /**
3525
+ * List all remotes for a given repository
3526
+ *
3527
+ * @category Repository/Methods
3528
+ * @signature
3529
+ * ```ts
3530
+ * class Repository {
3531
+ * remoteNames(): string[];
3532
+ * }
3533
+ * ```
3534
+ *
3535
+ * @returns All remote names for this repository.
3536
+ *
3537
+ * @example
3538
+ * ```ts
3539
+ * import { openRepository } from 'es-git';
3540
+ *
3541
+ * const repo = await openRepository('/path/to/repo');
3542
+ * console.log(repo.remoteNames()); // ["origin"]
3543
+ * ```
3544
+ */
1363
3545
  remoteNames(): Array<string>
1364
3546
  /**
1365
- * Get remote from repository
3547
+ * Get remote from repository.
3548
+ *
3549
+ * @category Repository/Methods
3550
+ * @signature
3551
+ * ```ts
3552
+ * class Repository {
3553
+ * getRemote(name: string): Remote;
3554
+ * }
3555
+ * ```
1366
3556
  *
1367
- * Throws error if not exists
3557
+ * @returns Remote instance.
3558
+ * @throws Throws error if remote does not exist.
1368
3559
  */
1369
3560
  getRemote(name: string): Remote
1370
- /** Find remote from repository */
3561
+ /**
3562
+ * Find remote from repository.
3563
+ *
3564
+ * @category Repository/Methods
3565
+ * @signature
3566
+ * ```ts
3567
+ * class Repository {
3568
+ * findRemote(name: string): Remote | null;
3569
+ * }
3570
+ * ```
3571
+ *
3572
+ * @returns Returns `null` if remote does not exist.
3573
+ */
1371
3574
  findRemote(name: string): Remote | null
1372
- /** Add a remote with the default fetch refspec to the repository’s configuration. */
3575
+ /**
3576
+ * Add a remote with the default fetch refspec to the repository’s configuration.
3577
+ *
3578
+ * @category Repository/Methods
3579
+ * @signature
3580
+ * ```ts
3581
+ * class Repository {
3582
+ * createRemote(name: string, url: string, options?: CreateRemoteOptions): Remote;
3583
+ * }
3584
+ * ```
3585
+ *
3586
+ * @param {string} name - The name of the remote.
3587
+ * @param {string} url - Remote url.
3588
+ * @param {CreateRemoteOptions} [options] - Options for creating remote.
3589
+ * @returns Created remote.
3590
+ */
1373
3591
  createRemote(name: string, url: string, options?: CreateRemoteOptions | undefined | null): Remote
1374
- /** Tests whether this repository is a bare repository or not. */
3592
+ /**
3593
+ * Tests whether this repository is a bare repository or not.
3594
+ *
3595
+ * @category Repository/Methods
3596
+ * @signature
3597
+ * ```ts
3598
+ * class Repository {
3599
+ * isBare(): boolean;
3600
+ * }
3601
+ * ```
3602
+ *
3603
+ * @returns Returns `true` if repository is a bare.
3604
+ */
1375
3605
  isBare(): boolean
1376
- /** Tests whether this repository is a shallow clone. */
3606
+ /**
3607
+ * Tests whether this repository is a shallow clone.
3608
+ *
3609
+ * @category Repository/Methods
3610
+ * @signature
3611
+ * ```ts
3612
+ * class Repository {
3613
+ * isShallow(): boolean;
3614
+ * }
3615
+ * ```
3616
+ *
3617
+ * @returns Returns `true` if repository is a shallow clone.
3618
+ */
1377
3619
  isShallow(): boolean
1378
- /** Tests whether this repository is a worktree. */
3620
+ /**
3621
+ * Tests whether this repository is a worktree.
3622
+ *
3623
+ * @category Repository/Methods
3624
+ * @signature
3625
+ * ```ts
3626
+ * class Repository {
3627
+ * isWorktree(): boolean;
3628
+ * }
3629
+ * ```
3630
+ *
3631
+ * @returns Returns `true` if repository is a worktree.
3632
+ */
1379
3633
  isWorktree(): boolean
1380
- /** Tests whether this repository is empty. */
3634
+ /**
3635
+ * Tests whether this repository is empty.
3636
+ *
3637
+ * @category Repository/Methods
3638
+ * @signature
3639
+ * ```ts
3640
+ * class Repository {
3641
+ * isEmpty(): boolean;
3642
+ * }
3643
+ * ```
3644
+ *
3645
+ * @returns Returns `true` if repository is empty.
3646
+ */
1381
3647
  isEmpty(): boolean
1382
3648
  /**
1383
3649
  * Returns the path to the `.git` folder for normal repositories or the
1384
3650
  * repository itself for bare repositories.
3651
+ *
3652
+ * @category Repository/Methods
3653
+ * @signature
3654
+ * ```ts
3655
+ * class Repository {
3656
+ * path(): string;
3657
+ * }
3658
+ * ```
3659
+ *
3660
+ * @returns The path to the `.git` folder for normal repositories or the repository itself
3661
+ * for bare repositories.
1385
3662
  */
1386
3663
  path(): string
1387
- /** Returns the current state of this repository */
3664
+ /**
3665
+ * Returns the current state of this repository.
3666
+ *
3667
+ * @category Repository/Methods
3668
+ * @signature
3669
+ * ```ts
3670
+ * class Repository {
3671
+ * state(): RepositoryState;
3672
+ * }
3673
+ * ```
3674
+ *
3675
+ * @returns The current state of this repository.
3676
+ */
1388
3677
  state(): RepositoryState
1389
3678
  /**
1390
3679
  * Get the path of the working directory for this repository.
1391
3680
  *
3681
+ * @category Repository/Methods
3682
+ * @signature
3683
+ * ```ts
3684
+ * class Repository {
3685
+ * workdir(): string | null;
3686
+ * }
3687
+ * ```
3688
+ *
3689
+ * @returns The path of the working directory for this repository.
1392
3690
  * If this repository is bare, then `null` is returned.
3691
+ * ```
1393
3692
  */
1394
3693
  workdir(): string | null
1395
- /** Retrieve and resolve the reference pointed at by HEAD. */
3694
+ /**
3695
+ * Retrieve and resolve the reference pointed at by `HEAD`.
3696
+ *
3697
+ * @category Repository/Methods
3698
+ * @signature
3699
+ * ```ts
3700
+ * class Repository {
3701
+ * head(): Reference;
3702
+ * }
3703
+ * ```
3704
+ *
3705
+ * @returns Reference pointed at by `HEAD`.
3706
+ */
1396
3707
  head(): Reference
1397
3708
  /**
1398
- * Make the repository HEAD point to the specified reference.
3709
+ * Make the repository `HEAD` point to the specified reference.
1399
3710
  *
1400
- * If the provided reference points to a tree or a blob, the HEAD is
3711
+ * If the provided reference points to a tree or a blob, the `HEAD` is
1401
3712
  * unaltered and an error is returned.
1402
3713
  *
1403
- * If the provided reference points to a branch, the HEAD will point to
1404
- * that branch, staying attached, or become attached if it isn't yet. If
1405
- * the branch doesn't exist yet, no error will be returned. The HEAD will
1406
- * then be attached to an unborn branch.
3714
+ * If the provided reference points to a branch, the `HEAD` will point to
3715
+ * that branch, staying attached, or become attached if it isn't yet. If
3716
+ * the branch doesn't exist yet, no error will be returned. The `HEAD` will
3717
+ * then be attached to an unborn branch.
3718
+ *
3719
+ * Otherwise, the `HEAD` will be detached and will directly point to the
3720
+ * commit.
3721
+ *
3722
+ * @category Repository/Methods
3723
+ * @signature
3724
+ * ```ts
3725
+ * class Repository {
3726
+ * setHead(refname: string): void;
3727
+ * }
3728
+ * ```
3729
+ *
3730
+ * @param {string} refname - Specified reference to point into `HEAD`.
3731
+ */
3732
+ setHead(refname: string): void
3733
+ /**
3734
+ * Execute a rev-parse operation against the `spec` listed.
3735
+ *
3736
+ * The resulting revision specification is returned, or an error is
3737
+ * returned if one occurs.
3738
+ *
3739
+ * @category Repository/Methods
3740
+ * @signature
3741
+ * ```ts
3742
+ * class Repository {
3743
+ * revparse(spec: string): Revspec;
3744
+ * }
3745
+ * ```
3746
+ *
3747
+ * @param {string} spec - Revision string.
3748
+ * @returns
3749
+ */
3750
+ revparse(spec: string): Revspec
3751
+ /**
3752
+ * Find a single object, as specified by a revision string.
3753
+ *
3754
+ * @category Repository/Methods
3755
+ * @signature
3756
+ * ```ts
3757
+ * class Repository {
3758
+ * revparseSingle(spec: string): string;
3759
+ * }
3760
+ * ```
1407
3761
  *
1408
- * Otherwise, the HEAD will be detached and will directly point to the
1409
- * commit.
3762
+ * @param {string} spec - Revision string.
3763
+ * @returns OID of single object.
3764
+ * @throws Throws error if the object does not exist.
1410
3765
  */
1411
- setHead(refname: string): void
3766
+ revparseSingle(spec: string): string
1412
3767
  /**
1413
- * Execute a rev-parse operation against the `spec` listed.
3768
+ * Create a revwalk that can be used to traverse the commit graph.
1414
3769
  *
1415
- * The resulting revision specification is returned, or an error is
1416
- * returned if one occurs.
3770
+ * @category Repository/Methods
3771
+ * @signature
3772
+ * ```ts
3773
+ * class Repository {
3774
+ * revwalk(): Revwalk;
3775
+ * }
3776
+ * ```
3777
+ *
3778
+ * @returns Revwalk to traverse the commit graph in this repository.
1417
3779
  */
1418
- revparse(spec: string): Revspec
1419
- /** Find a single object, as specified by a revision string. */
1420
- revparseSingle(spec: string): string
1421
- /** Create a revwalk that can be used to traverse the commit graph. */
1422
3780
  revwalk(): Revwalk
1423
3781
  /**
1424
3782
  * Lookup a tag object by prefix hash from the repository.
1425
3783
  *
1426
- * Returns `null` if tag does not exist.
3784
+ * @category Repository/Methods
3785
+ * @signature
3786
+ * ```ts
3787
+ * class Repository {
3788
+ * findTag(oid: string): Tag | null;
3789
+ * }
3790
+ * ```
3791
+ *
3792
+ * @param {string} oid - Prefix hash.
3793
+ * @returns Returns `null` if tag does not exist.
1427
3794
  */
1428
3795
  findTag(oid: string): Tag | null
1429
- /** Lookup a tag object by prefix hash from the repository. */
3796
+ /**
3797
+ * Lookup a tag object by prefix hash from the repository.
3798
+ *
3799
+ * @category Repository/Methods
3800
+ * @signature
3801
+ * ```ts
3802
+ * class Repository {
3803
+ * getTag(oid: string): Tag;
3804
+ * }
3805
+ * ```
3806
+ *
3807
+ * @param {string} oid - Prefix hash.
3808
+ * @throws Throws error if tag does not exist.
3809
+ */
1430
3810
  getTag(oid: string): Tag
1431
3811
  /**
1432
3812
  * Get a list with all the tags in the repository.
1433
3813
  *
1434
- * An optional fnmatch pattern can also be specified.
3814
+ * @category Repository/Methods
3815
+ * @signature
3816
+ * ```ts
3817
+ * class Repository {
3818
+ * tagNames(pattern?: string): string[];
3819
+ * }
3820
+ * ```
3821
+ *
3822
+ * @param {string} [pattern] - An optional fnmatch pattern can also be specified.
1435
3823
  */
1436
3824
  tagNames(pattern?: string | undefined | null): Array<string>
1437
3825
  /**
1438
- * iterate over all tags calling `callback` on each.
1439
- * the callback is provided the tag id and name
3826
+ * Iterate over all tags calling `callback` on each.
3827
+ * The callback is provided the tag id and name.
3828
+ *
3829
+ * @category Repository/Methods
3830
+ * @signature
3831
+ * ```ts
3832
+ * class Repository {
3833
+ * tagForeach(callback: (oid: string, name: string) => boolean): void;
3834
+ * }
3835
+ * ```
3836
+ *
3837
+ * @param {(oid: string, name: string) => boolean} callback - If you wish to stop iteration,
3838
+ * return `false` in the callback.
3839
+ *
3840
+ * @example
3841
+ * ```ts
3842
+ * import { openRepository } from 'es-git';
3843
+ *
3844
+ * const repo = await openRepository('.');
3845
+ * const tags = [];
3846
+ * repo.tagForeach((sha, name) => {
3847
+ * tags.push([name, sha]);
3848
+ * return true;
3849
+ * });
3850
+ *
3851
+ * console.log(tags);
3852
+ * // [['aa0040546ed22b8bb33f3bd621e8d10ed849b02c', 'refs/tags/v0'],
3853
+ * // ['674e3327707fcf32a348ecfc0cb6b93e57398b8c', 'refs/tags/v1'],
3854
+ * // ['567aa5c6b219312dc7758ab88ebb7a1e5d36d26b', 'refs/tags/v2']]
3855
+ * ```
1440
3856
  */
1441
3857
  tagForeach(callback: (oid: string, name: string) => boolean): void
1442
3858
  /**
1443
3859
  * Delete an existing tag reference.
1444
3860
  *
1445
- * The tag name will be checked for validity, see `tag` for some rules
1446
- * about valid names.
3861
+ * @category Repository/Methods
3862
+ * @signature
3863
+ * ```ts
3864
+ * class Repository {
3865
+ * deleteTag(name: string): void;
3866
+ * }
3867
+ * ```
3868
+ *
3869
+ * @param {string} name - The tag name will be checked for validity, see `isValidTagName`
3870
+ * for some rules about valid names.
1447
3871
  */
1448
3872
  deleteTag(name: string): void
1449
3873
  /**
1450
- * Create a new tag in the repository from an object
3874
+ * Create a new tag in the repository from an object.
1451
3875
  *
1452
- * A new reference will also be created pointing to this tag object. If
1453
- * `force` is true and a reference already exists with the given name,
1454
- * it'll be replaced.
3876
+ * A new reference will also be created pointing to this tag object.
1455
3877
  *
1456
3878
  * The message will not be cleaned up.
1457
3879
  *
1458
3880
  * The tag name will be checked for validity. You must avoid the characters
1459
3881
  * '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @
1460
3882
  * {" which have special meaning to revparse.
3883
+ *
3884
+ * @category Repository/Methods
3885
+ * @signature
3886
+ * ```ts
3887
+ * class Repository {
3888
+ * createTag(
3889
+ * name: string,
3890
+ * target: GitObject,
3891
+ * message: string,
3892
+ * options?: CreateTagOptions,
3893
+ * ): string;
3894
+ * }
3895
+ * ```
3896
+ *
3897
+ * @param {string} name - The name of tag.
3898
+ * @param {GitObject} target - Git object to pointed by this tag.
3899
+ * @param {string} message - The message of tag.
3900
+ * @param {CreateTagOptions} [options] - Options for creating the tag.
3901
+ *
3902
+ * @returns Tag OID(SHA1) which created.
3903
+ *
3904
+ * @example
3905
+ * ```ts
3906
+ * import { openRepository } from 'es-git';
3907
+ *
3908
+ * const repo = await openRepository('.');
3909
+ * const commit = repo.getCommit('828954df9f08dc8e172447cdacf0ddea1adf9e63');
3910
+ *
3911
+ * const sha = repo.createTag(
3912
+ * 'mytag',
3913
+ * commit.asObject(),
3914
+ * 'this is my tag message',
3915
+ * {
3916
+ * tagger: {
3917
+ * name: 'Seokju Na',
3918
+ * email: 'seokju.me@toss.im',
3919
+ * },
3920
+ * },
3921
+ * );
3922
+ * const tag = repo.getTag(sha);
3923
+ * console.log(tag.name()); // "mytag"
3924
+ * console.log(tag.target().id()); // "828954df9f08dc8e172447cdacf0ddea1adf9e63"
3925
+ * ```
1461
3926
  */
1462
3927
  createTag(name: string, target: GitObject, message: string, options?: CreateTagOptions | undefined | null): string
1463
3928
  /**
@@ -1468,30 +3933,87 @@ export declare class Repository {
1468
3933
  * The tag name will be checked for validity. You must avoid the characters
1469
3934
  * '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @
1470
3935
  * {" which have special meaning to revparse.
3936
+ *
3937
+ * @category Repository/Methods
3938
+ * @signature
3939
+ * ```ts
3940
+ * class Repository {
3941
+ * createAnnotationTag(
3942
+ * name: string,
3943
+ * target: GitObject,
3944
+ * message: string,
3945
+ * options?: CreateAnnotationTagOptions,
3946
+ * ): string;
3947
+ * }
3948
+ * ```
3949
+ *
3950
+ * @param {string} name - The name of tag.
3951
+ * @param {GitObject} target - Git object to pointed by this tag.
3952
+ * @param {string} message - The message of tag.
3953
+ * @param {CreateAnnotationTagOptions} [options] - Options for creating the tag.
3954
+ *
3955
+ * @returns Tag OID(SHA1) which created.
1471
3956
  */
1472
3957
  createAnnotationTag(name: string, target: GitObject, message: string, options?: CreateAnnotationTagOptions | undefined | null): string
1473
3958
  /**
1474
- * Create a new lightweight tag pointing at a target object
3959
+ * Create a new lightweight tag pointing at a target object.
1475
3960
  *
1476
3961
  * A new direct reference will be created pointing to this target object.
1477
- * If force is true and a reference already exists with the given name,
1478
- * it'll be replaced.
3962
+ *
3963
+ * @category Repository/Methods
3964
+ * @signature
3965
+ * ```ts
3966
+ * class Repository {
3967
+ * createLightweightTag(
3968
+ * name: string,
3969
+ * target: GitObject,
3970
+ * options?: CreateLightweightTagOptions,
3971
+ * ): string;
3972
+ * }
3973
+ * ```
3974
+ *
3975
+ * @param {string} name - The name of tag.
3976
+ * @param {GitObject} target - Git object to pointed by this tag.
3977
+ * @param {CreateLightweightTagOptions} [options] - Options for creating the tag.
3978
+ *
3979
+ * @returns Tag OID(SHA1) which created.
1479
3980
  */
1480
3981
  createLightweightTag(name: string, target: GitObject, options?: CreateLightweightTagOptions | undefined | null): string
1481
- /** Lookup a reference to one of the objects in a repository. */
3982
+ /**
3983
+ * Lookup a reference to one of the objects in a repository.
3984
+ *
3985
+ * @category Repository/Methods
3986
+ * @signature
3987
+ * ```ts
3988
+ * class Repository {
3989
+ * getTree(oid: string): Tree;
3990
+ * }
3991
+ * ```
3992
+ *
3993
+ * @param {string} oid - ID(SHA1) to lookup.
3994
+ * @returns Git tree.
3995
+ * @throws Throws error if tree does not exist.
3996
+ */
1482
3997
  getTree(oid: string): Tree
1483
3998
  /**
1484
3999
  * Lookup a reference to one of the objects in a repository.
1485
4000
  *
1486
- * If it does not exists, returns `null`.
4001
+ * @category Repository/Methods
4002
+ * @signature
4003
+ * ```ts
4004
+ * class Repository {
4005
+ * findTree(oid: string): Tree | null;
4006
+ * }
4007
+ * ```
4008
+ *
4009
+ * @param {string} oid - ID(SHA1) to lookup.
4010
+ * @returns If it does not exist, returns `null`.
1487
4011
  */
1488
4012
  findTree(oid: string): Tree | null
1489
4013
  }
1490
4014
  /**
1491
4015
  * A revwalk allows traversal of the commit graph defined by including one or
1492
4016
  * more leaves and excluding one or more roots.
1493
- *
1494
- * @hideconstructor
1495
4017
  */
1496
4018
  export declare class Revwalk {
1497
4019
  [Symbol.iterator](): Iterator<string, void, void>
@@ -1500,14 +4022,62 @@ export declare class Revwalk {
1500
4022
  *
1501
4023
  * The revwalk is automatically reset when iteration of its commits
1502
4024
  * completes.
4025
+ *
4026
+ * @category Revwalk/Methods
4027
+ * @signature
4028
+ * ```ts
4029
+ * class Revwalk {
4030
+ * reset(): this;
4031
+ * }
4032
+ * ```
1503
4033
  */
1504
4034
  reset(): this
1505
- /** Set the order in which commits are visited. */
4035
+ /**
4036
+ * Set the order in which commits are visited.
4037
+ *
4038
+ * @category Revwalk/Methods
4039
+ *
4040
+ * @signature
4041
+ * ```ts
4042
+ * class Revwalk {
4043
+ * setSorting(sort: number): this;
4044
+ * }
4045
+ * ```
4046
+ *
4047
+ * @param {number} sort - Orderings that may be specified for Revwalk iteration.
4048
+ * - `RevwalkSort.None` : Sort the repository contents in no particular ordering.
4049
+ * This sorting is arbitrary, implementation-specific, and subject to
4050
+ * change at any time. This is the default sorting for new walkers.
4051
+ * - `RevwalkSort.Topological` : Sort the repository contents in topological order
4052
+ * (children before parents).
4053
+ * This sorting mode can be combined with time sorting.
4054
+ * - `RevwalkSort.Time` : Sort the repository contents by commit time.
4055
+ * This sorting mode can be combined with topological sorting.
4056
+ * - `RevwalkSort.Reverse` : Iterate through the repository contents in reverse order.
4057
+ * This sorting mode can be combined with any others.
4058
+ *
4059
+ * @example
4060
+ * ```ts
4061
+ * import { openRepository, RevwalkSort } from 'es-git';
4062
+ *
4063
+ * const repo = await openRepository('.');
4064
+ * const revwalk = repo.revwalk();
4065
+ * revwalk.setSorting(RevwalkSort.Time | RevwalkSort.Reverse);
4066
+ * ```
4067
+ */
1506
4068
  setSorting(sort: number): this
1507
4069
  /**
1508
- * Simplify the history by first-parent
4070
+ * Simplify the history by first-parent.
1509
4071
  *
1510
4072
  * No parents other than the first for each commit will be enqueued.
4073
+ *
4074
+ * @category Revwalk/Methods
4075
+ * @signature
4076
+ * ```ts
4077
+ * class Revwalk {
4078
+ * simplifyFirstParent(): this;
4079
+ * }
4080
+ * ```
1511
4081
  */
1512
4082
  simplifyFirstParent(): this
1513
4083
  /**
@@ -1518,23 +4088,46 @@ export declare class Revwalk {
1518
4088
  * The given commit will be used as one of the roots when starting the
1519
4089
  * revision walk. At least one commit must be pushed onto the walker before
1520
4090
  * a walk can be started.
4091
+ *
4092
+ * @category Revwalk/Methods
4093
+ * @signature
4094
+ * ```ts
4095
+ * class Revwalk {
4096
+ * push(oid: string): this;
4097
+ * }
4098
+ * ```
4099
+ *
4100
+ * @param {string} oid - OID which belong to a commitish on the walked repository.
1521
4101
  */
1522
4102
  push(oid: string): this
1523
4103
  /**
1524
- * Push the repository's HEAD
4104
+ * Push the repository's HEAD.
1525
4105
  *
1526
- * For more information, see `push`.
4106
+ * @category Revwalk/Methods
4107
+ * @signature
4108
+ * ```ts
4109
+ * class Revwalk {
4110
+ * pushHead(): this;
4111
+ * }
4112
+ * ```
1527
4113
  */
1528
4114
  pushHead(): this
1529
4115
  /**
1530
- * Push matching references
4116
+ * Push matching references.
1531
4117
  *
1532
4118
  * The OIDs pointed to by the references that match the given glob pattern
1533
4119
  * will be pushed to the revision walker.
1534
4120
  *
1535
- * A leading 'refs/' is implied if not present as well as a trailing `/ \
1536
- * *` if the glob lacks '?', ' \ *' or '['.
4121
+ * @category Revwalk/Methods
4122
+ * @signature
4123
+ * ```ts
4124
+ * class Revwalk {
4125
+ * pushGlob(glob: string): this;
4126
+ * }
4127
+ * ```
1537
4128
  *
4129
+ * @param {string} glob - A leading 'refs/' is implied if not present as well as a trailing `/ \
4130
+ * *` if the glob lacks '?', ' \ *' or '['.
1538
4131
  * Any references matching this glob which do not point to a commitish
1539
4132
  * will be ignored.
1540
4133
  */
@@ -1542,23 +4135,57 @@ export declare class Revwalk {
1542
4135
  /**
1543
4136
  * Push and hide the respective endpoints of the given range.
1544
4137
  *
1545
- * The range should be of the form `<commit>..<commit>` where each
1546
- * `<commit>` is in the form accepted by `revparse_single`. The left-hand
4138
+ * @category Revwalk/Methods
4139
+ * @signature
4140
+ * ```ts
4141
+ * class Revwalk {
4142
+ * pushRange(range: string): this;
4143
+ * }
4144
+ * ```
4145
+ *
4146
+ * @param {string} range - The range should be of the form `<commit>..<commit>` where each
4147
+ * `<commit>` is in the form accepted by `revparseSingle`. The left-hand
1547
4148
  * commit will be hidden and the right-hand commit pushed.
1548
4149
  */
1549
4150
  pushRange(range: string): this
1550
4151
  /**
1551
- * Push the OID pointed to by a reference
4152
+ * Push the OID pointed to by a reference.
1552
4153
  *
1553
- * The reference must point to a commitish.
4154
+ * @category Revwalk/Methods
4155
+ * @signature
4156
+ * ```ts
4157
+ * class Revwalk {
4158
+ * pushRef(reference: string): this;
4159
+ * }
4160
+ * ```
4161
+ *
4162
+ * @param {string} reference - The reference must point to a commitish.
1554
4163
  */
1555
4164
  pushRef(reference: string): this
1556
- /** Mark a commit as not of interest to this revwalk. */
4165
+ /**
4166
+ * Mark a commit as not of interest to this revwalk.
4167
+ *
4168
+ * @category Revwalk/Methods
4169
+ * @signature
4170
+ * ```ts
4171
+ * class Revwalk {
4172
+ * hide(oid: string): this;
4173
+ * }
4174
+ * ```
4175
+ *
4176
+ * @param {string} oid - Marked commit OID as not of interest of this revwalk.
4177
+ */
1557
4178
  hide(oid: string): this
1558
4179
  /**
1559
- * Hide the repository's HEAD
4180
+ * Hide the repository's HEAD.
1560
4181
  *
1561
- * For more information, see `hide`.
4182
+ * @category Revwalk/Methods
4183
+ * @signature
4184
+ * ```ts
4185
+ * class Revwalk {
4186
+ * hideHead(): this;
4187
+ * }
4188
+ * ```
1562
4189
  */
1563
4190
  hideHead(): this
1564
4191
  /**
@@ -1567,9 +4194,16 @@ export declare class Revwalk {
1567
4194
  * The OIDs pointed to by the references that match the given glob pattern
1568
4195
  * and their ancestors will be hidden from the output on the revision walk.
1569
4196
  *
1570
- * A leading 'refs/' is implied if not present as well as a trailing `/ \
1571
- * *` if the glob lacks '?', ' \ *' or '['.
4197
+ * @category Revwalk/Methods
4198
+ * @signature
4199
+ * ```ts
4200
+ * class Revwalk {
4201
+ * hideGlob(glob: string): this;
4202
+ * }
4203
+ * ```
1572
4204
  *
4205
+ * @param {string} glob - A leading 'refs/' is implied if not present as well as a trailing `/ \
4206
+ * *` if the glob lacks '?', ' \ *' or '['.
1573
4207
  * Any references matching this glob which do not point to a commitish
1574
4208
  * will be ignored.
1575
4209
  */
@@ -1577,120 +4211,381 @@ export declare class Revwalk {
1577
4211
  /**
1578
4212
  * Hide the OID pointed to by a reference.
1579
4213
  *
1580
- * The reference must point to a commitish.
4214
+ * @category Revwalk/Methods
4215
+ * @signature
4216
+ * ```ts
4217
+ * class Revwalk {
4218
+ * hideRef(reference: string): this;
4219
+ * }
4220
+ * ```
4221
+ *
4222
+ * @param {string} reference - The reference must point to a commitish.
1581
4223
  */
1582
4224
  hideRef(reference: string): this
1583
4225
  }
1584
4226
  /**
1585
- * A structure to represent a git [tag][1]
1586
- * @hideconstructor
4227
+ * A class to represent a git [tag][1].
1587
4228
  *
1588
- * [1]: http://git-scm.com/book/en/Git-Basics-Tagging
4229
+ * [1]: https://git-scm.com/book/en/Git-Basics-Tagging
1589
4230
  */
1590
4231
  export declare class Tag {
1591
- /** Get the id (SHA1) of a repository tag */
4232
+ /**
4233
+ * Get the id (SHA1) of a repository tag.
4234
+ *
4235
+ * @category Tag/Methods
4236
+ * @signature
4237
+ * ```ts
4238
+ * class Tag {
4239
+ * id(): string;
4240
+ * }
4241
+ * ```
4242
+ *
4243
+ * @returns ID(SHA1) of this tag.
4244
+ */
1592
4245
  id(): string
1593
4246
  /**
1594
- * Get the message of a tag
4247
+ * Get the message of a tag.
1595
4248
  *
1596
- * Returns `null`` if there is no message or if it is not valid utf8
4249
+ * @category Tag/Methods
4250
+ * @signature
4251
+ * ```ts
4252
+ * class Tag {
4253
+ * message(): string | null;
4254
+ * }
4255
+ * ```
4256
+ *
4257
+ * @returns Returns `null` if there is no message or if it is not valid utf8.
1597
4258
  */
1598
4259
  message(): string | null
1599
4260
  /**
1600
- * Get the name of a tag
4261
+ * Get the name of a tag.
4262
+ *
4263
+ * @category Tag/Methods
4264
+ * @signature
4265
+ * ```ts
4266
+ * class Tag {
4267
+ * name(): string;
4268
+ * }
4269
+ * ```
1601
4270
  *
1602
- * Throws error if it is not valid utf8
4271
+ * @returns Name of tag.
4272
+ * @throws Throws error if it is not valid utf8.
1603
4273
  */
1604
4274
  name(): string
1605
- /** Recursively peel a tag until a non tag git_object is found */
4275
+ /**
4276
+ * Recursively peel a tag until a non tag Git object is found.
4277
+ *
4278
+ * @category Tag/Methods
4279
+ * @signature
4280
+ * ```ts
4281
+ * class Tag {
4282
+ * peel(): GitObject;
4283
+ * }
4284
+ * ```
4285
+ *
4286
+ * @returns Git object for this tag.
4287
+ */
1606
4288
  peel(): GitObject
1607
4289
  /**
1608
- * Get the tagger (author) of a tag
4290
+ * Get the tagger (author) of a tag.
1609
4291
  *
1610
- * If the author is unspecified, then `null` is returned.
4292
+ * @category Tag/Methods
4293
+ * @signature
4294
+ * ```ts
4295
+ * class Tag {
4296
+ * tagger(): Signature | null;
4297
+ * }
4298
+ * ```
4299
+ *
4300
+ * @returns If the author is unspecified, then `null` is returned.
1611
4301
  */
1612
4302
  tagger(): Signature | null
1613
4303
  /**
1614
- * Get the tagged object of a tag
4304
+ * Get the tagged object of a tag.
1615
4305
  *
1616
4306
  * This method performs a repository lookup for the given object and
1617
- * returns it
4307
+ * returns it.
4308
+ *
4309
+ * @category Tag/Methods
4310
+ * @signature
4311
+ * ```ts
4312
+ * class Tag {
4313
+ * target(): GitObject;
4314
+ * }
4315
+ * ```
4316
+ *
4317
+ * @returns Tagged git object of a tag.
1618
4318
  */
1619
4319
  target(): GitObject
1620
- /** Get the OID of the tagged object of a tag */
4320
+ /**
4321
+ * Get the OID of the tagged object of a tag.
4322
+ *
4323
+ * @category Tag/Methods
4324
+ * @signature
4325
+ * ```ts
4326
+ * class Tag {
4327
+ * targetId(): string;
4328
+ * }
4329
+ * ```
4330
+ *
4331
+ * @returns OID of the tagged object of a tag.
4332
+ */
1621
4333
  targetId(): string
1622
- /** Get the ObjectType of the tagged object of a tag */
4334
+ /**
4335
+ * Get the ObjectType of the tagged object of a tag.
4336
+ *
4337
+ * @category Tag/Methods
4338
+ * @signature
4339
+ * ```ts
4340
+ * class Tag {
4341
+ * targetType(): ObjectType | null;
4342
+ * }
4343
+ * ```
4344
+ *
4345
+ * @returns ObjectType of the tagged object of a tag.
4346
+ */
1623
4347
  targetType(): ObjectType | null
1624
4348
  }
1625
4349
  /**
1626
- * A structure to represent a git [tree][1]
1627
- * @hideconstructor
4350
+ * A class to represent a git [tree][1].
1628
4351
  *
1629
- * [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects
4352
+ * [1]: https://git-scm.com/book/en/Git-Internals-Git-Objects
1630
4353
  */
1631
4354
  export declare class Tree {
1632
- /** Get the id (SHA1) of a repository object */
4355
+ /**
4356
+ * Get the id (SHA1) of a repository object.
4357
+ *
4358
+ * @category Tree/Methods
4359
+ * @signature
4360
+ * ```ts
4361
+ * class Tree {
4362
+ * id(): string;
4363
+ * }
4364
+ * ```
4365
+ *
4366
+ * @returns ID(SHA1) of a repository object.
4367
+ */
1633
4368
  id(): string
1634
- /** Get the number of entries listed in this tree. */
4369
+ /**
4370
+ * Get the number of entries listed in this tree.
4371
+ *
4372
+ * @category Tree/Methods
4373
+ * @signature
4374
+ * ```ts
4375
+ * class Tree {
4376
+ * len(): bigint;
4377
+ * }
4378
+ * ```
4379
+ *
4380
+ * @returns The number of entries listed in this tree.
4381
+ */
1635
4382
  len(): bigint
1636
- /** Return `true` if there is not entry */
4383
+ /**
4384
+ * @category Tree/Methods
4385
+ * @signature
4386
+ * ```ts
4387
+ * class Tree {
4388
+ * isEmpty(): boolean;
4389
+ * }
4390
+ * ```
4391
+ *
4392
+ * @returns Return `true` if there is no entry.
4393
+ */
1637
4394
  isEmpty(): boolean
1638
- /** Returns an iterator over the entries in this tree. */
4395
+ /**
4396
+ * Returns an iterator over the entries in this tree.
4397
+ *
4398
+ * @category Tree/Methods
4399
+ * @signature
4400
+ * ```ts
4401
+ * class Tree {
4402
+ * iter(): TreeIter;
4403
+ * }
4404
+ * ```
4405
+ *
4406
+ * @returns An iterator over the entries in this tree.
4407
+ */
1639
4408
  iter(): TreeIter
1640
4409
  /**
1641
4410
  * Traverse the entries in a tree and its subtrees in post or pre-order.
1642
- * The callback function will be run on each node of the tree that's
1643
- * walked. The return code of this function will determine how the walk
1644
- * continues.
1645
4411
  *
1646
- * libgit2 requires that the callback be an integer, where 0 indicates a
1647
- * successful visit, 1 skips the node, and -1 aborts the traversal completely.
1648
- * See [libgit2 documentation][1] for more information.
4412
+ * @category Tree/Methods
4413
+ * @signature
4414
+ * ```ts
4415
+ * class Tree {
4416
+ * walk(mode: TreeWalkMode, callback: (entry: TreeEntry) => number): void;
4417
+ * }
4418
+ * ```
4419
+ *
4420
+ * @param {TreeWalkMode} mode - A indicator of whether a tree walk should be performed
4421
+ * in pre-order or post-order.
1649
4422
  *
1650
- * [1]: https://libgit2.org/libgit2/#HEAD/group/tree/git_tree_walk
4423
+ * @param {(entry: TreeEntry) => number} callback - The callback function will be run on
4424
+ * each node of the tree that's walked. The return code of this function will determine
4425
+ * how the walk continues.
4426
+ * `libgit2` requires that the callback be an integer, where 0 indicates a successful visit,
4427
+ * 1 skips the node, and -1 aborts the traversal completely.
1651
4428
  */
1652
4429
  walk(mode: TreeWalkMode, callback: (entry: TreeEntry) => number): void
1653
- /** Lookup a tree entry by SHA value. */
4430
+ /**
4431
+ * Lookup a tree entry by SHA value.
4432
+ *
4433
+ * @category Tree/Methods
4434
+ * @signature
4435
+ * ```ts
4436
+ * class Tree {
4437
+ * getId(id: string): TreeEntry | null;
4438
+ * }
4439
+ * ```
4440
+ *
4441
+ * @param {string} id - SHA value.
4442
+ *
4443
+ * @returns Tree entry with the given ID(SHA1).
4444
+ */
1654
4445
  getId(id: string): TreeEntry | null
1655
- /** Lookup a tree entry by its position in the tree */
4446
+ /**
4447
+ * Lookup a tree entry by its position in the tree.
4448
+ *
4449
+ * @category Tree/Methods
4450
+ * @signature
4451
+ * ```ts
4452
+ * class Tree {
4453
+ * get(index: number): TreeEntry | null;
4454
+ * }
4455
+ * ```
4456
+ *
4457
+ * @param {number} index - Index of tree entry.
4458
+ *
4459
+ * @returns Tree entry.
4460
+ */
1656
4461
  get(index: number): TreeEntry | null
1657
- /** Lookup a tree entry by its filename */
4462
+ /**
4463
+ * Lookup a tree entry by its filename.
4464
+ *
4465
+ * @category Tree/Methods
4466
+ * @signature
4467
+ * ```ts
4468
+ * class Tree {
4469
+ * getName(filename: string): TreeEntry | null;
4470
+ * }
4471
+ * ```
4472
+ *
4473
+ * @param {string} filename - Filename of tree entry.
4474
+ *
4475
+ * @returns Tree entry.
4476
+ */
1658
4477
  getName(filename: string): TreeEntry | null
1659
4478
  /**
1660
4479
  * Retrieve a tree entry contained in a tree or in any of its subtrees,
1661
4480
  * given its relative path.
4481
+ *
4482
+ * @category Tree/Methods
4483
+ * @signature
4484
+ * ```ts
4485
+ * class Tree {
4486
+ * getPath(path: string): TreeEntry | null;
4487
+ * }
4488
+ * ```
4489
+ *
4490
+ * @param {string} path - Relative path to tree entry.
4491
+ *
4492
+ * @returns Tree entry.
1662
4493
  */
1663
4494
  getPath(path: string): TreeEntry | null
1664
- /** Casts this Tree to be usable as an `GitObject` */
4495
+ /**
4496
+ * Casts this Tree to be usable as an `GitObject`.
4497
+ *
4498
+ * @category Tree/Methods
4499
+ * @signature
4500
+ * ```ts
4501
+ * class Tree {
4502
+ * asObject(): GitObject;
4503
+ * }
4504
+ * ```
4505
+ *
4506
+ * @returns Git object.
4507
+ */
1665
4508
  asObject(): GitObject
1666
4509
  }
1667
- /**
1668
- * An iterator over the entries in a tree.
1669
- *
1670
- * @hideconstructor
1671
- */
4510
+ /** An iterator over the entries in a tree. */
1672
4511
  export declare class TreeIter {
1673
4512
  [Symbol.iterator](): Iterator<TreeEntry, void, void>
1674
4513
  }
1675
4514
  /**
1676
- * A structure representing an entry inside of a tree. An entry is borrowed
4515
+ * A class representing an entry inside of a tree. An entry is borrowed
1677
4516
  * from a tree.
1678
- *
1679
- * @hideconstructor
1680
4517
  */
1681
4518
  export declare class TreeEntry {
1682
- /** Get the id of the object pointed by the entry */
4519
+ /**
4520
+ * Get the id of the object pointed by the entry.
4521
+ *
4522
+ * @category Tree/TreeEntry
4523
+ * @signature
4524
+ * ```ts
4525
+ * class TreeEntry {
4526
+ * id(): string;
4527
+ * }
4528
+ * ```
4529
+ *
4530
+ * @returns ID of the object pointed by the entry.
4531
+ */
1683
4532
  id(): string
1684
4533
  /**
1685
- * Get the filename of a tree entry
4534
+ * Get the filename of a tree entry.
4535
+ *
4536
+ * @category Tree/TreeEntry
4537
+ * @signature
4538
+ * ```ts
4539
+ * class TreeEntry {
4540
+ * name(): string;
4541
+ * }
4542
+ * ```
1686
4543
  *
1687
- * Throws error if the name is not valid utf-8
4544
+ * @returns The filename of a tree entry.
4545
+ * @throws Throws error if the name is not valid utf-8.
1688
4546
  */
1689
4547
  name(): string
1690
- /** Get the type of the object pointed by the entry */
4548
+ /**
4549
+ * Get the type of the object pointed by the entry.
4550
+ *
4551
+ * @category Tree/TreeEntry
4552
+ * @signature
4553
+ * ```ts
4554
+ * class TreeEntry {
4555
+ * type(): ObjectType | null;
4556
+ * }
4557
+ * ```
4558
+ *
4559
+ * @returns The type of the object pointed by the entry.
4560
+ */
1691
4561
  type(): ObjectType | null
1692
- /** Get the UNIX file attributes of a tree entry */
4562
+ /**
4563
+ * Get the UNIX file attributes of a tree entry.
4564
+ *
4565
+ * @category Tree/TreeEntry
4566
+ * @signature
4567
+ * ```ts
4568
+ * class TreeEntry {
4569
+ * filemode(): number;
4570
+ * }
4571
+ * ```
4572
+ *
4573
+ * @returns UNIX file attributes of a tree entry.
4574
+ */
1693
4575
  filemode(): number
1694
- /** Convert a tree entry to the object it points to. */
4576
+ /**
4577
+ * Convert a tree entry to the object it points to.
4578
+ *
4579
+ * @category Tree/TreeEntry
4580
+ * @signature
4581
+ * ```ts
4582
+ * class TreeEntry {
4583
+ * toObject(repo: Repository): GitObject;
4584
+ * }
4585
+ * ```
4586
+ *
4587
+ * @param {Repository} repo - Repository which this tree entry belongs to.
4588
+ * @returns Git object that pointed by the entry.
4589
+ */
1695
4590
  toObject(repo: Repository): GitObject
1696
4591
  }