es-git 0.4.0-next.141 → 0.4.0-next.142

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 +282 -0
  2. package/index.js +3 -1
  3. package/package.json +11 -11
package/index.d.ts CHANGED
@@ -1029,6 +1029,93 @@ export declare function hashObjectOid(objType: ObjectType, bytes: Buffer): strin
1029
1029
  * @returns Hashed string.
1030
1030
  */
1031
1031
  export declare function hashFileOid(objType: ObjectType, path: string): string
1032
+ export interface RebaseCommitOptions {
1033
+ /**
1034
+ * Signature for author.
1035
+ * To keep the author from the original commit leave this as empty.
1036
+ */
1037
+ author?: SignaturePayload
1038
+ /** Signature for commiter. */
1039
+ committer: SignaturePayload
1040
+ /** To keep the message from the original commit leave this as empty. */
1041
+ message?: string
1042
+ }
1043
+ /**
1044
+ * A rebase operation
1045
+ *
1046
+ * Describes a single instruction/operation to be performed during the
1047
+ * rebase.
1048
+ */
1049
+ export interface RebaseOperation {
1050
+ /** The type of rebase operation */
1051
+ type?: RebaseOperationType
1052
+ /**
1053
+ * The commit ID being cherry-picked. This will be populated for all
1054
+ * operations except those of type `GIT_REBASE_OPERATION_EXEC`.
1055
+ */
1056
+ id: string
1057
+ /**
1058
+ *The executable the user has requested be run. This will only
1059
+ * be populated for operations of type `Exec`.
1060
+ */
1061
+ exec?: string
1062
+ }
1063
+ /**
1064
+ * A rebase operation.
1065
+ * Describes a single instruction/operation to be performed during the
1066
+ * rebase.
1067
+ *
1068
+ * - `Pick` : The given commit is to be cherry-picked. The client should commit the
1069
+ * changes and continue if there are no conflicts.
1070
+ * - `Reword` : The given commit is to be cherry-picked, but the client should prompt
1071
+ * the user to provide an updated commit message.
1072
+ * - `Edit` : The given commit is to be cherry-picked, but the client should stop to
1073
+ * allow the user to edit the changes before committing them.
1074
+ * - `Squash` : The given commit is to be squashed into the previous commit. The commit
1075
+ * message will be merged with the previous message.
1076
+ * - `Fixup` : The given commit is to be squashed into the previous commit. The commit
1077
+ * message from this commit will be discarded.
1078
+ * - `Exec` : No commit will be cherry-picked. The client should run the given command
1079
+ * and (if successful) continue.
1080
+ */
1081
+ export type RebaseOperationType = 'Pick' | 'Reword' | 'Edit' | 'Squash' | 'Fixup' | 'Exec';
1082
+ export interface RebaseOptions {
1083
+ /**
1084
+ * This will instruct other clients working on this
1085
+ * rebase that you want a quiet rebase experience, which they may choose to
1086
+ * provide in an application-specific manner. This has no effect upon
1087
+ * libgit2 directly, but is provided for interoperability between Git
1088
+ * tools.
1089
+ */
1090
+ quiet?: boolean
1091
+ /**
1092
+ * This will begin an in-memory rebase,
1093
+ * which will allow callers to step through the rebase operations and
1094
+ * commit the rebased changes, but will not rewind HEAD or update the
1095
+ * repository to be in a rebasing state. This will not interfere with
1096
+ * the working directory (if there is one).
1097
+ */
1098
+ inmemory?: boolean
1099
+ /**
1100
+ * Used by `finish()`, this is the name of the notes reference
1101
+ * used to rewrite notes for rebased commits when finishing the rebase;
1102
+ * if NULL, the contents of the configuration option `notes.rewriteRef`
1103
+ * is examined, unless the configuration option `notes.rewrite.rebase`
1104
+ * is set to false.
1105
+ * If `notes.rewriteRef` is also NULL, notes will not be rewritten.
1106
+ */
1107
+ rewriteNotesRef?: string
1108
+ /** Options to control how trees are merged during `next()`. */
1109
+ mergeOptions?: MergeOptions
1110
+ /**
1111
+ * Options to control how files are written during `Repository::rebase`,
1112
+ * `next()` and `abort()`. Note that a minimum strategy of
1113
+ * `GIT_CHECKOUT_SAFE` is defaulted in `init` and `next`, and a minimum
1114
+ * strategy of `GIT_CHECKOUT_FORCE` is defaulted in `abort` to match git
1115
+ * semantics.
1116
+ */
1117
+ checkoutOptions?: CheckoutOptions
1118
+ }
1032
1119
  /**
1033
1120
  * - `Direct` : A reference which points at an object id.
1034
1121
  * - `Symbolic` : A reference which points at another reference.
@@ -3722,6 +3809,133 @@ export declare class GitObject {
3722
3809
  */
3723
3810
  asCommit(): Commit | null
3724
3811
  }
3812
+ /**
3813
+ * Representation of a rebase
3814
+ * Begin the rebase by iterating the returned `Rebase`
3815
+ * (e.g., `for (const op of rebase) { ... }` or calling `next()`).
3816
+ */
3817
+ export declare class Rebase {
3818
+ /**
3819
+ * Gets the count of rebase operations that are to be applied.
3820
+ *
3821
+ * @category Rebase/Methods
3822
+ * @signature
3823
+ * ```ts
3824
+ * class Rebase {
3825
+ * len(): number;
3826
+ * }
3827
+ * ```
3828
+ *
3829
+ * @returns The count of rebase operations.
3830
+ */
3831
+ len(): bigint
3832
+ /**
3833
+ * Gets the original `HEAD` ref name for merge rebases.
3834
+ *
3835
+ * @category Rebase/Methods
3836
+ * @signature
3837
+ * ```ts
3838
+ * class Rebase {
3839
+ * originHeadName(): string | null;
3840
+ * }
3841
+ * ```
3842
+ *
3843
+ * @returns The original `HEAD` ref name for merge rebases.
3844
+ */
3845
+ originHeadName(): string | null
3846
+ /**
3847
+ * Gets the original `HEAD` id for merge rebases.
3848
+ *
3849
+ * @category Rebase/Methods
3850
+ * @signature
3851
+ * ```ts
3852
+ * class Rebase {
3853
+ * originHeadId(): string | null;
3854
+ * }
3855
+ * ```
3856
+ *
3857
+ * @returns The original `HEAD` id for merge rebases.
3858
+ */
3859
+ originHeadId(): string | null
3860
+ /**
3861
+ * Gets the index produced by the last operation, which is the result of
3862
+ * `next()` and which will be committed by the next invocation of
3863
+ * `commit()`. This is useful for resolving conflicts in an in-memory
3864
+ * rebase before committing them.
3865
+ *
3866
+ * This is only applicable for in-memory rebases; for rebases within a
3867
+ * working directory, the changes were applied to the repository's index.
3868
+ *
3869
+ * @category Rebase/Methods
3870
+ * @signature
3871
+ * ```ts
3872
+ * class Rebase {
3873
+ * inmemoryIndex(): Index;
3874
+ * }
3875
+ * ```
3876
+ *
3877
+ * @returns The index produced by the last operation.
3878
+ */
3879
+ inmemoryIndex(): Index
3880
+ /**
3881
+ * Commits the current patch. You must have resolved any conflicts that
3882
+ * were introduced during the patch application from the rebase next
3883
+ * invocation.
3884
+ *
3885
+ * @category Rebase/Methods
3886
+ * @signature
3887
+ * ```ts
3888
+ * class Rebase {
3889
+ * commit(options: RebaseCommitOptions): string;
3890
+ * }
3891
+ * ```
3892
+ *
3893
+ * @param {RebaseCommitOptions} options - Options for committing the patch.
3894
+ * @returns The commit ID of the commit that was created.
3895
+ *
3896
+ * @example
3897
+ * ```ts
3898
+ * import { openRepository } from 'es-git';
3899
+ *
3900
+ * const repo = await openRepository('.');
3901
+ * const rebase = repo.rebase(...);
3902
+ * const sig = { name: 'Seokju Na', email: 'seokju.me@toss.im' };
3903
+ * for (const op of rebase) {
3904
+ * rebase.commit({ committer: sig });
3905
+ * }
3906
+ * ```
3907
+ */
3908
+ commit(options: RebaseCommitOptions): string
3909
+ /**
3910
+ * Aborts a rebase that is currently in progress, resetting the repository
3911
+ * and working directory to their state before rebase began.
3912
+ *
3913
+ * @category Rebase/Methods
3914
+ * @signature
3915
+ * ```ts
3916
+ * class Rebase {
3917
+ * abort(): void;
3918
+ * }
3919
+ * ```
3920
+ */
3921
+ abort(): void
3922
+ /**
3923
+ * Finishes a rebase that is currently in progress once all patches have
3924
+ * been applied.
3925
+ *
3926
+ * @category Rebase/Methods
3927
+ * @signature
3928
+ * ```ts
3929
+ * class Rebase {
3930
+ * finish(signature?: SignaturePayload | undefined | null): void;
3931
+ * }
3932
+ * ```
3933
+ *
3934
+ * @params {SignaturePayload | undefined | null} [signature] - The identity that is finishing the rebase
3935
+ */
3936
+ finish(signature?: SignaturePayload | undefined | null): void
3937
+ [Symbol.iterator](): Iterator<RebaseOperation, void, void>
3938
+ }
3725
3939
  /**
3726
3940
  * A class to represent a git [reference][1].
3727
3941
  *
@@ -4946,6 +5160,74 @@ export declare class Repository {
4946
5160
  * @throws Throws error if the object does not exist.
4947
5161
  */
4948
5162
  getObject(oid: string): GitObject
5163
+ /**
5164
+ * Initializes a rebase operation to rebase the changes in `branch`
5165
+ * relative to `upstream` onto another branch. To begin the rebase process,
5166
+ * call iterator.
5167
+ *
5168
+ * @category Repository/Methods
5169
+ * @signature
5170
+ * ```ts
5171
+ * class Repository {
5172
+ * rebase(
5173
+ * branch?: AnnotatedCommit | undefined | null,
5174
+ * upstream?: AnnotatedCommit | undefined | null,
5175
+ * onto?: AnnotatedCommit | undefined | null,
5176
+ * options?: RebaseOptions | undefined | null,
5177
+ * ): Rebase;
5178
+ * }
5179
+ * ```
5180
+ *
5181
+ * @param {AnnotatedCommit | undefined | null} [branch] - Annotated commit representing the
5182
+ * branch to rebase. Typically, the branch's head commit. If omitted, the currently checked-out
5183
+ * branch is used.
5184
+ * @param {AnnotatedCommit | undefined | null} [upstream] - Annotated commit that defines the
5185
+ * "original base" of the commits to be rebased. If omitted, the repository will typically try
5186
+ * to use the branch's configured upstream.
5187
+ * @param {AnnotatedCommit | undefined | null} [onto] - Specified the "new base" onto which the
5188
+ * selected commits will be reapplied.
5189
+ * @param {RebaseOptions | undefined | null} [options] - Fine-grained control of the rebase
5190
+ * behavior, such as checkout options, merge options, and in-memory rebase.
5191
+ * @returns The initialized rebase handle to iterate and apply steps.
5192
+ *
5193
+ * @example
5194
+ * ```ts
5195
+ * import { openRepository } from 'es-git';
5196
+ *
5197
+ * const repo = await openRepository('.');
5198
+ * const branchRef = repo.getReference('refs/heads/other');
5199
+ * const upstreamRef = repo.getReference('refs/heads/main');
5200
+ * const branch = repo.getAnnotatedCommitFromReference(branchRef);
5201
+ * const upstream = repo.getAnnotatedCommitFromReference(upstreamRef);
5202
+ *
5203
+ * const sig = { name: 'Seokju Na', email: 'seokju.me@toss.im' };
5204
+ *
5205
+ * const rebase = repo.rebase(branch, upstream);
5206
+ * for (const op of rebase) {
5207
+ * rebase.commit({ committer: sig });
5208
+ * }
5209
+ * rebase.finish(sig);
5210
+ * ```
5211
+ */
5212
+ rebase(branch?: AnnotatedCommit | undefined | null, upstream?: AnnotatedCommit | undefined | null, onto?: AnnotatedCommit | undefined | null, options?: RebaseOptions | undefined | null): Rebase
5213
+ /**
5214
+ * Opens an existing rebase that was previously started by either an
5215
+ * invocation of `rebase()` or by another client.
5216
+ *
5217
+ * @category Repository/Methods
5218
+ * @signature
5219
+ * ```ts
5220
+ * class Repository {
5221
+ * openRebase(options?: RebaseOptions | undefined | null): Rebase;
5222
+ * }
5223
+ * ```
5224
+ *
5225
+ * @param {RebaseOptions | undefined | null} [options] - Fine-grained control of the rebase
5226
+ * behavior, such as checkout options, merge options, and in-memory rebase.
5227
+ * @returns The initialized rebase handle to iterate and apply steps.
5228
+ * @throws Throws if the existing rebase was not found.
5229
+ */
5230
+ openRebase(options?: RebaseOptions | undefined | null): Rebase
4949
5231
  /**
4950
5232
  * Lookup a reference to one of the objects in a repository.
4951
5233
  *
package/index.js CHANGED
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { AnnotatedCommit, 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, Mailmap, createMailmapFromBuffer, FileFavor, 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, StashEntry, StashList, StashListIter, StatusShow, Statuses, StatusesIter, StatusEntry, isValidTagName, Tag, TreeWalkMode, Tree, TreeIter, TreeEntry } = nativeBinding
313
+ const { AnnotatedCommit, 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, Mailmap, createMailmapFromBuffer, FileFavor, ObjectType, GitObject, isValidOid, isZeroOid, zeroOid, hashObjectOid, hashFileOid, Rebase, RebaseOperationType, ReferenceType, Reference, isValidReferenceName, ReferenceFormat, normalizeReferenceName, Direction, CredentialType, FetchPrune, AutotagOption, RemoteRedirect, Remote, RepositoryState, RepositoryInitMode, Repository, initRepository, openRepository, discoverRepository, cloneRepository, RevparseMode, revparseModeContains, RevwalkSort, Revwalk, createSignature, StashEntry, StashList, StashListIter, StatusShow, Statuses, StatusesIter, StatusEntry, isValidTagName, Tag, TreeWalkMode, Tree, TreeIter, TreeEntry } = nativeBinding
314
314
 
315
315
  module.exports.AnnotatedCommit = AnnotatedCommit
316
316
  module.exports.Blame = Blame
@@ -356,6 +356,8 @@ module.exports.isZeroOid = isZeroOid
356
356
  module.exports.zeroOid = zeroOid
357
357
  module.exports.hashObjectOid = hashObjectOid
358
358
  module.exports.hashFileOid = hashFileOid
359
+ module.exports.Rebase = Rebase
360
+ module.exports.RebaseOperationType = RebaseOperationType
359
361
  module.exports.ReferenceType = ReferenceType
360
362
  module.exports.Reference = Reference
361
363
  module.exports.isValidReferenceName = isValidReferenceName
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-git",
3
- "version": "0.4.0-next.141+ecc5ce3",
3
+ "version": "0.4.0-next.142+cac7306",
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.141+ecc5ce3",
61
- "es-git-darwin-arm64": "0.4.0-next.141+ecc5ce3",
62
- "es-git-win32-x64-msvc": "0.4.0-next.141+ecc5ce3",
63
- "es-git-win32-arm64-msvc": "0.4.0-next.141+ecc5ce3",
64
- "es-git-linux-x64-gnu": "0.4.0-next.141+ecc5ce3",
65
- "es-git-linux-x64-musl": "0.4.0-next.141+ecc5ce3",
66
- "es-git-android-arm64": "0.4.0-next.141+ecc5ce3",
67
- "es-git-linux-arm64-gnu": "0.4.0-next.141+ecc5ce3",
68
- "es-git-linux-arm64-musl": "0.4.0-next.141+ecc5ce3",
69
- "es-git-android-arm-eabi": "0.4.0-next.141+ecc5ce3"
60
+ "es-git-darwin-x64": "0.4.0-next.142+cac7306",
61
+ "es-git-darwin-arm64": "0.4.0-next.142+cac7306",
62
+ "es-git-win32-x64-msvc": "0.4.0-next.142+cac7306",
63
+ "es-git-win32-arm64-msvc": "0.4.0-next.142+cac7306",
64
+ "es-git-linux-x64-gnu": "0.4.0-next.142+cac7306",
65
+ "es-git-linux-x64-musl": "0.4.0-next.142+cac7306",
66
+ "es-git-android-arm64": "0.4.0-next.142+cac7306",
67
+ "es-git-linux-arm64-gnu": "0.4.0-next.142+cac7306",
68
+ "es-git-linux-arm64-musl": "0.4.0-next.142+cac7306",
69
+ "es-git-android-arm-eabi": "0.4.0-next.142+cac7306"
70
70
  }
71
71
  }