es-git 0.5.0-next.165 → 0.5.0-next.167

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 +197 -36
  2. package/index.js +1 -0
  3. package/package.json +11 -11
package/index.d.ts CHANGED
@@ -1464,6 +1464,23 @@ export declare class DiffStats {
1464
1464
  * [1]: https://git-scm.com/book/en/Git-Internals-Git-Objects
1465
1465
  */
1466
1466
  export declare class GitObject {
1467
+ /**
1468
+ * Describes a commit
1469
+ *
1470
+ * Performs a describe operation on this commitish object.
1471
+ *
1472
+ * @category GitObject/Methods
1473
+ * @signature
1474
+ * ```ts
1475
+ * class Object {
1476
+ * describe(options?: DescribeOptions | null | undefined): Describe;
1477
+ * }
1478
+ * ```
1479
+ *
1480
+ * @param {DescribeOptions} [options] - Options for describe operation.
1481
+ * @returns Instance of describe.
1482
+ */
1483
+ describe(options?: DescribeOptions | undefined | null): Describe
1467
1484
  /**
1468
1485
  * Get the id (SHA1) of a repository object.
1469
1486
  *
@@ -1552,23 +1569,6 @@ export declare class GitObject {
1552
1569
  * @returns Returns `null` if the object is not actually a commit.
1553
1570
  */
1554
1571
  asCommit(): Commit | null
1555
- /**
1556
- * Describes a commit
1557
- *
1558
- * Performs a describe operation on this commitish object.
1559
- *
1560
- * @category GitObject/Methods
1561
- * @signature
1562
- * ```ts
1563
- * class Object {
1564
- * describe(options?: DescribeOptions | null | undefined): Describe;
1565
- * }
1566
- * ```
1567
- *
1568
- * @param {DescribeOptions} [options] - Options for describe operation.
1569
- * @returns Instance of describe.
1570
- */
1571
- describe(options?: DescribeOptions | undefined | null): Describe
1572
1572
  }
1573
1573
 
1574
1574
  /**
@@ -2640,6 +2640,43 @@ export declare class Repository {
2640
2640
  * @returns An Annotated Commit created from `FETCH_HEAD`.
2641
2641
  */
2642
2642
  getAnnotatedCommitFromFetchHead(branchName: string, remoteUrl: string, id: string): AnnotatedCommit
2643
+ /**
2644
+ * Apply a Diff to the given repo, making changes directly in the working directory, the index, or both.
2645
+ *
2646
+ * @category Repository/Methods
2647
+ * ```ts
2648
+ * class Repository {
2649
+ * apply(diff: Diff, location: ApplyLocation, options?: ApplyOptions | null | undefined): void;
2650
+ * }
2651
+ * ```
2652
+ *
2653
+ * @param {Diff} diff - The diff to apply
2654
+ * @param {ApplyLocation} location - The location to apply
2655
+ * @param {ApplyOptions} [options] - The options for the apply
2656
+ */
2657
+ apply(diff: Diff, location: ApplyLocation, options?: ApplyOptions | undefined | null): void
2658
+ /**
2659
+ * Apply a Diff to the provided tree, and return the resulting Index.
2660
+ *
2661
+ * @category Repository/Methods
2662
+ * @signature
2663
+ * ```ts
2664
+ * class Repository {
2665
+ * applyToTree(
2666
+ * tree: Tree,
2667
+ * diff: Diff,
2668
+ * options?: ApplyOptions | null | undefined
2669
+ * ): Index;
2670
+ * }
2671
+ * ```
2672
+ *
2673
+ * @param {Tree} tree - The tree to apply the diff to
2674
+ * @param {Diff} diff - The diff to apply
2675
+ * @param {ApplyOptions} [options] - The options for the apply
2676
+ *
2677
+ * @returns The postimage of the application
2678
+ */
2679
+ applyToTree(tree: Tree, diff: Diff, options?: ApplyOptions | undefined | null): Index
2643
2680
  /**
2644
2681
  * Creates a blame object for the file at the given path
2645
2682
  *
@@ -2800,6 +2837,98 @@ export declare class Repository {
2800
2837
  * @param {CheckoutOptions} [options] - Options for checkout.
2801
2838
  */
2802
2839
  checkoutTree(treeish: GitObject, options?: CheckoutOptions | undefined | null): void
2840
+ /**
2841
+ * Cherrypicks the given commit onto HEAD and updates the working tree and index.
2842
+ * This method prepares the index and tree as if the commit were applied, but does not actually make a new commit.
2843
+ *
2844
+ * @category Repository/Methods
2845
+ * @signature
2846
+ * ```ts
2847
+ * class Repository {
2848
+ * cherrypick(
2849
+ * commit: Commit,
2850
+ * options?: CherrypickOptions | undefined | null,
2851
+ * ): void;
2852
+ * }
2853
+ * ```
2854
+ *
2855
+ * @param {Commit} commit - The commit to cherrypick.
2856
+ * @param {CherrypickOptions} [options] - Options for the cherrypick operation.
2857
+ * @throws {Error} If the commit is a merge commit and no mainline is specified.
2858
+ * @throws {Error} If there are conflicts during the cherrypick operation.
2859
+ *
2860
+ * @example
2861
+ * ```ts
2862
+ * import { openRepository } from 'es-git';
2863
+ *
2864
+ * const repo = await openRepository('./path/to/repo');
2865
+ * const cherrypickCommit = repo.getCommit('cherrypick-commit');
2866
+ *
2867
+ * // Cherrypick the commit onto HEAD and working tree
2868
+ * repo.cherrypick(cherrypickCommit);
2869
+ * repo.cleanupState();
2870
+ *
2871
+ * // Cherrypick the commit against our commit selecting the first parent as mainline (This is necessary because, for merge commits, there is ambiguity about which side of the merge should be treated as the baseline.)
2872
+ * repo.cherrypick(cherrypickCommit, { mainline: 1 });
2873
+ * repo.cleanupState();
2874
+ *
2875
+ * // Prevent working tree changes (dry run) but compute conflicts
2876
+ * repo.cherrypick(cherrypickCommit, { checkoutOptions: { dryRun: true } });
2877
+ * repo.cleanupState();
2878
+ *
2879
+ * // Cherrypick the commit against our commit selecting the first parent as mainline and prevent working tree changes (dry run) but compute conflicts
2880
+ * repo.cherrypick(cherrypickCommit, { mainline: 1, checkoutOptions: { dryRun: true } });
2881
+ * repo.cleanupState();
2882
+ * ```
2883
+ */
2884
+ cherrypick(commit: Commit, options?: CherrypickOptions | undefined | null): void
2885
+ /**
2886
+ * Applies a cherrypick of `cherrypick_commit` against `our_commit` and returns the resulting Index,
2887
+ * without modifying the working directory or repository state.
2888
+ * This method does not write any changes to disk or update HEAD.
2889
+ * it is useful for computing what the cherrypick result would look like without actually applying it.
2890
+ *
2891
+ * @category Repository/Methods
2892
+ * @signature
2893
+ * ```ts
2894
+ * class Repository {
2895
+ * cherrypickCommit(
2896
+ * cherrypickCommit: Commit,
2897
+ * ourCommit: Commit,
2898
+ * mainline: number,
2899
+ * mergeOptions?: MergeOptions | undefined | null,
2900
+ * ): Index;
2901
+ * }
2902
+ * ```
2903
+ *
2904
+ * @param {Commit} cherrypickCommit - The commit to cherrypick.
2905
+ * @param {Commit} ourCommit - The commit to cherrypick against (usually HEAD).
2906
+ * @param {number} mainline - The parent of the cherrypick commit, if it is a merge (1-based).
2907
+ * @param {MergeOptions} [mergeOptions] - Options for merge conflict resolution.
2908
+ * @returns The index result.
2909
+ * @throws {Error} If the cherrypick commit is a merge and mainline is 0.
2910
+ * @throws {Error} If there are conflicts and failOnConflict is true (default).
2911
+ *
2912
+ * @example
2913
+ * ```ts
2914
+ * // This is an example for cherrypick_commit
2915
+ * import { openRepository } from "es-git";
2916
+ *
2917
+ * const repo = await openRepository("./path/to/repo");
2918
+ * const cherry = repo.getCommit("cherrypick-commit");
2919
+ * const target = repo.getCommit("onto-commit");
2920
+ *
2921
+ * // Returns the Index resulting from the cherrypick in memory,
2922
+ * // without affecting HEAD or the working tree.
2923
+ * // The mainline parameter indicates which parent to use as the baseline,
2924
+ * // For merge commits, mainline specifies which parent to use as baseline (1 or 2).
2925
+ * // For normal (non-merge) commits, use mainline 0.
2926
+ * const idx = repo.cherrypickCommit(cherry, target, 0);
2927
+ *
2928
+ * // You can check for conflicts with idx.hasConflicts()
2929
+ * ```
2930
+ */
2931
+ cherrypickCommit(cherrypickCommit: Commit, ourCommit: Commit, mainline: number, mergeOptions?: MergeOptions | undefined | null): Index
2803
2932
  /**
2804
2933
  * Lookup a reference to one of the commits in a repository.
2805
2934
  *
@@ -2872,6 +3001,25 @@ export declare class Repository {
2872
3001
  * (if they are available).
2873
3002
  */
2874
3003
  config(): Config
3004
+ /**
3005
+ * Describes a commit
3006
+ *
3007
+ * Performs a describe operation on the current commit and the worktree.
3008
+ * After performing a describe on `HEAD`, a status is run and description is
3009
+ * considered to be dirty if there are.
3010
+ *
3011
+ * @category Repository/Methods
3012
+ * @signature
3013
+ * ```ts
3014
+ * class Repository {
3015
+ * describe(options?: DescribeOptions | null | undefined): Describe;
3016
+ * }
3017
+ * ```
3018
+ *
3019
+ * @param {DescribeOptions} [options] - Options for describe operation.
3020
+ * @returns Instance of describe.
3021
+ */
3022
+ describe(options?: DescribeOptions | undefined | null): Describe
2875
3023
  /**
2876
3024
  * Create a diff with the difference between two tree objects.
2877
3025
  *
@@ -4584,25 +4732,6 @@ export declare class Repository {
4584
4732
  * @returns If it does not exist, returns `null`.
4585
4733
  */
4586
4734
  findTree(oid: string): Tree | null
4587
- /**
4588
- * Describes a commit
4589
- *
4590
- * Performs a describe operation on the current commit and the worktree.
4591
- * After performing a describe on `HEAD`, a status is run and description is
4592
- * considered to be dirty if there are.
4593
- *
4594
- * @category Repository/Methods
4595
- * @signature
4596
- * ```ts
4597
- * class Repository {
4598
- * describe(options?: DescribeOptions | null | undefined): Describe;
4599
- * }
4600
- * ```
4601
- *
4602
- * @param {DescribeOptions} [options] - Options for describe operation.
4603
- * @returns Instance of describe.
4604
- */
4605
- describe(options?: DescribeOptions | undefined | null): Describe
4606
4735
  }
4607
4736
 
4608
4737
  /**
@@ -5581,6 +5710,23 @@ export interface AmendOptions {
5581
5710
  messageEncoding?: string
5582
5711
  }
5583
5712
 
5713
+ /**
5714
+ * Possible application locations for git_apply
5715
+ * see <https://libgit2.org/libgit2/#HEAD/type/git_apply_options>
5716
+ */
5717
+ export type ApplyLocation = /** Apply the patch to the workdir */
5718
+ 'WorkDir'|
5719
+ /** Apply the patch to the index */
5720
+ 'Index'|
5721
+ /** Apply the patch to both the working directory and the index */
5722
+ 'Both';
5723
+
5724
+ /** Options to specify when applying a diff */
5725
+ export interface ApplyOptions {
5726
+ /** Don't actually make changes, just test that the patch applies. */
5727
+ check?: boolean
5728
+ }
5729
+
5584
5730
  /**
5585
5731
  * - `Unspecified` : Use the setting from the remote's configuration
5586
5732
  * - `Auto` : Ask the server for tags pointing to objects we're already downloading
@@ -5828,6 +5974,21 @@ export interface CheckoutOptions {
5828
5974
  theirLabel?: string
5829
5975
  }
5830
5976
 
5977
+ /** Options for cherrypick behavior. */
5978
+ export interface CherrypickOptions {
5979
+ /**
5980
+ * Parent number for merge commits (1-based).
5981
+ *
5982
+ * When cherrypicking a merge commit, the mainline parent is the one you want to
5983
+ * cherrypick from. The mainline is the branch from which the merge was made.
5984
+ */
5985
+ mainline?: number
5986
+ /** Options for merge resolution when cherrypicking a merge commit. */
5987
+ mergeOptions?: MergeOptions
5988
+ /** Options for checkout behavior when updating working directory. */
5989
+ checkoutOptions?: CheckoutOptions
5990
+ }
5991
+
5831
5992
  /**
5832
5993
  * Clone a remote repository.
5833
5994
  *
package/index.js CHANGED
@@ -609,6 +609,7 @@ module.exports.Tag = nativeBinding.Tag
609
609
  module.exports.Tree = nativeBinding.Tree
610
610
  module.exports.TreeEntry = nativeBinding.TreeEntry
611
611
  module.exports.TreeIter = nativeBinding.TreeIter
612
+ module.exports.ApplyLocation = nativeBinding.ApplyLocation
612
613
  module.exports.AutotagOption = nativeBinding.AutotagOption
613
614
  module.exports.BranchType = nativeBinding.BranchType
614
615
  module.exports.cloneRepository = nativeBinding.cloneRepository
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-git",
3
- "version": "0.5.0-next.165+a053e66",
3
+ "version": "0.5.0-next.167+3d819b8",
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.165+a053e66",
58
- "es-git-darwin-arm64": "0.5.0-next.165+a053e66",
59
- "es-git-win32-x64-msvc": "0.5.0-next.165+a053e66",
60
- "es-git-win32-arm64-msvc": "0.5.0-next.165+a053e66",
61
- "es-git-linux-x64-gnu": "0.5.0-next.165+a053e66",
62
- "es-git-linux-x64-musl": "0.5.0-next.165+a053e66",
63
- "es-git-android-arm64": "0.5.0-next.165+a053e66",
64
- "es-git-linux-arm64-gnu": "0.5.0-next.165+a053e66",
65
- "es-git-linux-arm64-musl": "0.5.0-next.165+a053e66",
66
- "es-git-android-arm-eabi": "0.5.0-next.165+a053e66"
57
+ "es-git-darwin-x64": "0.5.0-next.167+3d819b8",
58
+ "es-git-darwin-arm64": "0.5.0-next.167+3d819b8",
59
+ "es-git-win32-x64-msvc": "0.5.0-next.167+3d819b8",
60
+ "es-git-win32-arm64-msvc": "0.5.0-next.167+3d819b8",
61
+ "es-git-linux-x64-gnu": "0.5.0-next.167+3d819b8",
62
+ "es-git-linux-x64-musl": "0.5.0-next.167+3d819b8",
63
+ "es-git-android-arm64": "0.5.0-next.167+3d819b8",
64
+ "es-git-linux-arm64-gnu": "0.5.0-next.167+3d819b8",
65
+ "es-git-linux-arm64-musl": "0.5.0-next.167+3d819b8",
66
+ "es-git-android-arm-eabi": "0.5.0-next.167+3d819b8"
67
67
  }
68
68
  }