es-git 0.2.0-next.112 → 0.2.0-next.114

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 +235 -0
  2. package/index.js +4 -1
  3. package/package.json +11 -11
package/index.d.ts CHANGED
@@ -3,6 +3,72 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
+ /**
7
+ * Represents a hunk of a blame operation, which is a range of lines
8
+ * and information about who last modified them.
9
+ */
10
+ export interface BlameHunk {
11
+ /** The oid of the commit where this line was last changed. */
12
+ finalCommitId: string
13
+ /** The 1-based line number in the final file where this hunk starts. */
14
+ finalStartLineNumber: number
15
+ /** The number of lines in this hunk. */
16
+ linesInHunk: number
17
+ /** The signature of the commit where this line was last changed. */
18
+ finalSignature?: Signature
19
+ /** The path to the file where this line was originally written. */
20
+ path?: string
21
+ /** The 1-based line number in the original file where this hunk starts. */
22
+ origStartLineNumber: number
23
+ /** The oid of the commit where this line was originally written. */
24
+ origCommitId: string
25
+ /** The signature of the commit where this line was originally written. */
26
+ origSignature?: Signature
27
+ /**
28
+ * True if the hunk has been determined to be a boundary commit (the commit
29
+ * when the file was first introduced to the repository).
30
+ */
31
+ isBoundary: boolean
32
+ }
33
+ /** Options for controlling blame behavior */
34
+ export interface BlameOptions {
35
+ /** The minimum line number to blame (1-based index) */
36
+ minLine?: number
37
+ /** The maximum line number to blame (1-based index) */
38
+ maxLine?: number
39
+ /**
40
+ * The oid of the newest commit to consider. The blame algorithm will stop
41
+ * when this commit is reached.
42
+ */
43
+ newestCommit?: string
44
+ /**
45
+ * The oid of the oldest commit to consider. The blame algorithm will
46
+ * stop when this commit is reached.
47
+ */
48
+ oldestCommit?: string
49
+ /**
50
+ * The path to the file being worked on. Path has to be relative to the
51
+ * repo root.
52
+ */
53
+ path?: string
54
+ /**
55
+ * Track lines that have moved within a file. This is the git-blame -M
56
+ * option.
57
+ */
58
+ trackLinesMovement?: boolean
59
+ /** Restrict search to commits reachable following only first parents. */
60
+ firstParent?: boolean
61
+ /** Ignore whitespace differences. */
62
+ ignoreWhitespace?: boolean
63
+ /** Track lines that have been copied from another file that exists in any commit. */
64
+ trackCopiesAnyCommitCopies?: boolean
65
+ /** Track lines that have been copied from another file that exists in the same commit. */
66
+ trackCopiesSameCommitCopies?: boolean
67
+ /** Track lines that have moved across files in the same commit. */
68
+ trackCopiesSameCommitMoves?: boolean
69
+ /** Use mailmap file to map author and committer names and email addresses to canonical real names and email addresses. */
70
+ useMailmap?: boolean
71
+ }
6
72
  /**
7
73
  * Ensure the branch name is well-formed.
8
74
  *
@@ -1420,6 +1486,146 @@ export interface CreateLightweightTagOptions {
1420
1486
  * - `PostOrder` : Runs the traversal in post-order.
1421
1487
  */
1422
1488
  export type TreeWalkMode = 'PreOrder' | 'PostOrder';
1489
+ /** A wrapper around git2::Blame providing Node.js bindings */
1490
+ export declare class Blame {
1491
+ /**
1492
+ * Gets the number of hunks in the blame result
1493
+ *
1494
+ * @category Blame/Methods
1495
+ * @signature
1496
+ * ```ts
1497
+ * class Blame {
1498
+ * getHunkCount(): number;
1499
+ * }
1500
+ * ```
1501
+ *
1502
+ * @returns The number of hunks in the blame result
1503
+ */
1504
+ getHunkCount(): number
1505
+ /**
1506
+ * Checks if the blame result is empty
1507
+ *
1508
+ * @category Blame/Methods
1509
+ * @signature
1510
+ * ```ts
1511
+ * class Blame {
1512
+ * isEmpty(): boolean;
1513
+ * }
1514
+ * ```
1515
+ *
1516
+ * @returns True if the blame result contains no hunks
1517
+ */
1518
+ isEmpty(): boolean
1519
+ /**
1520
+ * Gets blame information for the specified index
1521
+ *
1522
+ * @category Blame/Methods
1523
+ * @signature
1524
+ * ```ts
1525
+ * class Blame {
1526
+ * getHunkByIndex(index: number): BlameHunk;
1527
+ * }
1528
+ * ```
1529
+ *
1530
+ * @param {number} index - Index of the hunk to get (0-based)
1531
+ * @returns Blame information for the specified index
1532
+ * @throws If no hunk is found at the index
1533
+ */
1534
+ getHunkByIndex(index: number): BlameHunk
1535
+ /**
1536
+ * Gets blame information for the specified line
1537
+ *
1538
+ * @category Blame/Methods
1539
+ * @signature
1540
+ * ```ts
1541
+ * class Blame {
1542
+ * getHunkByLine(line: number): BlameHunk;
1543
+ * }
1544
+ * ```
1545
+ *
1546
+ * @param {number} line - Line number to get blame information for (1-based)
1547
+ * @returns Blame information for the specified line
1548
+ * @throws If no hunk is found for the line
1549
+ */
1550
+ getHunkByLine(line: number): BlameHunk
1551
+ /**
1552
+ * Gets all blame hunks as an iterator
1553
+ *
1554
+ * @category Blame/Methods
1555
+ * @signature
1556
+ * ```ts
1557
+ * class Blame {
1558
+ * iter(): Generator<BlameHunk>;
1559
+ * }
1560
+ * ```
1561
+ *
1562
+ * @returns Iterator of all blame hunks
1563
+ * @example
1564
+ * ```ts
1565
+ * // Using for...of loop
1566
+ * for (const hunk of blame.iter()) {
1567
+ * console.log(hunk.finalCommitId);
1568
+ * }
1569
+ *
1570
+ * // Using spread operator to collect all hunks
1571
+ * const hunks = [...blame.iter()];
1572
+ * ```
1573
+ */
1574
+ iter(): BlameHunks
1575
+ /**
1576
+ * Collects blame hunks by scanning file lines as an iterator
1577
+ *
1578
+ * @category Blame/Methods
1579
+ * @signature
1580
+ * ```ts
1581
+ * class Blame {
1582
+ * iterByLine(): Generator<BlameHunk>;
1583
+ * }
1584
+ * ```
1585
+ *
1586
+ * @returns Iterator of blame hunks collected by line scanning
1587
+ * @example
1588
+ * ```ts
1589
+ * // Using for...of loop
1590
+ * for (const hunk of blame.iterByLine()) {
1591
+ * console.log(hunk.finalCommitId);
1592
+ * }
1593
+ *
1594
+ * // Using spread operator to collect all hunks
1595
+ * const hunks = [...blame.iterByLine()];
1596
+ * ```
1597
+ */
1598
+ iterByLine(): BlameHunksByLine
1599
+ /**
1600
+ * Generates blame information from an in-memory buffer
1601
+ *
1602
+ * @category Blame/Methods
1603
+ * @signature
1604
+ * ```ts
1605
+ * class Blame {
1606
+ * buffer(buffer: Buffer): Blame;
1607
+ * }
1608
+ * ```
1609
+ *
1610
+ * @example
1611
+ * ```ts
1612
+ * const buffer = Buffer.from('modified content');
1613
+ * const bufferBlame = blame.buffer(buffer);
1614
+ * ```
1615
+ *
1616
+ * @param {Buffer} buffer - Buffer containing file content to blame
1617
+ * @returns A new Blame object for the buffer content
1618
+ */
1619
+ buffer(buffer: Buffer): Blame
1620
+ }
1621
+ /** An iterator over blame hunks. */
1622
+ export declare class BlameHunks {
1623
+ [Symbol.iterator](): Iterator<BlameHunk, void, void>
1624
+ }
1625
+ /** Iterator over blame hunks collected line by line. */
1626
+ export declare class BlameHunksByLine {
1627
+ [Symbol.iterator](): Iterator<BlameHunk, void, void>
1628
+ }
1423
1629
  /**
1424
1630
  * A class to represent a git [blob][1].
1425
1631
  * [1]: https://git-scm.com/book/en/Git-Internals-Git-Objects
@@ -3413,6 +3619,35 @@ export declare class Remote {
3413
3619
  * This class corresponds to a git repository in libgit2.
3414
3620
  */
3415
3621
  export declare class Repository {
3622
+ /**
3623
+ * Creates a blame object for the file at the given path
3624
+ *
3625
+ * @category Repository/Methods
3626
+ * @signature
3627
+ * ```ts
3628
+ * class Repository {
3629
+ * blameFile(path: string, options?: BlameOptions): Blame;
3630
+ * }
3631
+ * ```
3632
+ *
3633
+ * @example
3634
+ * ```ts
3635
+ * // Blame the entire file
3636
+ * const blame = repo.blameFile('path/to/file.js');
3637
+ *
3638
+ * // Blame a single line
3639
+ * const lineBlame = repo.blameFile('path/to/file.js', { minLine: 10, maxLine: 10 });
3640
+ *
3641
+ * // Blame a range of lines
3642
+ * const rangeBlame = repo.blameFile('path/to/file.js', { minLine: 5, maxLine: 15 });
3643
+ * ```
3644
+ *
3645
+ * @param {string} path - Path to the file to blame
3646
+ * @param {BlameOptions} [options] - Options to control blame behavior
3647
+ * @returns Blame object for the specified file
3648
+ * @throws If the file doesn't exist or can't be opened
3649
+ */
3650
+ blameFile(path: string, options?: BlameOptions | undefined | null): Blame
3416
3651
  /**
3417
3652
  * Create a new branch pointing at a target commit
3418
3653
  *
package/index.js CHANGED
@@ -310,8 +310,11 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { Blob, isValidBranchName, Branch, Branches, BranchType, Commit, ConfigLevel, ConfigEntries, Config, openConfig, openDefaultConfig, findGlobalConfigPath, findSystemConfigPath, findXdgConfigPath, parseConfigBool, parseConfigI32, parseConfigI64, DiffFlags, diffFlagsContains, DeltaType, DiffFormat, Diff, DiffStats, Deltas, DiffDelta, FileMode, DiffFile, IndexStage, Index, IndexEntries, ObjectType, GitObject, isValidOid, isZeroOid, zeroOid, hashObjectOid, hashFileOid, ReferenceType, Reference, isValidReferenceName, ReferenceFormat, normalizeReferenceName, Direction, CredentialType, FetchPrune, AutotagOption, RemoteRedirect, Remote, RepositoryState, RepositoryInitMode, Repository, initRepository, openRepository, discoverRepository, cloneRepository, RevparseMode, revparseModeContains, RevwalkSort, Revwalk, createSignature, isValidTagName, Tag, TreeWalkMode, Tree, TreeIter, TreeEntry } = nativeBinding
313
+ const { Blame, BlameHunks, BlameHunksByLine, Blob, isValidBranchName, Branch, Branches, BranchType, Commit, ConfigLevel, ConfigEntries, Config, openConfig, openDefaultConfig, findGlobalConfigPath, findSystemConfigPath, findXdgConfigPath, parseConfigBool, parseConfigI32, parseConfigI64, DiffFlags, diffFlagsContains, DeltaType, DiffFormat, Diff, DiffStats, Deltas, DiffDelta, FileMode, DiffFile, IndexStage, Index, IndexEntries, ObjectType, GitObject, isValidOid, isZeroOid, zeroOid, hashObjectOid, hashFileOid, ReferenceType, Reference, isValidReferenceName, ReferenceFormat, normalizeReferenceName, Direction, CredentialType, FetchPrune, AutotagOption, RemoteRedirect, Remote, RepositoryState, RepositoryInitMode, Repository, initRepository, openRepository, discoverRepository, cloneRepository, RevparseMode, revparseModeContains, RevwalkSort, Revwalk, createSignature, isValidTagName, Tag, TreeWalkMode, Tree, TreeIter, TreeEntry } = nativeBinding
314
314
 
315
+ module.exports.Blame = Blame
316
+ module.exports.BlameHunks = BlameHunks
317
+ module.exports.BlameHunksByLine = BlameHunksByLine
315
318
  module.exports.Blob = Blob
316
319
  module.exports.isValidBranchName = isValidBranchName
317
320
  module.exports.Branch = Branch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-git",
3
- "version": "0.2.0-next.112+95dab5f",
3
+ "version": "0.2.0-next.114+458013d",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -57,15 +57,15 @@
57
57
  "vitest": "^3.0.5"
58
58
  },
59
59
  "optionalDependencies": {
60
- "es-git-darwin-x64": "0.2.0-next.112+95dab5f",
61
- "es-git-darwin-arm64": "0.2.0-next.112+95dab5f",
62
- "es-git-win32-x64-msvc": "0.2.0-next.112+95dab5f",
63
- "es-git-win32-arm64-msvc": "0.2.0-next.112+95dab5f",
64
- "es-git-linux-x64-gnu": "0.2.0-next.112+95dab5f",
65
- "es-git-linux-x64-musl": "0.2.0-next.112+95dab5f",
66
- "es-git-android-arm64": "0.2.0-next.112+95dab5f",
67
- "es-git-linux-arm64-gnu": "0.2.0-next.112+95dab5f",
68
- "es-git-linux-arm64-musl": "0.2.0-next.112+95dab5f",
69
- "es-git-android-arm-eabi": "0.2.0-next.112+95dab5f"
60
+ "es-git-darwin-x64": "0.2.0-next.114+458013d",
61
+ "es-git-darwin-arm64": "0.2.0-next.114+458013d",
62
+ "es-git-win32-x64-msvc": "0.2.0-next.114+458013d",
63
+ "es-git-win32-arm64-msvc": "0.2.0-next.114+458013d",
64
+ "es-git-linux-x64-gnu": "0.2.0-next.114+458013d",
65
+ "es-git-linux-x64-musl": "0.2.0-next.114+458013d",
66
+ "es-git-android-arm64": "0.2.0-next.114+458013d",
67
+ "es-git-linux-arm64-gnu": "0.2.0-next.114+458013d",
68
+ "es-git-linux-arm64-musl": "0.2.0-next.114+458013d",
69
+ "es-git-android-arm-eabi": "0.2.0-next.114+458013d"
70
70
  }
71
71
  }