es-git 0.0.12 → 1.0.0-security

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 DELETED
@@ -1,1696 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /* auto-generated by NAPI-RS */
5
-
6
- export interface CommitOptions {
7
- updateRef?: string
8
- /**
9
- * Signature for author.
10
- *
11
- * If not provided, default signature of repository will be used.
12
- * If there is no default signature set for the repository, an error will occur.
13
- */
14
- author?: SignaturePayload
15
- /**
16
- * Signature for commiter.
17
- *
18
- * If not provided, default signature of repository will be used.
19
- * If there is no default signature set for the repository, an error will occur.
20
- */
21
- committer?: SignaturePayload
22
- parents?: Array<string>
23
- }
24
- export const enum DiffFlags {
25
- /** File(s) treated as binary data. (1 << 0) */
26
- Binary = 1,
27
- /** File(s) treated as text data. (1 << 1) */
28
- NotBinary = 2,
29
- /** `id` value is known correct. (1 << 2) */
30
- ValidId = 4,
31
- /** File exists at this side of the delta. (1 << 3) */
32
- Exists = 8
33
- }
34
- /** Check diff flags contains given flags. */
35
- 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';
57
- export interface DiffPrintOptions {
58
- format?: DiffFormat
59
- }
60
- /** 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. */
64
- export interface DiffOptions {
65
- /** Flag indicating whether the sides of the diff will be reversed. */
66
- reverse?: boolean
67
- /** Flag indicating whether ignored files are included. */
68
- includeIgnored?: boolean
69
- /** Flag indicating whether ignored directories are traversed deeply or not. */
70
- recurseIgnoredDirs?: boolean
71
- /** Flag indicating whether untracked files are in the diff */
72
- includeUntracked?: boolean
73
- /**
74
- * Flag indicating whether untracked directories are traversed deeply or
75
- * not.
76
- */
77
- recurseUntrackedDirs?: boolean
78
- /** Flag indicating whether unmodified files are in the diff. */
79
- includeUnmodified?: boolean
80
- /** If enabled, then Typechange delta records are generated. */
81
- includeTypechange?: boolean
82
- /**
83
- * Event with `includeTypechange`, the tree returned generally shows a
84
- * deleted blob. This flag correctly labels the tree transitions as a
85
- * typechange record with the `new_file`'s mode set to tree.
86
- *
87
- * Note that the tree SHA will not be available.
88
- */
89
- includeTypechangeTrees?: boolean
90
- /** Flag indicating whether file mode changes are ignored. */
91
- ignoreFilemode?: boolean
92
- /** Flag indicating whether all submodules should be treated as unmodified. */
93
- ignoreSubmodules?: boolean
94
- /** Flag indicating whether case insensitive filenames should be used. */
95
- ignoreCase?: boolean
96
- /**
97
- * If pathspecs are specified, this flag means that they should be applied
98
- * as an exact match instead of a fnmatch pattern.
99
- */
100
- disablePathspecMatch?: boolean
101
- /**
102
- * Disable updating the `binary` flag in delta records. This is useful when
103
- * iterating over a diff if you don't need hunk and data callbacks and want
104
- * to avoid having to load a file completely.
105
- */
106
- skipBinaryCheck?: boolean
107
- /**
108
- * When diff finds an untracked directory, to match the behavior of core
109
- * Git, it scans the contents for ignored and untracked files. If all
110
- * contents are ignored, then the directory is ignored; if any contents are
111
- * not ignored, then the directory is untracked. This is extra work that
112
- * may not matter in many cases.
113
- *
114
- * This flag turns off that scan and immediately labels an untracked
115
- * directory as untracked (changing the behavior to not match core git).
116
- */
117
- enableFastUntrackedDirs?: boolean
118
- /**
119
- * When diff finds a file in the working directory with stat information
120
- * different from the index, but the OID ends up being the same, write the
121
- * correct stat information into the index. Note: without this flag, diff
122
- * will always leave the index untouched.
123
- */
124
- updateIndex?: boolean
125
- /** Include unreadable files in the diff */
126
- includeUnreadable?: boolean
127
- /** Include unreadable files in the diff as untracked files */
128
- includeUnreadableAsUntracked?: boolean
129
- /** Treat all files as text, disabling binary attributes and detection. */
130
- forceText?: boolean
131
- /** Treat all files as binary, disabling text diffs */
132
- forceBinary?: boolean
133
- /** Ignore all whitespace */
134
- ignoreWhitespace?: boolean
135
- /** Ignore changes in the amount of whitespace */
136
- ignoreWhitespaceChange?: boolean
137
- /** Ignore whitespace at the end of line */
138
- ignoreWhitespaceEol?: boolean
139
- /** Ignore blank lines */
140
- ignoreBlankLines?: boolean
141
- /**
142
- * When generating patch text, include the content of untracked files.
143
- *
144
- * This automatically turns on `includeUntracked` but it does not turn on
145
- * `recurseUntrackedDirs`. Add that flag if you want the content of every
146
- * single untracked file.
147
- */
148
- showUntrackedContent?: boolean
149
- /**
150
- * When generating output, include the names of unmodified files if they
151
- * are included in the `Diff`. Normally these are skipped in the formats
152
- * that list files (e.g. name-only, name-status, raw). Even with this these
153
- * will not be included in the patch format.
154
- */
155
- showUnmodified?: boolean
156
- /** Use the "patience diff" algorithm */
157
- patience?: boolean
158
- /** Take extra time to find the minimal diff */
159
- minimal?: boolean
160
- /**
161
- * Include the necessary deflate/delta information so that `git-apply` can
162
- * apply given diff information to binary files.
163
- */
164
- showBinary?: boolean
165
- /**
166
- * Use a heuristic that takes indentation and whitespace into account
167
- * which generally can produce better diffs when dealing with ambiguous
168
- * diff hunks.
169
- */
170
- indentHeuristic?: boolean
171
- /**
172
- * Set the number of unchanged lines that define the boundary of a hunk
173
- * (and to display before and after).
174
- *
175
- * The default value for this is 3.
176
- */
177
- contextLines?: number
178
- /**
179
- * Set the maximum number of unchanged lines between hunk boundaries before
180
- * the hunks will be merged into one.
181
- *
182
- * The default value for this is 0.
183
- */
184
- interhunkLines?: number
185
- /** The default value for this is `core.abbrev` or 7 if unset. */
186
- idAbbrev?: number
187
- /**
188
- * Maximum size (in bytes) above which a blob will be marked as binary
189
- * automatically.
190
- *
191
- * A negative value will disable this entirely.
192
- *
193
- * The default value for this is 512MB.
194
- */
195
- maxSize?: number
196
- /**
197
- * The virtual "directory" to prefix old file names with in hunk headers.
198
- *
199
- * The default value for this is "a".
200
- */
201
- oldPrefix?: string
202
- /**
203
- * The virtual "directory" to prefix new file names with in hunk headers.
204
- *
205
- * The default value for this is "b".
206
- */
207
- newPrefix?: string
208
- /** Add to the array of paths/fnmatch patterns to constrain the diff. */
209
- pathspecs?: Array<string>
210
- }
211
- export interface IndexEntry {
212
- ctime: Date
213
- mtime: Date
214
- dev: number
215
- ino: number
216
- mode: number
217
- uid: number
218
- gid: number
219
- fileSize: number
220
- id: string
221
- flags: number
222
- flagsExtended: number
223
- /**
224
- * The path of this index entry as a byte vector. Regardless of the
225
- * current platform, the directory separator is an ASCII forward slash
226
- * (`0x2F`). There are no terminating or internal NUL characters, and no
227
- * trailing slashes. Most of the time, paths will be valid utf-8 — but
228
- * 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
233
- */
234
- path: Buffer
235
- }
236
- export interface IndexOnMatchCallbackArgs {
237
- /** The path of entry. */
238
- path: string
239
- /** The patchspec that matched it. */
240
- pathspec: string
241
- }
242
- export interface IndexAddAllOptions {
243
- /**
244
- * Files that are ignored will be skipped (unlike `addPath`). If a file is
245
- * already tracked in the index, then it will be updated even if it is
246
- * ignored. Pass the `force` flag to skip the checking of ignore rules.
247
- */
248
- force?: boolean
249
- /**
250
- * The `pathspecs` are a list of file names or shell glob patterns that
251
- * will matched against files in the repository's working directory. Each
252
- * file that matches will be added to the index (either updating an
253
- * existing entry or adding a new entry). You can disable glob expansion
254
- * and force exact matching with the `disablePathspecMatch` flag.
255
- */
256
- disablePathspecMatch?: boolean
257
- /**
258
- * To emulate `git add -A` and generate an error if the pathspec contains
259
- * the exact path of an ignored file (when not using `force`), add the
260
- * `checkPathspec` flag. This checks that each entry in `pathspecs`
261
- * that is an exact match to a filename on disk is either not ignored or
262
- * already in the index. If this check fails, the function will return
263
- * an error.
264
- */
265
- checkPathspec?: boolean
266
- /**
267
- * If you provide a callback function, it will be invoked on each matching
268
- * item in the working directory immediately before it is added to /
269
- * updated in the index. Returning zero will add the item to the index,
270
- * greater than zero will skip the item, and less than zero will abort the
271
- * scan an return an error to the caller.
272
- */
273
- onMatch?: (args: IndexOnMatchCallbackArgs) => number
274
- }
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';
281
- export interface IndexRemoveOptions {
282
- stage?: IndexStage
283
- }
284
- export interface IndexRemoveAllOptions {
285
- /**
286
- * If you provide a callback function, it will be invoked on each matching
287
- * item in the index immediately before it is removed. Return 0 to remove
288
- * the item, > 0 to skip the item, and < 0 to abort the scan.
289
- */
290
- onMatch?: (args: IndexOnMatchCallbackArgs) => number
291
- }
292
- export interface IndexUpdateAllOptions {
293
- /**
294
- * If you provide a callback function, it will be invoked on each matching
295
- * item in the index immediately before it is updated (either refreshed or
296
- * removed depending on working directory state). Return 0 to proceed with
297
- * updating the item, > 0 to skip the item, and < 0 to abort the scan.
298
- */
299
- onMatch?: (args: IndexOnMatchCallbackArgs) => number
300
- }
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
- }
314
- /**
315
- * Check if given string is valid Oid.
316
- *
317
- * Returns `false` if the string is empty, is longer than 40 hex
318
- * characters, or contains any non-hex characters.
319
- */
320
- export declare function isValidOid(value: string): boolean
321
- /** Test if this Oid is all zeros. */
322
- export declare function isZeroOid(value: string): boolean
323
- /** Creates an all zero Oid structure. */
324
- export declare function zeroOid(): string
325
- /**
326
- * Hashes the provided data as an object of the provided type, and returns
327
- * an Oid corresponding to the result. This does not store the object
328
- * inside any object database or repository.
329
- */
330
- export declare function hashObjectOid(objType: ObjectType, bytes: Buffer): string
331
- /**
332
- * Hashes the content of the provided file as an object of the provided type,
333
- * and returns an Oid corresponding to the result. This does not store the object
334
- * inside any object database or repository.
335
- */
336
- 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';
341
- /**
342
- * Ensure the reference name is well-formed.
343
- *
344
- * Validation is performed as if [`ReferenceFormat::ALLOW_ONELEVEL`]
345
- * was given to [`Reference::normalize_name`]. No normalization is
346
- * performed, however.
347
- *
348
- * @example
349
- * ```ts
350
- * import { isReferenceNameValid } from 'es-git';
351
- *
352
- * console.assert(isReferenceNameValid("HEAD"));
353
- * console.assert(isReferenceNameValid("refs/heads/main"));
354
- *
355
- * // But:
356
- * console.assert(!isReferenceNameValid("main"));
357
- * console.assert(!isReferenceNameValid("refs/heads/*"));
358
- * console.assert(!isReferenceNameValid("foo//bar"));
359
- * ```
360
- */
361
- export declare function isReferenceNameValid(refname: string): boolean
362
- /** Options for normalize reference name. */
363
- export const enum ReferenceFormat {
364
- /** No particular normalization. */
365
- 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
- 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
- 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
- RefspecShorthand = 4
389
- }
390
- /**
391
- * Normalize reference name and check validity.
392
- *
393
- * This will normalize the reference name by collapsing runs of adjacent
394
- * slashes between name components into a single slash. It also validates
395
- * the name according to the following rules:
396
- *
397
- * 1. If `ReferenceFormat.AllowOnelevel` is given, the name may
398
- * contain only capital letters and underscores, and must begin and end
399
- * with a letter. (e.g. "HEAD", "ORIG_HEAD").
400
- * 2. The flag `ReferenceFormat.RefspecShorthand` has an effect
401
- * only when combined with `ReferenceFormat.AllowOnelevel`. If
402
- * it is given, "shorthand" branch names (i.e. those not prefixed by
403
- * `refs/`, but consisting of a single word without `/` separators)
404
- * become valid. For example, "main" would be accepted.
405
- * 3. If `ReferenceFormat.RefspecPattern` is given, the name may
406
- * contain a single `*` in place of a full pathname component (e.g.
407
- * `foo/*\/bar`, `foo/bar*`).
408
- * 4. Names prefixed with "refs/" can be almost anything. You must avoid
409
- * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
410
- * sequences ".." and "@{" which have special meaning to revparse.
411
- *
412
- * If the reference passes validation, it is returned in normalized form,
413
- * otherwise an `null` is returned.
414
- *
415
- * @example
416
- * ```ts
417
- * import { normalizeReferenceName, ReferenceFormat } from 'es-git';
418
- *
419
- * console.assert(
420
- * normalizeReferenceName('foo//bar"),
421
- * 'foo/bar'
422
- * );
423
- * console.assert(
424
- * normalizeReferenceName(
425
- * 'HEAD',
426
- * ReferenceFormat.AllowOnelevel
427
- * ),
428
- * 'HEAD'
429
- * );
430
- * console.assert(
431
- * normalizeReferenceName(
432
- * 'refs/heads/*',
433
- * ReferenceFormat.RefspecPattern
434
- * ),
435
- * 'refs/heads/*'
436
- * );
437
- * console.assert(
438
- * normalizeReferenceName(
439
- * 'main',
440
- * ReferenceFormat.AllowOnelevel | ReferenceFormat.RefspecShorthand
441
- * ),
442
- * 'main'
443
- * );
444
- * ```
445
- */
446
- export declare function normalizeReferenceName(refname: string, format?: number | undefined | null): string | null
447
- export interface RenameReferenceOptions {
448
- /**
449
- * If the force flag is not enabled, and there's already a reference with
450
- * the given name, the renaming will fail.
451
- */
452
- force?: boolean
453
- logMessage?: string
454
- }
455
- export type Direction = 'Fetch' | 'Push';
456
- export interface RefspecObject {
457
- direction: Direction
458
- src: string
459
- dst: string
460
- force: boolean
461
- }
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
- {
483
- 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
- {
487
- type: 'SSHKeyFromAgent';
488
- username?: string;
489
- } | /** Create a new passphrase-protected ssh key credential object.*/
490
- {
491
- type: 'SSHKeyFromPath';
492
- username?: string;
493
- publicKeyPath?: string;
494
- privateKeyPath: string;
495
- passphrase?: string;
496
- } | /** Create a new ssh key credential object reading the keys from memory.*/
497
- {
498
- type: 'SSHKey';
499
- username?: string;
500
- publicKey?: string;
501
- privateKey: string;
502
- passphrase?: string;
503
- } | /** Create a new plain-text username and password credential object.*/
504
- {
505
- type: 'Plain';
506
- username?: string;
507
- password: string;
508
- };
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';
515
- /**
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.
521
- */
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.
526
- */
527
- 'Initial' | /** Allow redirects at any stage in the fetch or push. */
528
- 'All';
529
- /** Options which can be specified to various fetch operations. */
530
- export interface FetchOptions {
531
- credential?: Credential
532
- /** Set the proxy options to use for the fetch operation. */
533
- proxy?: ProxyOptions
534
- /** Set whether to perform a prune after the fetch. */
535
- prune?: FetchPrune
536
- /**
537
- * Set fetch depth, a value less or equal to 0 is interpreted as pull
538
- * everything (effectively the same as not declaring a limit depth).
539
- */
540
- depth?: number
541
- /**
542
- * Set how to behave regarding tags on the remote, such as auto-downloading
543
- * tags for objects we're downloading or downloading all of them.
544
- *
545
- * The default is to auto-follow tags.
546
- */
547
- downloadTags?: AutotagOption
548
- /**
549
- * Set remote redirection settings; whether redirects to another host are
550
- * permitted.
551
- *
552
- * By default, git will follow a redirect on the initial request
553
- * (`/info/refs`), but not subsequent requests.
554
- */
555
- followRedirects?: RemoteRedirect
556
- /** Set extra headers for this fetch operation. */
557
- customHeaders?: Array<string>
558
- }
559
- /** Options to control the behavior of a git push. */
560
- export interface PushOptions {
561
- credential?: Credential
562
- /** Set the proxy options to use for the push operation. */
563
- proxy?: ProxyOptions
564
- /**
565
- * If the transport being used to push to the remote requires the creation
566
- * of a pack file, this controls the number of worker threads used by the
567
- * packbuilder when creating that pack file to be sent to the remote.
568
- *
569
- * If set to 0, the packbuilder will auto-detect the number of threads to
570
- * create, and the default value is 1.
571
- */
572
- pbParallelism?: number
573
- /**
574
- * Set remote redirection settings; whether redirects to another host are
575
- * permitted.
576
- *
577
- * By default, git will follow a redirect on the initial request
578
- * (`/info/refs`), but not subsequent requests.
579
- */
580
- followRedirects?: RemoteRedirect
581
- /** Set extra headers for this push operation. */
582
- customHeaders?: Array<string>
583
- /** Set "push options" to deliver to the remote. */
584
- remoteOptions?: Array<string>
585
- }
586
- export interface CreateRemoteOptions {
587
- fetchRefspec?: string
588
- }
589
- export interface FetchRemoteOptions {
590
- fetch?: FetchOptions
591
- reflogMsg?: string
592
- }
593
- export interface PruneOptions {
594
- credential?: Credential
595
- }
596
- /** A listing of the possible states that a repository can be in. */
597
- export type RepositoryState = 'Clean' | 'Merge' | 'Revert' | 'RevertSequence' | 'CherryPick' | 'CherryPickSequence' | 'Bisect' | 'Rebase' | 'RebaseInteractive' | 'RebaseMerge' | 'ApplyMailbox' | 'ApplyMailboxOrRebase';
598
- export interface RepositoryInitOptions {
599
- bare?: boolean
600
- initialHead?: string
601
- originUrl?: string
602
- }
603
- export interface RepositoryOpenOptions {
604
- flags: number
605
- ceilingDirs?: Array<string>
606
- }
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
- export interface RepositoryCloneOptions {
620
- recursive?: boolean
621
- fetch?: FetchOptions
622
- }
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
- /**
628
- * Attempt to open an already-existing repository at or above `path`
629
- *
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.
636
- *
637
- * This will use the options configured so far to clone the specified URL
638
- * into the specified local path.
639
- */
640
- 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) */
644
- Single = 1,
645
- /** The spec targeted a range of commits (1 << 1) */
646
- Range = 2,
647
- /** The spec used the `...` operator, which invokes special semantics. (1 << 2) */
648
- MergeBase = 4
649
- }
650
- /** Check revparse mode contains specific flags. */
651
- export declare function revparseModeContains(source: number, target: number): boolean
652
- /** A revspec represents a range of revisions within a repository. */
653
- export interface Revspec {
654
- /** Access the `from` range of this revspec. */
655
- from?: string
656
- /** Access the `to` range of this revspec. */
657
- to?: string
658
- /** Returns the intent of the revspec. */
659
- mode: number
660
- }
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
- */
669
- 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
- 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
- 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
- Reverse = 4
692
- }
693
- /**
694
- * A Signature is used to indicate authorship of various actions throughout the
695
- * library.
696
- *
697
- * Signatures contain a name, email, and timestamp.
698
- */
699
- export interface Signature {
700
- /** Name on the signature. */
701
- name: string
702
- /** Email on the signature. */
703
- email: string
704
- /** Time in seconds, from epoch */
705
- timestamp: number
706
- }
707
- export interface SignatureTimeOptions {
708
- /** Time in seconds, from epoch */
709
- timestamp: number
710
- /** Timezone offset, in minutes */
711
- offset?: number
712
- }
713
- /** Create a new action signature. */
714
- export declare function createSignature(name: string, email: string, timeOptions?: SignatureTimeOptions | undefined | null): Signature
715
- export interface SignaturePayload {
716
- /** Name on the signature. */
717
- name: string
718
- /** Email on the signature. */
719
- email: string
720
- timeOptions?: SignatureTimeOptions
721
- }
722
- /**
723
- * Determine whether a tag name is valid, meaning that (when prefixed with refs/tags/) that
724
- * it is a valid reference name, and that any additional tag name restrictions are imposed
725
- * (eg, it cannot start with a -).
726
- */
727
- export declare function isValidTagName(tagName: string): boolean
728
- export interface CreateTagOptions {
729
- /**
730
- * Signature for tagger.
731
- *
732
- * If not provided, default signature of repository will be used.
733
- * If there is no default signature set for the repository, an error will occur.
734
- */
735
- tagger?: SignaturePayload
736
- force?: boolean
737
- }
738
- export interface CreateAnnotationTagOptions {
739
- /**
740
- * Signature for tagger.
741
- *
742
- * If not provided, default signature of repository will be used.
743
- * If there is no default signature set for the repository, an error will occur.
744
- */
745
- tagger?: SignaturePayload
746
- }
747
- export interface CreateLightweightTagOptions {
748
- force?: boolean
749
- }
750
- export type TreeWalkMode = 'PreOrder' | 'PostOrder';
751
- /**
752
- * A structure to represent a git commit
753
- * @hideconstructor
754
- */
755
- export declare class Commit {
756
- /** Get the id (SHA1) of a repository commit */
757
- id(): string
758
- /** Get the author of this commit. */
759
- author(): Signature
760
- /** Get the committer of this commit. */
761
- committer(): Signature
762
- /**
763
- * Get the full message of a commit.
764
- *
765
- * The returned message will be slightly prettified by removing any
766
- * potential leading newlines.
767
- *
768
- * Throws error if the message is not valid utf-8
769
- */
770
- message(): string
771
- /**
772
- * Get the short "summary" of the git commit message.
773
- *
774
- * The returned message is the summary of the commit, comprising the first
775
- * paragraph of the message with whitespace trimmed and squashed.
776
- *
777
- * Throws error if the summary is not valid utf-8.
778
- */
779
- summary(): string | null
780
- /**
781
- * Get the long "body" of the git commit message.
782
- *
783
- * The returned message is the body of the commit, comprising everything
784
- * but the first paragraph of the message. Leading and trailing whitespaces
785
- * are trimmed.
786
- *
787
- * Throws error if the summary is not valid utf-8.
788
- */
789
- body(): string | null
790
- /**
791
- * Get the commit time (i.e. committer time) of a commit.
792
- *
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.
796
- */
797
- time(): Date
798
- /** Get the tree pointed to by a commit. */
799
- tree(): Tree
800
- /** Casts this Commit to be usable as an `GitObject` */
801
- asObject(): GitObject
802
- }
803
- /**
804
- * The diff object that contains all individual file deltas.
805
- *
806
- * 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
811
- */
812
- export declare class Diff {
813
- /**
814
- * Merge one diff into another.
815
- *
816
- * This merges items from the "from" list into the "self" list. The
817
- * resulting diff will have all items that appear in either list.
818
- * If an item appears in both lists, then it will be "merged" to appear
819
- * as if the old version was from the "onto" list and the new version
820
- * is from the "from" list (with the exception that if the item has a
821
- * pending DELETE in the middle, then it will show as deleted).
822
- */
823
- merge(diff: Diff): void
824
- /** Returns an iterator over the deltas in this diff. */
825
- deltas(): Deltas
826
- /** Check if deltas are sorted case sensitively or insensitively. */
827
- isSortedIcase(): boolean
828
- /** Accumulate diff statistics for all patches. */
829
- stats(): DiffStats
830
- /** Iterate over a diff generating formatted text output. */
831
- print(options?: DiffPrintOptions | undefined | null): string
832
- }
833
- /**
834
- * Structure describing a hunk of a diff.
835
- *
836
- * @hideconstructor
837
- */
838
- export declare class DiffStats {
839
- /** Get the total number of files changed in a diff. */
840
- get filesChanged(): bigint
841
- /** Get the total number of insertions in a diff */
842
- get insertions(): bigint
843
- /** Get the total number of deletions in a diff */
844
- get deletions(): bigint
845
- }
846
- /**
847
- * An iterator over the diffs in a delta
848
- *
849
- * @hideconstructor
850
- */
851
- export declare class Deltas {
852
- [Symbol.iterator](): Iterator<DiffDelta, void, void>
853
- }
854
- /**
855
- * Description of changes to one entry.
856
- *
857
- * @hideconstructor
858
- */
859
- export declare class DiffDelta {
860
- /**
861
- * Returns the flags on the delta.
862
- *
863
- * For more information, see `DiffFlags`'s documentation.
864
- */
865
- flags(): number
866
- /** Returns the number of files in this delta. */
867
- numFiles(): number
868
- /** Returns the status of this entry */
869
- status(): DeltaType
870
- /**
871
- * Return the file which represents the "from" side of the diff.
872
- *
873
- * What side this means depends on the function that was used to generate
874
- * the diff and will be documented on the function itself.
875
- */
876
- oldFile(): DiffFile
877
- /**
878
- * Return the file which represents the "to" side of the diff.
879
- *
880
- * What side this means depends on the function that was used to generate
881
- * the diff and will be documented on the function itself.
882
- */
883
- newFile(): DiffFile
884
- }
885
- /**
886
- * Description of one side of a delta.
887
- *
888
- * Although this is called a "file" it could represent a file, a symbolic
889
- * link, a submodule commit id, or even a tree (although that only happens if
890
- * you are tracking type changes or ignored/untracked directories).
891
- *
892
- * @hideconstructor
893
- */
894
- export declare class DiffFile {
895
- /**
896
- * Returns the Oid of this item.
897
- *
898
- * If this entry represents an absent side of a diff (e.g. the `old_file`
899
- * of a `Added` delta), then the oid returned will be zeroes.
900
- */
901
- id(): string
902
- /**
903
- * Returns the path of the entry relative to the working directory of the
904
- * repository.
905
- */
906
- path(): string | null
907
- /** Returns the size of this entry, in bytes */
908
- size(): bigint
909
- /** Returns `true` if file(s) are treated as binary data. */
910
- isBinary(): boolean
911
- /** Returns `true` if `id` value is known correct. */
912
- isValidId(): boolean
913
- /** Returns `true` if file exists at this side of the delta. */
914
- exists(): boolean
915
- /** Returns file mode. */
916
- mode(): FileMode
917
- }
918
- /**
919
- * A structure to represent a git [index][1]
920
- * @hideconstructor
921
- *
922
- * [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects
923
- */
924
- export declare class Index {
925
- /**
926
- * Get index on-disk version.
927
- *
928
- * Valid return values are 2, 3, or 4. If 3 is returned, an index
929
- * with version 2 may be written instead, if the extension data in
930
- * version 3 is not necessary.
931
- */
932
- version(): number
933
- /**
934
- * Set index on-disk version.
935
- *
936
- * Valid values are 2, 3, or 4. If 2 is given, git_index_write may
937
- * write an index with version 3 instead, if necessary to accurately
938
- * represent the index.
939
- */
940
- 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
- /**
944
- * Add or update an index entry from a file on disk
945
- *
946
- * The file path must be relative to the repository's working folder and
947
- * must be readable.
948
- *
949
- * This method will fail in bare index instances.
950
- *
951
- * This forces the file to be added to the index, not looking at gitignore
952
- * rules.
953
- *
954
- * If this file currently is the result of a merge conflict, this file will
955
- * no longer be marked as conflicting. The data about the conflict will be
956
- * moved to the "resolve undo" (REUC) section.
957
- */
958
- addPath(path: string): void
959
- /**
960
- * Add or update index entries matching files in the working directory.
961
- *
962
- * This method will fail in bare index instances.
963
- *
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).
968
- *
969
- * @example
970
- *
971
- * Emulate `git add *`:
972
- *
973
- * ```ts
974
- * import { openRepository } from 'es-git';
975
- *
976
- * const repo = await openRepository('.');
977
- * const index = repo.index();
978
- * index.addAll(['*']);
979
- * index.write();
980
- * ```
981
- */
982
- addAll(pathspecs: Array<string>, options?: IndexAddAllOptions | undefined | null): void
983
- /**
984
- * Update the contents of an existing index object in memory by reading
985
- * from the hard disk.
986
- *
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.
990
- *
991
- * If force is false, this does a "soft" read that reloads the index data
992
- * from disk only if it has changed since the last time it was loaded.
993
- * Purely in-memory index data will be untouched. Be aware: if there are
994
- * changes on disk, unwritten in-memory changes are discarded.
995
- */
996
- read(force?: boolean | undefined | null): void
997
- /**
998
- * Write an existing index object from memory back to disk using an atomic
999
- * file lock.
1000
- */
1001
- write(): void
1002
- /**
1003
- * Write the index as a tree.
1004
- *
1005
- * This method will scan the index and write a representation of its
1006
- * current state back to disk; it recursively creates tree objects for each
1007
- * of the subtrees stored in the index, but only returns the OID of the
1008
- * root tree. This is the OID that can be used e.g. to create a commit.
1009
- *
1010
- * The index instance cannot be bare, and needs to be associated to an
1011
- * existing repository.
1012
- *
1013
- * The index must not contain any file in conflict.
1014
- */
1015
- writeTree(): string
1016
- /**
1017
- * Remove an index entry corresponding to a file on disk.
1018
- *
1019
- * The file path must be relative to the repository's working folder. It
1020
- * may exist.
1021
- *
1022
- * If this file currently is the result of a merge conflict, this file will
1023
- * no longer be marked as conflicting. The data about the conflict will be
1024
- * moved to the "resolve undo" (REUC) section.
1025
- */
1026
- 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
- /**
1030
- * Update all index entries to match the working directory
1031
- *
1032
- * This method will fail in bare index instances.
1033
- *
1034
- * This scans the existing index entries and synchronizes them with the
1035
- * working directory, deleting them if the corresponding working directory
1036
- * file no longer exists otherwise updating the information (including
1037
- * adding the latest version of file to the ODB if needed).
1038
- */
1039
- updateAll(pathspecs: Array<string>, options?: IndexUpdateAllOptions | undefined | null): void
1040
- /** Get the count of entries currently in the index */
1041
- count(): number
1042
- /** Return `true` is there is no entry in the index */
1043
- isEmpty(): boolean
1044
- /**
1045
- * Get the full path to the index file on disk.
1046
- *
1047
- * Returns `None` if this is an in-memory index.
1048
- */
1049
- path(): string | null
1050
- /**
1051
- * Does this index have conflicts?
1052
- *
1053
- * Returns `true` if the index contains conflicts, `false` if it does not.
1054
- */
1055
- hasConflicts(): boolean
1056
- /** Get an iterator over the entries in this index. */
1057
- entries(): IndexEntries
1058
- }
1059
- /**
1060
- * An iterator over the entries in an index
1061
- *
1062
- * @hideconstructor
1063
- */
1064
- export declare class IndexEntries {
1065
- [Symbol.iterator](): Iterator<IndexEntry, void, void>
1066
- }
1067
- /**
1068
- * A structure to represent a git [object][1]
1069
- * @hideconstructor
1070
- *
1071
- * [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects
1072
- */
1073
- export declare class GitObject {
1074
- /** Get the id (SHA1) of a repository object */
1075
- id(): string
1076
- /**
1077
- * Get the object type of object.
1078
- *
1079
- * If the type is unknown, then `null` is returned.
1080
- */
1081
- type(): ObjectType | null
1082
- /**
1083
- * Recursively peel an object until an object of the specified type is met.
1084
- *
1085
- * If you pass `Any` as the target type, then the object will be
1086
- * peeled until the type changes (e.g. a tag will be chased until the
1087
- * referenced object is no longer a tag).
1088
- */
1089
- peel(objType: ObjectType): GitObject
1090
- /** Recursively peel an object until a commit is found */
1091
- peelToCommit(): Commit
1092
- /**
1093
- * Attempt to view this object as a commit.
1094
- *
1095
- * Returns `null` if the object is not actually a commit.
1096
- */
1097
- asCommit(): Commit | null
1098
- }
1099
- /**
1100
- * A structure to represent a git [reference][1].
1101
- * @hideconstructor
1102
- *
1103
- * [1]: http://git-scm.com/book/en/Git-Internals-Git-References
1104
- */
1105
- export declare class Reference {
1106
- /**
1107
- * Delete an existing reference.
1108
- *
1109
- * This method works for both direct and symbolic references. The reference
1110
- * will be immediately removed on disk.
1111
- *
1112
- * This function will return an error if the reference has changed from the
1113
- * time it was looked up.
1114
- */
1115
- delete(): void
1116
- /** Check if a reference is a local branch. */
1117
- isBranch(): boolean
1118
- /** Check if a reference is a note. */
1119
- isNote(): boolean
1120
- /** Check if a reference is a remote tracking branch */
1121
- isRemote(): boolean
1122
- /** Check if a reference is a tag */
1123
- isTag(): boolean
1124
- /**
1125
- * Get the reference type of a reference.
1126
- *
1127
- * If the type is unknown, then `null` is returned.
1128
- */
1129
- type(): ReferenceType | null
1130
- /**
1131
- * Get the full name of a reference.
1132
- *
1133
- * Throws error if the name is not valid utf-8.
1134
- */
1135
- name(): string
1136
- /**
1137
- * Get the full shorthand of a reference.
1138
- *
1139
- * This will transform the reference name into a name "human-readable"
1140
- * version. If no shortname is appropriate, it will return the full name.
1141
- *
1142
- * Throws error if the shorthand is not valid utf-8.
1143
- */
1144
- shorthand(): string
1145
- /**
1146
- * Get the OID pointed to by a direct reference.
1147
- *
1148
- * Only available if the reference is direct (i.e. an object id reference,
1149
- * not a symbolic one).
1150
- */
1151
- target(): string | null
1152
- /**
1153
- * Return the peeled OID target of this reference.
1154
- *
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.
1157
- */
1158
- targetPeel(): string | null
1159
- /**
1160
- * Peel a reference to a tree
1161
- *
1162
- * This method recursively peels the reference until it reaches
1163
- * a tree.
1164
- */
1165
- peelToTree(): Tree
1166
- /**
1167
- * Get full name to the reference pointed to by a symbolic reference.
1168
- *
1169
- * Only available if the reference is symbolic.
1170
- */
1171
- symbolicTarget(): string | null
1172
- /**
1173
- * Resolve a symbolic reference to a direct reference.
1174
- *
1175
- * This method iteratively peels a symbolic reference until it resolves to
1176
- * a direct reference to an OID.
1177
- *
1178
- * If a direct reference is passed as an argument, a copy of that
1179
- * reference is returned.
1180
- */
1181
- resolve(): Reference
1182
- /**
1183
- * Rename an existing reference.
1184
- *
1185
- * This method works for both direct and symbolic references.
1186
- *
1187
- * If the force flag is not enabled, and there's already a reference with
1188
- * the given name, the renaming will fail.
1189
- */
1190
- rename(newName: string, options?: RenameReferenceOptions | undefined | null): Reference
1191
- }
1192
- /**
1193
- * A structure representing a [remote][1] of a git repository.
1194
- * @hideconstructor
1195
- *
1196
- * [1]: http://git-scm.com/book/en/Git-Basics-Working-with-Remotes
1197
- */
1198
- export declare class Remote {
1199
- /**
1200
- * Get the remote's name.
1201
- *
1202
- * Returns `null` if this remote has not yet been named, and
1203
- * Throws error if the URL is not valid utf-8
1204
- */
1205
- name(): string | null
1206
- /**
1207
- * Get the remote's URL.
1208
- *
1209
- * Throws error if the URL is not valid utf-8
1210
- */
1211
- url(): string
1212
- /**
1213
- * Get the remote's URL.
1214
- *
1215
- * Returns `null` if push url not exists, and
1216
- * Throws error if the URL is not valid utf-8
1217
- */
1218
- pushurl(): string | null
1219
- /**
1220
- * List all refspecs.
1221
- *
1222
- * Filter refspec if has not valid src or dst with utf-8
1223
- */
1224
- refspecs(): Array<RefspecObject>
1225
- /**
1226
- * Download new data and update tips
1227
- *
1228
- * Convenience function to connect to a remote, download the data, disconnect and update the remote-tracking branches.
1229
- */
1230
- fetch(refspecs: Array<string>, options?: FetchRemoteOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<void>
1231
- /**
1232
- * Perform a push
1233
- *
1234
- * Perform all the steps for a push.
1235
- * If no refspecs are passed, then the configured refspecs will be used.
1236
- */
1237
- 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 */
1239
- prune(options?: PruneOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<void>
1240
- /** Get the remote’s default branch. */
1241
- defaultBranch(signal?: AbortSignal | undefined | null): Promise<string>
1242
- }
1243
- /**
1244
- * An owned git repository, representing all state associated with the
1245
- * underlying filesystem.
1246
- *
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
1253
- */
1254
- export declare class Repository {
1255
- /**
1256
- * Lookup a reference to one of the commits in a repository.
1257
- *
1258
- * Returns `null` if the commit does not exist.
1259
- */
1260
- findCommit(oid: string): Commit | null
1261
- /** Lookup a reference to one of the commits in a repository. */
1262
- getCommit(oid: string): Commit
1263
- /**
1264
- * Create new commit in the repository
1265
- *
1266
- * If the `update_ref` is not `null`, name of the reference that will be
1267
- * updated to point to this commit. If the reference is not direct, it will
1268
- * be resolved to a direct reference. Use "HEAD" to update the HEAD of the
1269
- * current branch and make it point to this commit. If the reference
1270
- * doesn't exist yet, it will be created. If it does exist, the first
1271
- * parent must be the tip of this branch.
1272
- */
1273
- commit(tree: Tree, message: string, options?: CommitOptions | undefined | null): string
1274
- /**
1275
- * Create a diff with the difference between two tree objects.
1276
- *
1277
- * This is equivalent to `git diff <old-tree> <new-tree>`
1278
- *
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`.
1283
- */
1284
- diffTreeToTree(oldTree?: Tree | undefined | null, newTree?: Tree | undefined | null, options?: DiffOptions | undefined | null): Diff
1285
- /**
1286
- * Create a diff between two index objects.
1287
- *
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.
1290
- */
1291
- diffIndexToIndex(oldIndex: Index, newIndex: Index, options?: DiffOptions | undefined | null): Diff
1292
- /**
1293
- * Create a diff between the repository index and the workdir directory.
1294
- *
1295
- * This matches the `git diff` command. See the note below on
1296
- * `tree_to_workdir` for a discussion of the difference between
1297
- * `git diff` and `git diff HEAD` and how to emulate a `git diff <treeish>`
1298
- * using libgit2.
1299
- *
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.
1302
- *
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.
1306
- */
1307
- diffIndexToWorkdir(index?: Index | undefined | null, options?: DiffOptions | undefined | null): Diff
1308
- /**
1309
- * Create a diff between a tree and the working directory.
1310
- *
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.
1313
- *
1314
- * This is not the same as `git diff <treeish>` or `git diff-index <treeish>`.
1315
- * Those commands use information from the index, whereas this
1316
- * 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.
1319
- *
1320
- * To see difference between this and `tree_to_workdir_with_index`,
1321
- * 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
1323
- * tree-to-workdir diff for that file is 'modified', but `git diff` would
1324
- * show status 'deleted' since there is a staged delete.
1325
- *
1326
- * If `null` is passed for `tree`, then an empty tree is used.
1327
- */
1328
- diffTreeToWorkdir(oldTree?: Tree | undefined | null, options?: DiffOptions | undefined | null): Diff
1329
- /**
1330
- * Create a diff between a tree and the working directory using index data
1331
- * to account for staged deletes, tracked files, etc.
1332
- *
1333
- * This emulates `git diff <tree>` by diffing the tree to the index and
1334
- * the index to the working directory and blending the results into a
1335
- * single diff that includes staged deleted, etc.
1336
- */
1337
- diffTreeToWorkdirWithIndex(oldTree?: Tree | undefined | null, options?: DiffOptions | undefined | null): Diff
1338
- /**
1339
- * Get the Index file for this repository.
1340
- *
1341
- * If a custom index has not been set, the default index for the repository
1342
- * will be returned (the one located in .git/index).
1343
- *
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.
1348
- */
1349
- index(): Index
1350
- /**
1351
- * Lookup a reference to one of the objects in a repository.
1352
- *
1353
- * Returns `null` if the object does not exist.
1354
- */
1355
- findObject(oid: string): GitObject | null
1356
- /** Lookup a reference to one of the objects in a repository. */
1357
- getObject(oid: string): GitObject
1358
- /** Lookup a reference to one of the objects in a repository. */
1359
- findReference(name: string): Reference | null
1360
- /** Lookup a reference to one of the objects in a repository. */
1361
- getReference(name: string): Reference
1362
- /** List all remotes for a given repository */
1363
- remoteNames(): Array<string>
1364
- /**
1365
- * Get remote from repository
1366
- *
1367
- * Throws error if not exists
1368
- */
1369
- getRemote(name: string): Remote
1370
- /** Find remote from repository */
1371
- findRemote(name: string): Remote | null
1372
- /** Add a remote with the default fetch refspec to the repository’s configuration. */
1373
- createRemote(name: string, url: string, options?: CreateRemoteOptions | undefined | null): Remote
1374
- /** Tests whether this repository is a bare repository or not. */
1375
- isBare(): boolean
1376
- /** Tests whether this repository is a shallow clone. */
1377
- isShallow(): boolean
1378
- /** Tests whether this repository is a worktree. */
1379
- isWorktree(): boolean
1380
- /** Tests whether this repository is empty. */
1381
- isEmpty(): boolean
1382
- /**
1383
- * Returns the path to the `.git` folder for normal repositories or the
1384
- * repository itself for bare repositories.
1385
- */
1386
- path(): string
1387
- /** Returns the current state of this repository */
1388
- state(): RepositoryState
1389
- /**
1390
- * Get the path of the working directory for this repository.
1391
- *
1392
- * If this repository is bare, then `null` is returned.
1393
- */
1394
- workdir(): string | null
1395
- /** Retrieve and resolve the reference pointed at by HEAD. */
1396
- head(): Reference
1397
- /**
1398
- * Make the repository HEAD point to the specified reference.
1399
- *
1400
- * If the provided reference points to a tree or a blob, the HEAD is
1401
- * unaltered and an error is returned.
1402
- *
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.
1407
- *
1408
- * Otherwise, the HEAD will be detached and will directly point to the
1409
- * commit.
1410
- */
1411
- setHead(refname: string): void
1412
- /**
1413
- * Execute a rev-parse operation against the `spec` listed.
1414
- *
1415
- * The resulting revision specification is returned, or an error is
1416
- * returned if one occurs.
1417
- */
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
- revwalk(): Revwalk
1423
- /**
1424
- * Lookup a tag object by prefix hash from the repository.
1425
- *
1426
- * Returns `null` if tag does not exist.
1427
- */
1428
- findTag(oid: string): Tag | null
1429
- /** Lookup a tag object by prefix hash from the repository. */
1430
- getTag(oid: string): Tag
1431
- /**
1432
- * Get a list with all the tags in the repository.
1433
- *
1434
- * An optional fnmatch pattern can also be specified.
1435
- */
1436
- tagNames(pattern?: string | undefined | null): Array<string>
1437
- /**
1438
- * iterate over all tags calling `callback` on each.
1439
- * the callback is provided the tag id and name
1440
- */
1441
- tagForeach(callback: (oid: string, name: string) => boolean): void
1442
- /**
1443
- * Delete an existing tag reference.
1444
- *
1445
- * The tag name will be checked for validity, see `tag` for some rules
1446
- * about valid names.
1447
- */
1448
- deleteTag(name: string): void
1449
- /**
1450
- * Create a new tag in the repository from an object
1451
- *
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.
1455
- *
1456
- * The message will not be cleaned up.
1457
- *
1458
- * The tag name will be checked for validity. You must avoid the characters
1459
- * '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @
1460
- * {" which have special meaning to revparse.
1461
- */
1462
- createTag(name: string, target: GitObject, message: string, options?: CreateTagOptions | undefined | null): string
1463
- /**
1464
- * Create a new tag in the repository from an object without creating a reference.
1465
- *
1466
- * The message will not be cleaned up.
1467
- *
1468
- * The tag name will be checked for validity. You must avoid the characters
1469
- * '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @
1470
- * {" which have special meaning to revparse.
1471
- */
1472
- createAnnotationTag(name: string, target: GitObject, message: string, options?: CreateAnnotationTagOptions | undefined | null): string
1473
- /**
1474
- * Create a new lightweight tag pointing at a target object
1475
- *
1476
- * 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.
1479
- */
1480
- createLightweightTag(name: string, target: GitObject, options?: CreateLightweightTagOptions | undefined | null): string
1481
- /** Lookup a reference to one of the objects in a repository. */
1482
- getTree(oid: string): Tree
1483
- /**
1484
- * Lookup a reference to one of the objects in a repository.
1485
- *
1486
- * If it does not exists, returns `null`.
1487
- */
1488
- findTree(oid: string): Tree | null
1489
- }
1490
- /**
1491
- * A revwalk allows traversal of the commit graph defined by including one or
1492
- * more leaves and excluding one or more roots.
1493
- *
1494
- * @hideconstructor
1495
- */
1496
- export declare class Revwalk {
1497
- [Symbol.iterator](): Iterator<string, void, void>
1498
- /**
1499
- * Reset a revwalk to allow re-configuring it.
1500
- *
1501
- * The revwalk is automatically reset when iteration of its commits
1502
- * completes.
1503
- */
1504
- reset(): this
1505
- /** Set the order in which commits are visited. */
1506
- setSorting(sort: number): this
1507
- /**
1508
- * Simplify the history by first-parent
1509
- *
1510
- * No parents other than the first for each commit will be enqueued.
1511
- */
1512
- simplifyFirstParent(): this
1513
- /**
1514
- * Mark a commit to start traversal from.
1515
- *
1516
- * The given OID must belong to a commitish on the walked repository.
1517
- *
1518
- * The given commit will be used as one of the roots when starting the
1519
- * revision walk. At least one commit must be pushed onto the walker before
1520
- * a walk can be started.
1521
- */
1522
- push(oid: string): this
1523
- /**
1524
- * Push the repository's HEAD
1525
- *
1526
- * For more information, see `push`.
1527
- */
1528
- pushHead(): this
1529
- /**
1530
- * Push matching references
1531
- *
1532
- * The OIDs pointed to by the references that match the given glob pattern
1533
- * will be pushed to the revision walker.
1534
- *
1535
- * A leading 'refs/' is implied if not present as well as a trailing `/ \
1536
- * *` if the glob lacks '?', ' \ *' or '['.
1537
- *
1538
- * Any references matching this glob which do not point to a commitish
1539
- * will be ignored.
1540
- */
1541
- pushGlob(glob: string): this
1542
- /**
1543
- * Push and hide the respective endpoints of the given range.
1544
- *
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
1547
- * commit will be hidden and the right-hand commit pushed.
1548
- */
1549
- pushRange(range: string): this
1550
- /**
1551
- * Push the OID pointed to by a reference
1552
- *
1553
- * The reference must point to a commitish.
1554
- */
1555
- pushRef(reference: string): this
1556
- /** Mark a commit as not of interest to this revwalk. */
1557
- hide(oid: string): this
1558
- /**
1559
- * Hide the repository's HEAD
1560
- *
1561
- * For more information, see `hide`.
1562
- */
1563
- hideHead(): this
1564
- /**
1565
- * Hide matching references.
1566
- *
1567
- * The OIDs pointed to by the references that match the given glob pattern
1568
- * and their ancestors will be hidden from the output on the revision walk.
1569
- *
1570
- * A leading 'refs/' is implied if not present as well as a trailing `/ \
1571
- * *` if the glob lacks '?', ' \ *' or '['.
1572
- *
1573
- * Any references matching this glob which do not point to a commitish
1574
- * will be ignored.
1575
- */
1576
- hideGlob(glob: string): this
1577
- /**
1578
- * Hide the OID pointed to by a reference.
1579
- *
1580
- * The reference must point to a commitish.
1581
- */
1582
- hideRef(reference: string): this
1583
- }
1584
- /**
1585
- * A structure to represent a git [tag][1]
1586
- * @hideconstructor
1587
- *
1588
- * [1]: http://git-scm.com/book/en/Git-Basics-Tagging
1589
- */
1590
- export declare class Tag {
1591
- /** Get the id (SHA1) of a repository tag */
1592
- id(): string
1593
- /**
1594
- * Get the message of a tag
1595
- *
1596
- * Returns `null`` if there is no message or if it is not valid utf8
1597
- */
1598
- message(): string | null
1599
- /**
1600
- * Get the name of a tag
1601
- *
1602
- * Throws error if it is not valid utf8
1603
- */
1604
- name(): string
1605
- /** Recursively peel a tag until a non tag git_object is found */
1606
- peel(): GitObject
1607
- /**
1608
- * Get the tagger (author) of a tag
1609
- *
1610
- * If the author is unspecified, then `null` is returned.
1611
- */
1612
- tagger(): Signature | null
1613
- /**
1614
- * Get the tagged object of a tag
1615
- *
1616
- * This method performs a repository lookup for the given object and
1617
- * returns it
1618
- */
1619
- target(): GitObject
1620
- /** Get the OID of the tagged object of a tag */
1621
- targetId(): string
1622
- /** Get the ObjectType of the tagged object of a tag */
1623
- targetType(): ObjectType | null
1624
- }
1625
- /**
1626
- * A structure to represent a git [tree][1]
1627
- * @hideconstructor
1628
- *
1629
- * [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects
1630
- */
1631
- export declare class Tree {
1632
- /** Get the id (SHA1) of a repository object */
1633
- id(): string
1634
- /** Get the number of entries listed in this tree. */
1635
- len(): bigint
1636
- /** Return `true` if there is not entry */
1637
- isEmpty(): boolean
1638
- /** Returns an iterator over the entries in this tree. */
1639
- iter(): TreeIter
1640
- /**
1641
- * 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
- *
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.
1649
- *
1650
- * [1]: https://libgit2.org/libgit2/#HEAD/group/tree/git_tree_walk
1651
- */
1652
- walk(mode: TreeWalkMode, callback: (entry: TreeEntry) => number): void
1653
- /** Lookup a tree entry by SHA value. */
1654
- getId(id: string): TreeEntry | null
1655
- /** Lookup a tree entry by its position in the tree */
1656
- get(index: number): TreeEntry | null
1657
- /** Lookup a tree entry by its filename */
1658
- getName(filename: string): TreeEntry | null
1659
- /**
1660
- * Retrieve a tree entry contained in a tree or in any of its subtrees,
1661
- * given its relative path.
1662
- */
1663
- getPath(path: string): TreeEntry | null
1664
- /** Casts this Tree to be usable as an `GitObject` */
1665
- asObject(): GitObject
1666
- }
1667
- /**
1668
- * An iterator over the entries in a tree.
1669
- *
1670
- * @hideconstructor
1671
- */
1672
- export declare class TreeIter {
1673
- [Symbol.iterator](): Iterator<TreeEntry, void, void>
1674
- }
1675
- /**
1676
- * A structure representing an entry inside of a tree. An entry is borrowed
1677
- * from a tree.
1678
- *
1679
- * @hideconstructor
1680
- */
1681
- export declare class TreeEntry {
1682
- /** Get the id of the object pointed by the entry */
1683
- id(): string
1684
- /**
1685
- * Get the filename of a tree entry
1686
- *
1687
- * Throws error if the name is not valid utf-8
1688
- */
1689
- name(): string
1690
- /** Get the type of the object pointed by the entry */
1691
- type(): ObjectType | null
1692
- /** Get the UNIX file attributes of a tree entry */
1693
- filemode(): number
1694
- /** Convert a tree entry to the object it points to. */
1695
- toObject(repo: Repository): GitObject
1696
- }