es-git 0.2.0-next.109 → 0.2.0-next.111

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 +5 -1
  3. package/package.json +11 -11
package/index.d.ts CHANGED
@@ -3,6 +3,46 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
+ /**
7
+ * Ensure the branch name is well-formed.
8
+ *
9
+ * @category Branch
10
+ * @signature
11
+ * ```ts
12
+ * function isValidBranchName(name: string): boolean;
13
+ * ```
14
+ *
15
+ * @param {string} name - Branch name to check is valid.
16
+ * @returns Returns `true` if the given branch name is well-formed.
17
+ */
18
+ export declare function isValidBranchName(name: string): boolean
19
+ export interface BranchesItem {
20
+ type: BranchType
21
+ name: string
22
+ }
23
+ /**
24
+ * - `Local` : A local branch not on a remote.
25
+ * - `Remote` : A branch for a remote.
26
+ */
27
+ export type BranchType = 'Local' | 'Remote';
28
+ export interface BranchRenameOptions {
29
+ /**
30
+ * If the force flag is not enabled, and there's already a branch with
31
+ * the given name, the renaming will fail.
32
+ */
33
+ force?: boolean
34
+ }
35
+ export interface CreateBranchOptions {
36
+ /**
37
+ * If `force` is true and a reference already exists with the given name,
38
+ * it'll be replaced.
39
+ */
40
+ force?: boolean
41
+ }
42
+ export interface BranchesFilter {
43
+ /** Branch type to filter. */
44
+ type?: BranchType
45
+ }
6
46
  export interface CommitOptions {
7
47
  updateRef?: string
8
48
  /**
@@ -1446,6 +1486,148 @@ export declare class Blob {
1446
1486
  */
1447
1487
  size(): bigint
1448
1488
  }
1489
+ /**
1490
+ * A structure to represent a git [branch][1]
1491
+ *
1492
+ * A branch is currently just a wrapper to an underlying `Reference`. The
1493
+ * reference can be accessed through the `get` and `into_reference` methods.
1494
+ *
1495
+ * [1]: http://git-scm.com/book/en/Git-Branching-What-a-Branch-Is
1496
+ */
1497
+ export declare class Branch {
1498
+ /**
1499
+ * Get the OID pointed to by a reference which is this branch.
1500
+ *
1501
+ * @category Branch/Methods
1502
+ * @signature
1503
+ * ```ts
1504
+ * class Branch {
1505
+ * referenceTarget(): string | null;
1506
+ * }
1507
+ * ```
1508
+ *
1509
+ * @returns The OID pointed to by a reference which is this branch.
1510
+ */
1511
+ referenceTarget(): string | null
1512
+ /**
1513
+ * Delete an existing branch reference.
1514
+ *
1515
+ * @category Branch/Methods
1516
+ * @signature
1517
+ * ```ts
1518
+ * class Branch {
1519
+ * delete(): void;
1520
+ * }
1521
+ * ```
1522
+ */
1523
+ delete(): void
1524
+ /**
1525
+ * Determine if the current local branch is pointed at by `HEAD`.
1526
+ *
1527
+ * @category Branch/Methods
1528
+ * @signature
1529
+ * ```ts
1530
+ * class Branch {
1531
+ * isHead(): boolean;
1532
+ * }
1533
+ * ```
1534
+ *
1535
+ * @returns Returns `true` if the current local branch is pointed at by `HEAD`.
1536
+ */
1537
+ isHead(): boolean
1538
+ /**
1539
+ * Move/rename an existing local branch reference.
1540
+ *
1541
+ * @category Branch/Methods
1542
+ * @signature
1543
+ * ```ts
1544
+ * class Branch {
1545
+ * rename(newBranchName: string, options?: BranchRenameOptions | null | undefined): Branch;
1546
+ * }
1547
+ * ```
1548
+ *
1549
+ * @param {string} newBranchName - Branch name to move/rename.
1550
+ * @param {BranchRenameOptions} [options] - Options for move/rename branch.
1551
+ * @returns Move/renamed branch.
1552
+ */
1553
+ rename(newBranchName: string, options?: BranchRenameOptions | undefined | null): Branch
1554
+ /**
1555
+ * Return the name of the given local or remote branch.
1556
+ *
1557
+ * @category Branch/Methods
1558
+ * @signature
1559
+ * ```ts
1560
+ * class Branch {
1561
+ * name(): string;
1562
+ * }
1563
+ * ```
1564
+ *
1565
+ * @returns The name of the given local or remote branch.
1566
+ * @throws If the name is not valid utf-8.
1567
+ */
1568
+ name(): string
1569
+ /**
1570
+ * Return the reference supporting the remote tracking branch, given a
1571
+ * local branch reference.
1572
+ *
1573
+ * @category Branch/Methods
1574
+ * @signature
1575
+ * ```ts
1576
+ * class Branch {
1577
+ * findUpstream(): Branch | null;
1578
+ * }
1579
+ * ```
1580
+ *
1581
+ * @returns The reference supporting the remote tacking branch.
1582
+ */
1583
+ findUpstream(): Branch | null
1584
+ /**
1585
+ * Return the reference supporting the remote tracking branch, given a
1586
+ * local branch reference.
1587
+ *
1588
+ * @category Branch/Methods
1589
+ * @signature
1590
+ * ```ts
1591
+ * class Branch {
1592
+ * getUpstream(): Branch;
1593
+ * }
1594
+ * ```
1595
+ *
1596
+ * @returns The reference supporting the remote tacking branch.
1597
+ * @throws Throws error if upstream does not exist.
1598
+ */
1599
+ getUpstream(): Branch
1600
+ /**
1601
+ * Set the upstream configuration for a given local branch.
1602
+ *
1603
+ * @category Branch/Methods
1604
+ * @signature
1605
+ * ```ts
1606
+ * class Branch {
1607
+ * setUpstream(upstreamName: string): void;
1608
+ * }
1609
+ * ```
1610
+ *
1611
+ * @param {string} upstreamName - Branch name to set as upstream.
1612
+ */
1613
+ setUpstream(upstreamName: string): void
1614
+ /**
1615
+ * Unset the upstream configuration for a given local branch.
1616
+ *
1617
+ * @category Branch/Methods
1618
+ * @signature
1619
+ * ```ts
1620
+ * class Branch {
1621
+ * unsetUpstream(): void;
1622
+ * }
1623
+ * ```
1624
+ */
1625
+ unsetUpstream(): void
1626
+ }
1627
+ /** An iterator over the branches inside of a repository. */
1628
+ export declare class Branches {
1629
+ [Symbol.iterator](): Iterator<BranchesItem, void, void>
1630
+ }
1449
1631
  /** A class to represent a git commit. */
1450
1632
  export declare class Commit {
1451
1633
  /**
@@ -3231,6 +3413,88 @@ export declare class Remote {
3231
3413
  * This class corresponds to a git repository in libgit2.
3232
3414
  */
3233
3415
  export declare class Repository {
3416
+ /**
3417
+ * Create a new branch pointing at a target commit
3418
+ *
3419
+ * A new direct reference will be created pointing to this target commit.
3420
+ *
3421
+ * @category Repository/Methods
3422
+ * @signature
3423
+ * ```ts
3424
+ * class Repository {
3425
+ * createBranch(
3426
+ * branchName: string,
3427
+ * target: Commit,
3428
+ * options?: CreateBranchOptions | null | undefined,
3429
+ * ): Branch;
3430
+ * }
3431
+ * ```
3432
+ *
3433
+ * @param {string} branchName - Name for the new branch.
3434
+ * @param {Commit} target - Target commit which will be pointed by this branch.
3435
+ * @param {CreateBranchOptions} [options] - Options for create branch.
3436
+ * @returns {Branch} Newly created branch.
3437
+ */
3438
+ createBranch(branchName: string, target: Commit, options?: CreateBranchOptions | undefined | null): Branch
3439
+ /**
3440
+ * Lookup a branch by its name in a repository.
3441
+ *
3442
+ * @category Repository/Methods
3443
+ * @signature
3444
+ * ```ts
3445
+ * class Repository {
3446
+ * findBranch(name: string, branchType: BranchType): Branch | null;
3447
+ * }
3448
+ * ```
3449
+ *
3450
+ * @param {string} name - A branch name.
3451
+ * @param {BranchType} branchType - Branch type to lookup.
3452
+ * @returns A found branch.
3453
+ */
3454
+ findBranch(name: string, branchType: BranchType): Branch | null
3455
+ /**
3456
+ * Lookup a branch by its name in a repository.
3457
+ *
3458
+ * @category Repository/Methods
3459
+ * @signature
3460
+ * ```ts
3461
+ * class Repository {
3462
+ * getBranch(name: string, branchType: BranchType): Branch;
3463
+ * }
3464
+ * ```
3465
+ *
3466
+ * @param {string} name - A branch name.
3467
+ * @param {BranchType} branchType - Branch type to lookup.
3468
+ * @returns A found branch.
3469
+ * @throws Throws error if branch does not exist.
3470
+ */
3471
+ getBranch(name: string, branchType: BranchType): Branch
3472
+ /**
3473
+ * Create an iterator which loops over the requested branches.
3474
+ *
3475
+ * @category Repository/Methods
3476
+ * @signature
3477
+ * ```ts
3478
+ * class Repository {
3479
+ * branches(filter?: BranchesFilter | null | undefined): Branches;
3480
+ * }
3481
+ * ```
3482
+ *
3483
+ * @param {BranchesFilter} [filter] - Filter for the branches iterator.
3484
+ * @returns An iterator which loops over the requested branches.
3485
+ * @example
3486
+ * ```ts
3487
+ * import { openRepository } from 'es-git';
3488
+ *
3489
+ * const repo = await openRepository('/path/to/repo');
3490
+ *
3491
+ * for (const branch of repo.branches()) {
3492
+ * console.log(branch.type); // "Local"
3493
+ * console.log(branch.name); // "main"
3494
+ * }
3495
+ * ```
3496
+ */
3497
+ branches(filter?: BranchesFilter | undefined | null): Branches
3234
3498
  /**
3235
3499
  * Lookup a reference to one of the commits in a repository.
3236
3500
  *
package/index.js CHANGED
@@ -310,9 +310,13 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { Blob, 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 { 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
315
  module.exports.Blob = Blob
316
+ module.exports.isValidBranchName = isValidBranchName
317
+ module.exports.Branch = Branch
318
+ module.exports.Branches = Branches
319
+ module.exports.BranchType = BranchType
316
320
  module.exports.Commit = Commit
317
321
  module.exports.ConfigLevel = ConfigLevel
318
322
  module.exports.ConfigEntries = ConfigEntries
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-git",
3
- "version": "0.2.0-next.109+3bc3836",
3
+ "version": "0.2.0-next.111+c9bdb8e",
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.109+3bc3836",
61
- "es-git-darwin-arm64": "0.2.0-next.109+3bc3836",
62
- "es-git-win32-x64-msvc": "0.2.0-next.109+3bc3836",
63
- "es-git-win32-arm64-msvc": "0.2.0-next.109+3bc3836",
64
- "es-git-linux-x64-gnu": "0.2.0-next.109+3bc3836",
65
- "es-git-linux-x64-musl": "0.2.0-next.109+3bc3836",
66
- "es-git-android-arm64": "0.2.0-next.109+3bc3836",
67
- "es-git-linux-arm64-gnu": "0.2.0-next.109+3bc3836",
68
- "es-git-linux-arm64-musl": "0.2.0-next.109+3bc3836",
69
- "es-git-android-arm-eabi": "0.2.0-next.109+3bc3836"
60
+ "es-git-darwin-x64": "0.2.0-next.111+c9bdb8e",
61
+ "es-git-darwin-arm64": "0.2.0-next.111+c9bdb8e",
62
+ "es-git-win32-x64-msvc": "0.2.0-next.111+c9bdb8e",
63
+ "es-git-win32-arm64-msvc": "0.2.0-next.111+c9bdb8e",
64
+ "es-git-linux-x64-gnu": "0.2.0-next.111+c9bdb8e",
65
+ "es-git-linux-x64-musl": "0.2.0-next.111+c9bdb8e",
66
+ "es-git-android-arm64": "0.2.0-next.111+c9bdb8e",
67
+ "es-git-linux-arm64-gnu": "0.2.0-next.111+c9bdb8e",
68
+ "es-git-linux-arm64-musl": "0.2.0-next.111+c9bdb8e",
69
+ "es-git-android-arm-eabi": "0.2.0-next.111+c9bdb8e"
70
70
  }
71
71
  }