es-git 0.4.0-next.144 → 0.4.0-next.146
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 +138 -0
- package/package.json +11 -11
package/index.d.ts
CHANGED
|
@@ -1711,6 +1711,45 @@ export declare function discoverRepository(path: string, signal?: AbortSignal |
|
|
|
1711
1711
|
* ```
|
|
1712
1712
|
*/
|
|
1713
1713
|
export declare function cloneRepository(url: string, path: string, options?: RepositoryCloneOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Repository>
|
|
1714
|
+
/**
|
|
1715
|
+
* Options for revert behavior.
|
|
1716
|
+
*
|
|
1717
|
+
* Controls how a revert is performed when applying the inverse of a commit.
|
|
1718
|
+
*
|
|
1719
|
+
* @example
|
|
1720
|
+
* ```ts
|
|
1721
|
+
* import { openRepository } from 'es-git';
|
|
1722
|
+
*
|
|
1723
|
+
* const repo = await openRepository('./path/to/repo');
|
|
1724
|
+
* const head = repo.head().target()!;
|
|
1725
|
+
* const commit = repo.getCommit(head);
|
|
1726
|
+
*
|
|
1727
|
+
* // Simple revert
|
|
1728
|
+
* repo.revert(commit);
|
|
1729
|
+
* repo.cleanupState();
|
|
1730
|
+
*
|
|
1731
|
+
* // Revert a merge commit selecting the first parent as mainline
|
|
1732
|
+
* repo.revert(commit, { mainline: 1 });
|
|
1733
|
+
* repo.cleanupState();
|
|
1734
|
+
*
|
|
1735
|
+
* // Prevent working tree changes (dry run) but compute conflicts
|
|
1736
|
+
* repo.revert(commit, { checkoutOptions: { dryRun: true } });
|
|
1737
|
+
* repo.cleanupState();
|
|
1738
|
+
* ```
|
|
1739
|
+
*/
|
|
1740
|
+
export interface RevertOptions {
|
|
1741
|
+
/**
|
|
1742
|
+
* Parent number for merge commits (1-based).
|
|
1743
|
+
*
|
|
1744
|
+
* When reverting a merge commit, the mainline parent is the one you want to
|
|
1745
|
+
* revert to. The mainline is the branch into which the merge was made.
|
|
1746
|
+
*/
|
|
1747
|
+
mainline?: number
|
|
1748
|
+
/** Options for merge conflict resolution. */
|
|
1749
|
+
mergeOptions?: MergeOptions
|
|
1750
|
+
/** Options for checkout behavior when updating working directory. */
|
|
1751
|
+
checkoutOptions?: CheckoutOptions
|
|
1752
|
+
}
|
|
1714
1753
|
/**
|
|
1715
1754
|
* Flags for the revparse.
|
|
1716
1755
|
* - `Single` : The spec targeted a single object.
|
|
@@ -5433,6 +5472,16 @@ export declare class Repository {
|
|
|
5433
5472
|
* ```
|
|
5434
5473
|
*
|
|
5435
5474
|
* @returns The current state of this repository.
|
|
5475
|
+
*
|
|
5476
|
+
* @example
|
|
5477
|
+
* ```ts
|
|
5478
|
+
* import { openRepository } from 'es-git';
|
|
5479
|
+
*
|
|
5480
|
+
* const repo = await openRepository('./repo');
|
|
5481
|
+
* console.log(repo.state()); // e.g., 'Clean'
|
|
5482
|
+
* // After a revert/merge/cherry-pick, state can be 'Revert'/'Merge' etc.
|
|
5483
|
+
* // Use repo.cleanupState() to return to 'Clean' when done handling.
|
|
5484
|
+
* ```
|
|
5436
5485
|
*/
|
|
5437
5486
|
state(): RepositoryState
|
|
5438
5487
|
/**
|
|
@@ -5597,8 +5646,97 @@ export declare class Repository {
|
|
|
5597
5646
|
* cleanupState(): void;
|
|
5598
5647
|
* }
|
|
5599
5648
|
* ```
|
|
5649
|
+
*
|
|
5650
|
+
* @example
|
|
5651
|
+
* ```ts
|
|
5652
|
+
* import { openRepository } from 'es-git';
|
|
5653
|
+
*
|
|
5654
|
+
* const repo = await openRepository('./repo');
|
|
5655
|
+
* // After revert or merge operations:
|
|
5656
|
+
* if (repo.state() !== 'Clean') {
|
|
5657
|
+
* repo.cleanupState();
|
|
5658
|
+
* }
|
|
5659
|
+
* ```
|
|
5600
5660
|
*/
|
|
5601
5661
|
cleanupState(): void
|
|
5662
|
+
/**
|
|
5663
|
+
* Reverts the given commit, applying the inverse of its changes to the
|
|
5664
|
+
* HEAD commit and the working directory.
|
|
5665
|
+
*
|
|
5666
|
+
* @category Repository/Methods
|
|
5667
|
+
* @signature
|
|
5668
|
+
* ```ts
|
|
5669
|
+
* class Repository {
|
|
5670
|
+
* revert(
|
|
5671
|
+
* commit: Commit,
|
|
5672
|
+
* options?: RevertOptions | undefined | null,
|
|
5673
|
+
* ): void;
|
|
5674
|
+
* }
|
|
5675
|
+
* ```
|
|
5676
|
+
*
|
|
5677
|
+
* @param {Commit} commit - The commit to revert.
|
|
5678
|
+
* @param {RevertOptions} [options] - Options for the revert operation.
|
|
5679
|
+
* @throws {Error} If the commit is a merge commit and no mainline is specified.
|
|
5680
|
+
* @throws {Error} If there are conflicts during the revert operation.
|
|
5681
|
+
*
|
|
5682
|
+
* @example
|
|
5683
|
+
* ```ts
|
|
5684
|
+
* import { openRepository } from 'es-git';
|
|
5685
|
+
*
|
|
5686
|
+
* const repo = await openRepository('./path/to/repo');
|
|
5687
|
+
* const last = repo.head().target()!;
|
|
5688
|
+
* const commit = repo.getCommit(last);
|
|
5689
|
+
*
|
|
5690
|
+
* // Revert and update working tree
|
|
5691
|
+
* repo.revert(commit);
|
|
5692
|
+
* repo.cleanupState();
|
|
5693
|
+
*
|
|
5694
|
+
* // Revert a merge commit: specify the mainline parent
|
|
5695
|
+
* // repo.revert(mergeCommit, { mainline: 1 });
|
|
5696
|
+
* // repo.cleanupState();
|
|
5697
|
+
* ```
|
|
5698
|
+
*/
|
|
5699
|
+
revert(commit: Commit, options?: RevertOptions | undefined | null): void
|
|
5700
|
+
/**
|
|
5701
|
+
* Reverts the given commit against the given "our" commit, producing an
|
|
5702
|
+
* index that reflects the result of the revert.
|
|
5703
|
+
*
|
|
5704
|
+
* The returned index must be written to disk for the changes to take effect.
|
|
5705
|
+
*
|
|
5706
|
+
* @category Repository/Methods
|
|
5707
|
+
* @signature
|
|
5708
|
+
* ```ts
|
|
5709
|
+
* class Repository {
|
|
5710
|
+
* revertCommit(
|
|
5711
|
+
* revertCommit: Commit,
|
|
5712
|
+
* ourCommit: Commit,
|
|
5713
|
+
* mainline: number,
|
|
5714
|
+
* mergeOptions?: MergeOptions | undefined | null,
|
|
5715
|
+
* ): Index;
|
|
5716
|
+
* }
|
|
5717
|
+
* ```
|
|
5718
|
+
*
|
|
5719
|
+
* @param {Commit} revertCommit - The commit to revert.
|
|
5720
|
+
* @param {Commit} ourCommit - The commit to revert against (usually HEAD).
|
|
5721
|
+
* @param {number} mainline - The parent of the revert commit, if it is a merge (1-based).
|
|
5722
|
+
* @param {MergeOptions} [mergeOptions] - Options for merge conflict resolution.
|
|
5723
|
+
* @returns The index result.
|
|
5724
|
+
*
|
|
5725
|
+
* @example
|
|
5726
|
+
* ```ts
|
|
5727
|
+
* import { openRepository } from 'es-git';
|
|
5728
|
+
*
|
|
5729
|
+
* const repo = await openRepository('./path/to/repo');
|
|
5730
|
+
* const head = repo.head().target()!;
|
|
5731
|
+
* const our = repo.getCommit(head);
|
|
5732
|
+
* const target = repo.getCommit(head);
|
|
5733
|
+
*
|
|
5734
|
+
* // Compute a revert index and apply to working tree
|
|
5735
|
+
* const idx = repo.revertCommit(target, our, 0);
|
|
5736
|
+
* repo.checkoutIndex(idx);
|
|
5737
|
+
* ```
|
|
5738
|
+
*/
|
|
5739
|
+
revertCommit(revertCommit: Commit, ourCommit: Commit, mainline: number, mergeOptions?: MergeOptions | undefined | null): Index
|
|
5602
5740
|
/**
|
|
5603
5741
|
* Execute a rev-parse operation against the `spec` listed.
|
|
5604
5742
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-git",
|
|
3
|
-
"version": "0.4.0-next.
|
|
3
|
+
"version": "0.4.0-next.146+81f034c",
|
|
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.4.0-next.
|
|
61
|
-
"es-git-darwin-arm64": "0.4.0-next.
|
|
62
|
-
"es-git-win32-x64-msvc": "0.4.0-next.
|
|
63
|
-
"es-git-win32-arm64-msvc": "0.4.0-next.
|
|
64
|
-
"es-git-linux-x64-gnu": "0.4.0-next.
|
|
65
|
-
"es-git-linux-x64-musl": "0.4.0-next.
|
|
66
|
-
"es-git-android-arm64": "0.4.0-next.
|
|
67
|
-
"es-git-linux-arm64-gnu": "0.4.0-next.
|
|
68
|
-
"es-git-linux-arm64-musl": "0.4.0-next.
|
|
69
|
-
"es-git-android-arm-eabi": "0.4.0-next.
|
|
60
|
+
"es-git-darwin-x64": "0.4.0-next.146+81f034c",
|
|
61
|
+
"es-git-darwin-arm64": "0.4.0-next.146+81f034c",
|
|
62
|
+
"es-git-win32-x64-msvc": "0.4.0-next.146+81f034c",
|
|
63
|
+
"es-git-win32-arm64-msvc": "0.4.0-next.146+81f034c",
|
|
64
|
+
"es-git-linux-x64-gnu": "0.4.0-next.146+81f034c",
|
|
65
|
+
"es-git-linux-x64-musl": "0.4.0-next.146+81f034c",
|
|
66
|
+
"es-git-android-arm64": "0.4.0-next.146+81f034c",
|
|
67
|
+
"es-git-linux-arm64-gnu": "0.4.0-next.146+81f034c",
|
|
68
|
+
"es-git-linux-arm64-musl": "0.4.0-next.146+81f034c",
|
|
69
|
+
"es-git-android-arm-eabi": "0.4.0-next.146+81f034c"
|
|
70
70
|
}
|
|
71
71
|
}
|