es-git 0.5.0-next.161 → 0.5.0-next.163

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.
Files changed (3) hide show
  1. package/index.d.ts +264 -0
  2. package/index.js +2 -0
  3. package/package.json +11 -11
package/index.d.ts CHANGED
@@ -1895,6 +1895,85 @@ export declare class Mailmap {
1895
1895
  resolveSignature(signature: SignaturePayload): Signature
1896
1896
  }
1897
1897
 
1898
+ /**
1899
+ * A structure representing a [note][1] in git.
1900
+ *
1901
+ * [1]: http://alblue.bandlem.com/2011/11/git-tip-of-week-git-notes.html
1902
+ */
1903
+ export declare class Note {
1904
+ /**
1905
+ * Get the note object's id
1906
+ *
1907
+ * @category Note/Methods
1908
+ * @signature
1909
+ * ```ts
1910
+ * class Note {
1911
+ * id(): string;
1912
+ * }
1913
+ * ```
1914
+ *
1915
+ * @returns The note object's id.
1916
+ */
1917
+ id(): string
1918
+ /**
1919
+ * Get the note author
1920
+ *
1921
+ * @category Note/Methods
1922
+ * @signature
1923
+ * ```ts
1924
+ * class Note {
1925
+ * author(): Signature;
1926
+ * }
1927
+ * ```
1928
+ *
1929
+ * @returns The note author signature.
1930
+ */
1931
+ author(): Signature
1932
+ /**
1933
+ * Get the note committer
1934
+ *
1935
+ * @category Note/Methods
1936
+ * @signature
1937
+ * ```ts
1938
+ * class Note {
1939
+ * committer(): Signature;
1940
+ * }
1941
+ * ```
1942
+ *
1943
+ * @returns The note committer signature.
1944
+ */
1945
+ committer(): Signature
1946
+ /**
1947
+ * Get the note message as a string.
1948
+ *
1949
+ * @category Note/Methods
1950
+ * @signature
1951
+ * ```ts
1952
+ * class Note {
1953
+ * message(): string;
1954
+ * }
1955
+ * ```
1956
+ *
1957
+ * @returns The note message as a string
1958
+ * @throws Throws error if message is not utf-8.
1959
+ */
1960
+ message(): string
1961
+ }
1962
+
1963
+ /**
1964
+ * An iterator over all of the notes within a repository.
1965
+ *
1966
+ * This type extends JavaScript's `Iterator`, and so has the iterator helper
1967
+ * methods. It may extend the upcoming TypeScript `Iterator` class in the future.
1968
+ *
1969
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helper_methods
1970
+ * @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-6.html#iterator-helper-methods
1971
+ */
1972
+ export declare class Notes extends Iterator<NoteIterItem, void, void> {
1973
+
1974
+ next(value?: void): IteratorResult<NoteIterItem, void>
1975
+ }
1976
+
1898
1977
  /**
1899
1978
  * Representation of a rebase
1900
1979
  * Begin the rebase by iterating the returned `Rebase`
@@ -3218,6 +3297,134 @@ export declare class Repository {
3218
3297
  * @returns Merge analysis result.
3219
3298
  */
3220
3299
  analyzeMergeForRef(ourRef: Reference, theirHeads: Array<AnnotatedCommit>): MergeAnalysisResult
3300
+ /**
3301
+ * Add a note for an object
3302
+ *
3303
+ * The `notesRef` argument is the canonical name of the reference to use,
3304
+ * defaulting to "refs/notes/commits". If `force` is specified then
3305
+ * previous notes are overwritten.
3306
+ *
3307
+ * @category Repository/Methods
3308
+ * @signature
3309
+ * ```ts
3310
+ * class Repository {
3311
+ * note(oid: string, note: string, options?: CreateNoteOptions | null | undefined): string;
3312
+ * }
3313
+ * ```
3314
+ *
3315
+ * @param {string} oid - OID of the git object to decorate.
3316
+ * @param {string} note - Content of the note to add for object oid.
3317
+ * @param {CreateNoteOptions} [options] - Options for creating note.
3318
+ * @returns OID for the note.
3319
+ */
3320
+ note(oid: string, note: string, options?: CreateNoteOptions | undefined | null): string
3321
+ /**
3322
+ * Get the default notes reference for this repository
3323
+ *
3324
+ * @category Repository/Methods
3325
+ * @signature
3326
+ * ```ts
3327
+ * class Repository {
3328
+ * noteDefaultRef(): string;
3329
+ * }
3330
+ * ```
3331
+ *
3332
+ * @returns The default notes reference.
3333
+ */
3334
+ noteDefaultRef(): string
3335
+ /**
3336
+ * Creates a new iterator for notes in this repository.
3337
+ *
3338
+ * The `notesRef` argument is the canonical name of the reference to use,
3339
+ * defaulting to "refs/notes/commits".
3340
+ *
3341
+ * @category Repository/Methods
3342
+ * @signature
3343
+ * ```ts
3344
+ * class Repository {
3345
+ * notes(notesRef?: string | null | undefined): Notes;
3346
+ * }
3347
+ * ```
3348
+ *
3349
+ * @param {string} [notesRef] - The canonical name of the reference to use.
3350
+ * @returns Iterator of all notes. The iterator returned yields pairs of `[string, string]`
3351
+ * where first element is the id of the note and the second id is the id the note is annotating.
3352
+ *
3353
+ * @example
3354
+ * ```ts
3355
+ * import { openRepository } from 'es-git';
3356
+ *
3357
+ * const repo = await openRepository('.');
3358
+ * for (const { noteId, annotatedId } of repo.notes()) {
3359
+ * const note = repo.getNote(noteId);
3360
+ * const commit = repo.getCommit(annotatedId);
3361
+ * }
3362
+ * ```
3363
+ */
3364
+ notes(notesRef?: string | undefined | null): Notes
3365
+ /**
3366
+ * Read the note for an object.
3367
+ *
3368
+ * The `notesRef` argument is the canonical name of the reference to use,
3369
+ * defaulting to "refs/notes/commits".
3370
+ *
3371
+ * The id specified is the Oid of the git object to read the note from.
3372
+ *
3373
+ * @category Repository/Methods
3374
+ * @signature
3375
+ * ```ts
3376
+ * class Repository {
3377
+ * getNote(id: string, options?: FindNoteOptions | null | undefined): Note;
3378
+ * }
3379
+ * ```
3380
+ *
3381
+ * @param {string} id - OID of the git object to read the note from.
3382
+ * @param {FindNoteOptions} [options] - Options for finding note.
3383
+ * @returns Instance of the note.
3384
+ * @throws Throws error if note does not exists.
3385
+ */
3386
+ getNote(id: string, options?: FindNoteOptions | undefined | null): Note
3387
+ /**
3388
+ * Read the note for an object.
3389
+ *
3390
+ * The `notesRef` argument is the canonical name of the reference to use,
3391
+ * defaulting to "refs/notes/commits".
3392
+ *
3393
+ * The id specified is the Oid of the git object to read the note from.
3394
+ *
3395
+ * @category Repository/Methods
3396
+ * @signature
3397
+ * ```ts
3398
+ * class Repository {
3399
+ * findNote(id: string, options?: FindNoteOptions | null | undefined): Note | null;
3400
+ * }
3401
+ * ```
3402
+ *
3403
+ * @param {string} id - OID of the git object to read the note from.
3404
+ * @param {FindNoteOptions} [options] - Options for finding note.
3405
+ * @returns Instance of the note. If does not exists, returns `null`.
3406
+ */
3407
+ findNote(id: string, options?: FindNoteOptions | undefined | null): Note | null
3408
+ /**
3409
+ * Remove the note for an object.
3410
+ *
3411
+ * The `notesRef` argument is the canonical name of the reference to use,
3412
+ * defaulting to "refs/notes/commits".
3413
+ *
3414
+ * The id specified is the Oid of the git object to remove the note from.
3415
+ *
3416
+ * @category Repository/Methods
3417
+ * @signature
3418
+ * ```ts
3419
+ * class Repository {
3420
+ * deleteNote(id: string, options?: DeleteNoteOptions | null | undefined): void;
3421
+ * }
3422
+ * ```
3423
+ *
3424
+ * @param {string} id - OID of the git object to remove the note from.
3425
+ * @param {DeleteNoteOptions} [options] - Options for deleting note.
3426
+ */
3427
+ deleteNote(id: string, options?: DeleteNoteOptions | undefined | null): void
3221
3428
  /**
3222
3429
  * Lookup a reference to one of the objects in a repository.
3223
3430
  *
@@ -5734,6 +5941,31 @@ export interface CreateLightweightTagOptions {
5734
5941
  */
5735
5942
  export declare function createMailmapFromBuffer(content: string): Mailmap
5736
5943
 
5944
+ export interface CreateNoteOptions {
5945
+ /**
5946
+ * Signature of the notes commit author.
5947
+ *
5948
+ * If not provided, the default signature of the repository will be used.
5949
+ * If there is no default signature set for the repository, an error will occur.
5950
+ */
5951
+ author?: SignaturePayload
5952
+ /**
5953
+ * Signature of the notes commit commiter.
5954
+ *
5955
+ * If not provided, the default signature of the repository will be used.
5956
+ * If there is no default signature set for the repository, an error will occur.
5957
+ */
5958
+ committer?: SignaturePayload
5959
+ /**
5960
+ * canonical name of the reference to use.
5961
+ *
5962
+ * Defaults to "refs/notes/commits".
5963
+ */
5964
+ notesRef?: string
5965
+ /** Overwrite existing note. */
5966
+ force?: boolean
5967
+ }
5968
+
5737
5969
  export interface CreateRemoteOptions {
5738
5970
  fetchRefspec?: string
5739
5971
  }
@@ -5811,6 +6043,29 @@ export type CredentialType = 'Default'|
5811
6043
  'SSHKey'|
5812
6044
  'Plain';
5813
6045
 
6046
+ export interface DeleteNoteOptions {
6047
+ /**
6048
+ * Signature of the notes commit author.
6049
+ *
6050
+ * If not provided, the default signature of the repository will be used.
6051
+ * If there is no default signature set for the repository, an error will occur.
6052
+ */
6053
+ author?: SignaturePayload
6054
+ /**
6055
+ * Signature of the notes commit commiter.
6056
+ *
6057
+ * If not provided, the default signature of the repository will be used.
6058
+ * If there is no default signature set for the repository, an error will occur.
6059
+ */
6060
+ committer?: SignaturePayload
6061
+ /**
6062
+ * canonical name of the reference to use.
6063
+ *
6064
+ * Defaults to "refs/notes/commits".
6065
+ */
6066
+ notesRef?: string
6067
+ }
6068
+
5814
6069
  /**
5815
6070
  * - `Unmodified` : No changes.
5816
6071
  * - `Added` : Entry does not exist in an old version.
@@ -6250,6 +6505,10 @@ export type FileMode = 'Unreadable'|
6250
6505
  */
6251
6506
  export declare function findGlobalConfigPath(): string | null
6252
6507
 
6508
+ export interface FindNoteOptions {
6509
+ notesRef?: string
6510
+ }
6511
+
6253
6512
  /**
6254
6513
  * Locate the path to the system configuration file.
6255
6514
  *
@@ -6722,6 +6981,11 @@ export interface MergePreference {
6722
6981
  */
6723
6982
  export declare function normalizeReferenceName(refname: string, format?: number | undefined | null): string | null
6724
6983
 
6984
+ export interface NoteIterItem {
6985
+ noteId: string
6986
+ annotatedId: string
6987
+ }
6988
+
6725
6989
  /**
6726
6990
  * - `Any` : Any kind of git object
6727
6991
  * - `Commit` : An object which corresponds to a git commit
package/index.js CHANGED
@@ -591,6 +591,8 @@ module.exports.GitObject = nativeBinding.GitObject
591
591
  module.exports.Index = nativeBinding.Index
592
592
  module.exports.IndexEntries = nativeBinding.IndexEntries
593
593
  module.exports.Mailmap = nativeBinding.Mailmap
594
+ module.exports.Note = nativeBinding.Note
595
+ module.exports.Notes = nativeBinding.Notes
594
596
  module.exports.Rebase = nativeBinding.Rebase
595
597
  module.exports.Reference = nativeBinding.Reference
596
598
  module.exports.Remote = nativeBinding.Remote
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-git",
3
- "version": "0.5.0-next.161+c7e747f",
3
+ "version": "0.5.0-next.163+9aa9566",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -54,15 +54,15 @@
54
54
  "vitest": "^3.0.5"
55
55
  },
56
56
  "optionalDependencies": {
57
- "es-git-darwin-x64": "0.5.0-next.161+c7e747f",
58
- "es-git-darwin-arm64": "0.5.0-next.161+c7e747f",
59
- "es-git-win32-x64-msvc": "0.5.0-next.161+c7e747f",
60
- "es-git-win32-arm64-msvc": "0.5.0-next.161+c7e747f",
61
- "es-git-linux-x64-gnu": "0.5.0-next.161+c7e747f",
62
- "es-git-linux-x64-musl": "0.5.0-next.161+c7e747f",
63
- "es-git-android-arm64": "0.5.0-next.161+c7e747f",
64
- "es-git-linux-arm64-gnu": "0.5.0-next.161+c7e747f",
65
- "es-git-linux-arm64-musl": "0.5.0-next.161+c7e747f",
66
- "es-git-android-arm-eabi": "0.5.0-next.161+c7e747f"
57
+ "es-git-darwin-x64": "0.5.0-next.163+9aa9566",
58
+ "es-git-darwin-arm64": "0.5.0-next.163+9aa9566",
59
+ "es-git-win32-x64-msvc": "0.5.0-next.163+9aa9566",
60
+ "es-git-win32-arm64-msvc": "0.5.0-next.163+9aa9566",
61
+ "es-git-linux-x64-gnu": "0.5.0-next.163+9aa9566",
62
+ "es-git-linux-x64-musl": "0.5.0-next.163+9aa9566",
63
+ "es-git-android-arm64": "0.5.0-next.163+9aa9566",
64
+ "es-git-linux-arm64-gnu": "0.5.0-next.163+9aa9566",
65
+ "es-git-linux-arm64-musl": "0.5.0-next.163+9aa9566",
66
+ "es-git-android-arm-eabi": "0.5.0-next.163+9aa9566"
67
67
  }
68
68
  }