es-git 0.3.0 → 0.4.0-next.135

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 +709 -0
  2. package/index.js +3 -1
  3. package/package.json +12 -12
package/index.d.ts CHANGED
@@ -109,6 +109,148 @@ export interface BranchesFilter {
109
109
  /** Branch type to filter. */
110
110
  type?: BranchType
111
111
  }
112
+ export interface CheckoutOptions {
113
+ /**
114
+ * Indicate that this checkout should perform a dry run by checking for
115
+ * conflicts but not make any actual changes.
116
+ */
117
+ dryRun?: boolean
118
+ /**
119
+ * Take any action necessary to get the working directory to match the
120
+ * target including potentially discarding modified files.
121
+ */
122
+ force?: boolean
123
+ /**
124
+ * Indicate that the checkout should be performed safely, allowing new
125
+ * files to be created but not overwriting existing files or changes.
126
+ *
127
+ * This is the default.
128
+ */
129
+ safe?: boolean
130
+ /**
131
+ * In safe mode, create files that don't exist.
132
+ *
133
+ * Defaults to false.
134
+ */
135
+ recreateMissing?: boolean
136
+ /**
137
+ * In safe mode, apply safe file updates even when there are conflicts
138
+ * instead of canceling the checkout.
139
+ *
140
+ * Defaults to false.
141
+ */
142
+ allowConflicts?: boolean
143
+ /**
144
+ * Remove untracked files from the working dir.
145
+ *
146
+ * Defaults to false.
147
+ */
148
+ removeUntracked?: boolean
149
+ /**
150
+ * Remove ignored files from the working dir.
151
+ *
152
+ * Defaults to false.
153
+ */
154
+ removeIgnored?: boolean
155
+ /**
156
+ * Only update the contents of files that already exist.
157
+ *
158
+ * If set, files will not be created or deleted.
159
+ *
160
+ * Defaults to false.
161
+ */
162
+ updateOnly?: boolean
163
+ /**
164
+ * Prevents checkout from writing the updated files' information to the
165
+ * index.
166
+ *
167
+ * Defaults to true.
168
+ */
169
+ updateIndex?: boolean
170
+ /**
171
+ * Indicate whether the index and git attributes should be refreshed from
172
+ * disk before any operations.
173
+ *
174
+ * Defaults to true,
175
+ */
176
+ refresh?: boolean
177
+ /**
178
+ * Skip files with unmerged index entries.
179
+ *
180
+ * Defaults to false.
181
+ */
182
+ skipUnmerged?: boolean
183
+ /**
184
+ * Indicate whether the checkout should proceed on conflicts by using the
185
+ * stage 2 version of the file ("ours").
186
+ *
187
+ * Defaults to false.
188
+ */
189
+ useOurs?: boolean
190
+ /**
191
+ * Indicate whether the checkout should proceed on conflicts by using the
192
+ * stage 3 version of the file ("theirs").
193
+ *
194
+ * Defaults to false.
195
+ */
196
+ useTheirs?: boolean
197
+ /**
198
+ * Indicate whether ignored files should be overwritten during the checkout.
199
+ *
200
+ * Defaults to true.
201
+ */
202
+ overwriteIgnored?: boolean
203
+ /**
204
+ * Indicate whether a normal merge file should be written for conflicts.
205
+ *
206
+ * Defaults to false.
207
+ */
208
+ conflictStyleMerge?: boolean
209
+ /**
210
+ * Indicates whether to include common ancestor data in diff3 format files
211
+ * for conflicts.
212
+ *
213
+ * Defaults to false.
214
+ */
215
+ conflictStyleDiff3?: boolean
216
+ /**
217
+ * Treat paths specified in `path` as exact file paths
218
+ * instead of as pathspecs.
219
+ */
220
+ disablePathspecMatch?: boolean
221
+ /** Indicate whether to apply filters like CRLF conversion. */
222
+ disableFilters?: boolean
223
+ /**
224
+ * Set the mode with which new directories are created.
225
+ *
226
+ * Default is 0755
227
+ */
228
+ dirPerm?: number
229
+ /**
230
+ * Set the mode with which new files are created.
231
+ *
232
+ * The default is 0644 or 0755 as dictated by the blob.
233
+ */
234
+ filePerm?: number
235
+ /**
236
+ * Add a path to be checked out.
237
+ *
238
+ * The path is a [pathspec](https://git-scm.com/docs/gitglossary.html#Documentation/gitglossary.txt-aiddefpathspecapathspec) pattern, unless
239
+ * `disablePathspecMatch` is set.
240
+ *
241
+ * If no paths are specified, then all files are checked out. Otherwise
242
+ * only these specified paths are checked out.
243
+ */
244
+ path?: string
245
+ /** Set the directory to check out to */
246
+ targetDir?: string
247
+ /** The name of the common ancestor side of conflicts */
248
+ ancestorLabel?: string
249
+ /** The name of the common our side of conflicts */
250
+ ourLabel?: string
251
+ /** The name of the common their side of conflicts */
252
+ theirLabel?: string
253
+ }
112
254
  export interface CommitOptions {
113
255
  updateRef?: string
114
256
  /**
@@ -683,6 +825,125 @@ export interface AddMailmapEntryData {
683
825
  * ```
684
826
  */
685
827
  export declare function createMailmapFromBuffer(content: string): Mailmap
828
+ export type FileFavor = /**
829
+ * When a region of a file is changed in both branches, a conflict will be
830
+ * recorded in the index so that git_checkout can produce a merge file with
831
+ * conflict markers in the working directory. This is the default.
832
+ */
833
+ 'Normal' | /**
834
+ * When a region of a file is changed in both branches, the file created
835
+ * in the index will contain the "ours" side of any conflicting region.
836
+ * The index will not record a conflict.
837
+ */
838
+ 'Ours' | /**
839
+ * When a region of a file is changed in both branches, the file created
840
+ * in the index will contain the "theirs" side of any conflicting region.
841
+ * The index will not record a conflict.
842
+ */
843
+ 'Theirs' | /**
844
+ * When a region of a file is changed in both branches, the file created
845
+ * in the index will contain each unique line from each side, which has
846
+ * the result of combining both files. The index will not record a conflict.
847
+ */
848
+ 'Union';
849
+ export interface MergeOptions {
850
+ /** Detect file renames */
851
+ findRenames?: boolean
852
+ /**
853
+ * If a conflict occurs, exit immediately instead of attempting to continue
854
+ * resolving conflicts
855
+ */
856
+ failOnConflict?: boolean
857
+ /** Do not write the REUC extension on the generated index */
858
+ skipReuc?: boolean
859
+ /**
860
+ * If the commits being merged have multiple merge bases, do not build a
861
+ * recursive merge base (by merging the multiple merge bases), instead
862
+ * simply use the first base.
863
+ */
864
+ noRecursive?: boolean
865
+ /** Similarity to consider a file renamed (default 50) */
866
+ renameThreshold?: number
867
+ /**
868
+ * Maximum similarity sources to examine for renames (default 200).
869
+ * If the number of rename candidates (add / delete pairs) is greater
870
+ * than this value, inexact rename detection is aborted. This setting
871
+ * overrides the `merge.renameLimit` configuration value.
872
+ */
873
+ targetLimit?: number
874
+ /**
875
+ * Maximum number of times to merge common ancestors to build a
876
+ * virtual merge base when faced with criss-cross merges. When
877
+ * this limit is reached, the next ancestor will simply be used
878
+ * instead of attempting to merge it. The default is unlimited.
879
+ */
880
+ recursionLimit?: number
881
+ /** Specify a side to favor for resolving conflicts */
882
+ filFavor?: FileFavor
883
+ /** Create standard conflicted merge files */
884
+ standardStyle?: boolean
885
+ /** Create diff3-style file */
886
+ diff3Style?: boolean
887
+ /** Condense non-alphanumeric regions for simplified diff file */
888
+ simplifyAlnum?: boolean
889
+ /** Ignore all whitespace */
890
+ ignoreWhitespace?: boolean
891
+ /** Ignore changes in amount of whitespace */
892
+ ignoreWhitespaceChange?: boolean
893
+ /** Ignore whitespace at end of line */
894
+ ignoreWhitespaceEol?: boolean
895
+ /** Use the "patience diff" algorithm */
896
+ patience?: boolean
897
+ /** Take extra time to find minimal diff */
898
+ minimal?: boolean
899
+ }
900
+ export interface MergeAnalysis {
901
+ /** No merge is possible. */
902
+ none: boolean
903
+ /**
904
+ * A "normal" merge; both HEAD and the given merge input have diverged
905
+ * from their common ancestor. The divergent commits must be merged.
906
+ */
907
+ normal: boolean
908
+ /**
909
+ * All given merge inputs are reachable from HEAD, meaning the
910
+ * repository is up-to-date and no merge needs to be performed.
911
+ */
912
+ upToDate: boolean
913
+ /**
914
+ * The given merge input is a fast-forward from HEAD and no merge
915
+ * needs to be performed. Instead, the client can check out the
916
+ * given merge input.
917
+ */
918
+ fastForward: boolean
919
+ /**
920
+ * The HEAD of the current repository is "unborn" and does not point to
921
+ * a valid commit. No merge can be performed, but the caller may wish
922
+ * to simply set HEAD to the target commit(s).
923
+ */
924
+ unborn: boolean
925
+ }
926
+ export interface MergePreference {
927
+ /**
928
+ * No configuration was found that suggests a preferred behavior for
929
+ * merge.
930
+ */
931
+ none: boolean
932
+ /**
933
+ * There is a `merge.ff=false` configuration setting, suggesting that
934
+ * the user does not want to allow a fast-forward merge.
935
+ */
936
+ noFastForward: boolean
937
+ /**
938
+ * There is a `merge.ff=only` configuration setting, suggesting that
939
+ * the user only wants fast-forward merges.
940
+ */
941
+ fastForwardOnly: boolean
942
+ }
943
+ export interface MergeAnalysisResult {
944
+ analysis: MergeAnalysis
945
+ preference: MergePreference
946
+ }
686
947
  /**
687
948
  * - `Any` : Any kind of git object
688
949
  * - `Commit` : An object which corresponds to a git commit
@@ -1573,6 +1834,45 @@ export interface CreateLightweightTagOptions {
1573
1834
  * - `PostOrder` : Runs the traversal in post-order.
1574
1835
  */
1575
1836
  export type TreeWalkMode = 'PreOrder' | 'PostOrder';
1837
+ /**
1838
+ * A structure to represent an annotated commit, the input to merge and rebase.
1839
+ *
1840
+ * An annotated commit contains information about how it was looked up, which
1841
+ * may be useful for functions like merge or rebase to provide context to the
1842
+ * operation.
1843
+ */
1844
+ export declare class AnnotatedCommit {
1845
+ /**
1846
+ * Gets the commit ID that the given Annotated Commit refers to.
1847
+ *
1848
+ * @category AnnotatedCommit/Methods
1849
+ * @signature
1850
+ * ```ts
1851
+ * class AnnotatedCommit {
1852
+ * id(): string;
1853
+ * }
1854
+ * ```
1855
+ *
1856
+ * @returns The commit ID that this Annotated Commit refers to.
1857
+ */
1858
+ id(): string
1859
+ /**
1860
+ * Get the refname that the given Annotated Commit refers to.
1861
+ *
1862
+ * @category AnnotatedCommit/Methods
1863
+ * @signature
1864
+ * ```ts
1865
+ * class AnnotatedCommit {
1866
+ * refname(): string | null;
1867
+ * }
1868
+ * ```
1869
+ *
1870
+ * @returns The refname that this Annotated Commit refers to. If this created from a reference,
1871
+ * the return value is `null`.
1872
+ * @throws Throws error if the refname is not valid utf-8.
1873
+ */
1874
+ refname(): string | null
1875
+ }
1576
1876
  /** A wrapper around git2::Blame providing Node.js bindings */
1577
1877
  export declare class Blame {
1578
1878
  /**
@@ -3789,6 +4089,57 @@ export declare class Remote {
3789
4089
  * This class corresponds to a git repository in libgit2.
3790
4090
  */
3791
4091
  export declare class Repository {
4092
+ /**
4093
+ * Creates an Annotated Commit from the given commit.
4094
+ *
4095
+ * @category Repository/Methods
4096
+ * @signature
4097
+ * ```ts
4098
+ * class Repository {
4099
+ * getAnnotatedCommit(commit: Commit): AnnotatedCommit;
4100
+ * }
4101
+ * ```
4102
+ *
4103
+ * @param {Commit} commit - Commit to creates a Annotated Commit.
4104
+ * @returns An Annotated Commit created from commit.
4105
+ */
4106
+ getAnnotatedCommit(commit: Commit): AnnotatedCommit
4107
+ /**
4108
+ * Creates a Annotated Commit from the given reference.
4109
+ *
4110
+ * @category Repository/Methods
4111
+ * @signature
4112
+ * ```ts
4113
+ * class Repository {
4114
+ * getAnnotatedCommitFromReference(reference: Reference): AnnotatedCommit;
4115
+ * }
4116
+ * ```
4117
+ *
4118
+ * @param {Reference} reference - Reference to creates a Annotated Commit.
4119
+ * @returns An Annotated Commit created from reference.
4120
+ */
4121
+ getAnnotatedCommitFromReference(reference: GitReference): AnnotatedCommit
4122
+ /**
4123
+ * Creates a Annotated Commit from `FETCH_HEAD`.
4124
+ *
4125
+ * @category Repository/Methods
4126
+ * @signature
4127
+ * ```ts
4128
+ * class Repository {
4129
+ * getAnnotatedCommitFromFetchHead(
4130
+ * branchName: string,
4131
+ * remoteUrl: string,
4132
+ * id: string,
4133
+ * ): AnnotatedCommit;
4134
+ * }
4135
+ * ```
4136
+ *
4137
+ * @param {String} branchName - Name of the remote branch.
4138
+ * @param {String} remoteUrl - Url of the remote.
4139
+ * @param {String} id - The commit object id of the remote branch.
4140
+ * @returns An Annotated Commit created from `FETCH_HEAD`.
4141
+ */
4142
+ getAnnotatedCommitFromFetchHead(branchName: string, remoteUrl: string, id: string): AnnotatedCommit
3792
4143
  /**
3793
4144
  * Creates a blame object for the file at the given path
3794
4145
  *
@@ -3900,6 +4251,55 @@ export declare class Repository {
3900
4251
  * ```
3901
4252
  */
3902
4253
  branches(filter?: BranchesFilter | undefined | null): Branches
4254
+ /**
4255
+ * Updates files in the index and the working tree to match the content of
4256
+ * the commit pointed at by HEAD.
4257
+ *
4258
+ * @category Repository/Methods
4259
+ * @signature
4260
+ * ```ts
4261
+ * class Repository {
4262
+ * checkoutHead(options?: CheckoutOptions | undefined | null): void;
4263
+ * }
4264
+ * ```
4265
+ *
4266
+ * @param {CheckoutOptions} [options] - Options for checkout.
4267
+ */
4268
+ checkoutHead(options?: CheckoutOptions | undefined | null): void
4269
+ /**
4270
+ * Updates files in the working tree to match the content of the index.
4271
+ *
4272
+ * @category Repository/Methods
4273
+ * @signature
4274
+ * ```ts
4275
+ * class Repository {
4276
+ * checkoutIndex(
4277
+ * index?: Index | undefined | null,
4278
+ * options?: CheckoutOptions | undefined | null,
4279
+ * ): void;
4280
+ * }
4281
+ * ```
4282
+ *
4283
+ * @param {Index} [index] - Index to checkout. If not given, the repository's index will be used.
4284
+ * @param {CheckoutOptions} [options] - Options for checkout.
4285
+ */
4286
+ checkoutIndex(index?: Index | undefined | null, options?: CheckoutOptions | undefined | null): void
4287
+ /**
4288
+ * Updates files in the index and working tree to match the content of the
4289
+ * tree pointed at by the treeish.
4290
+ *
4291
+ * @category Repository/Methods
4292
+ * @signature
4293
+ * ```ts
4294
+ * class Repository {
4295
+ * checkoutTree(treeish: GitObject, options?: CheckoutOptions | undefined | null): void;
4296
+ * }
4297
+ * ```
4298
+ *
4299
+ * @param {GitObject} treeish - Git object which tree pointed.
4300
+ * @param {CheckoutOptions} [options] - Options for checkout.
4301
+ */
4302
+ checkoutTree(treeish: GitObject, options?: CheckoutOptions | undefined | null): void
3903
4303
  /**
3904
4304
  * Lookup a reference to one of the commits in a repository.
3905
4305
  *
@@ -4217,6 +4617,225 @@ export declare class Repository {
4217
4617
  * @returns The mailmap object if it exists, null otherwise
4218
4618
  */
4219
4619
  mailmap(): Mailmap | null
4620
+ /**
4621
+ * Find a merge base between two commits
4622
+ *
4623
+ * @category Repository/Methods
4624
+ * @signature
4625
+ * ```ts
4626
+ * class Repository {
4627
+ * mergeBase(one: string, two: string): string;
4628
+ * }
4629
+ * ```
4630
+ *
4631
+ * @param {string} one - One of the commits OID.
4632
+ * @param {string} two - The other commit OID.
4633
+ * @returns The OID of a merge base between 'one' and 'two'.
4634
+ */
4635
+ getMergeBase(one: string, two: string): string
4636
+ /**
4637
+ * Find a merge base given a list of commits
4638
+ *
4639
+ * This behaves similar to [`git merge-base`](https://git-scm.com/docs/git-merge-base#_discussion).
4640
+ * Given three commits `a`, `b`, and `c`, `getMergeBaseMany([a, b, c])`
4641
+ * will compute a hypothetical commit `m`, which is a merge between `b`
4642
+ * and `c`.
4643
+ *
4644
+ * For example, with the following topology:
4645
+ * ```text
4646
+ * o---o---o---o---C
4647
+ * /
4648
+ * / o---o---o---B
4649
+ * / /
4650
+ * ---2---1---o---o---o---A
4651
+ * ```
4652
+ *
4653
+ * the result of `getMergeBaseMany([a, b, c])` is 1. This is because the
4654
+ * equivalent topology with a merge commit `m` between `b` and `c` would
4655
+ * is:
4656
+ * ```text
4657
+ * o---o---o---o---o
4658
+ * / \
4659
+ * / o---o---o---o---M
4660
+ * / /
4661
+ * ---2---1---o---o---o---A
4662
+ * ```
4663
+ *
4664
+ * and the result of `getMergeBaseMany([a, m])` is 1.
4665
+ *
4666
+ * ---
4667
+ *
4668
+ * If you're looking to recieve the common merge base between all the
4669
+ * given commits, use `getMergeBaseOctopus`.
4670
+ *
4671
+ * @category Repository/Methods
4672
+ * @signature
4673
+ * ```ts
4674
+ * class Repository {
4675
+ * getMergeBaseMany(oids: string[]): string;
4676
+ * }
4677
+ * ```
4678
+ *
4679
+ * @param {string[]} oids - Oids of the commits.
4680
+ * @returns The OID of a merge base considering all the commits.
4681
+ */
4682
+ getMergeBaseMany(oids: Array<string>): string
4683
+ /**
4684
+ * Find a merge base in preparation for an octopus merge.
4685
+ *
4686
+ * @category Repository/Methods
4687
+ * @signature
4688
+ * ```ts
4689
+ * class Repository {
4690
+ * getMergeBaseOctopus(oids: string[]): string;
4691
+ * }
4692
+ * ```
4693
+ *
4694
+ * @param {string[]} oids - Oids of the commits.
4695
+ * @returns The OID of a merge base considering all the commits.
4696
+ */
4697
+ getMergeBaseOctopus(oids: Array<string>): string
4698
+ /**
4699
+ * Find all merge bases between two commits
4700
+ *
4701
+ * @category Repository/Methods
4702
+ * @signature
4703
+ * ```ts
4704
+ * class Repository {
4705
+ * getMergeBases(one: string, two: string): string[];
4706
+ * }
4707
+ * ```
4708
+ *
4709
+ * @param {string} one - One of the commits OID.
4710
+ * @param {string} two - The other commit OID.
4711
+ * @returns Array in which to store the resulting OIDs.
4712
+ */
4713
+ getMergeBases(one: string, two: string): Array<string>
4714
+ /**
4715
+ * Find all merge bases given a list of commits
4716
+ *
4717
+ * @category Repository/Methods
4718
+ * @signature
4719
+ * ```ts
4720
+ * class Repository {
4721
+ * getMergeBasesMany(oids: string[]): string[];
4722
+ * }
4723
+ * ```
4724
+ *
4725
+ * @param {string[]} oids - Oids of the commits.
4726
+ * @returns Array in which to store the resulting OIDs.
4727
+ */
4728
+ getMergeBasesMany(oids: Array<string>): Array<string>
4729
+ /**
4730
+ * Merges the given commit(s) into HEAD, writing the results into the
4731
+ * working directory. Any changes are staged for commit and any conflicts
4732
+ * are written to the index. Callers should inspect the repository's index
4733
+ * after this completes, resolve any conflicts and prepare a commit.
4734
+ *
4735
+ * For compatibility with git, the repository is put into a merging state.
4736
+ * Once the commit is done (or if the user wishes to abort), you should
4737
+ * clear this state by calling `cleanupState()`.
4738
+ *
4739
+ * @category Repository/Methods
4740
+ * @signature
4741
+ * ```ts
4742
+ * class Repository {
4743
+ * merge(
4744
+ * annotatedCommits: AnnotatedCommit[],
4745
+ * mergeOptions?: MergeOptions | undefined | null,
4746
+ * checkoutOptions?: CheckoutOptions | undefined | null,
4747
+ * ): void;
4748
+ * }
4749
+ * ```
4750
+ *
4751
+ * @param {AnnotatedCommit[]} annotatedCommits - Commits to merge.
4752
+ * @param {MergeOptions} [mergeOptions] - Merge options.
4753
+ * @param {CheckoutOptions} [checkoutOptions] - Checkout options.
4754
+ */
4755
+ merge(annotatedCommits: Array<AnnotatedCommit>, mergeOptions?: MergeOptions | undefined | null, checkoutOptions?: CheckoutOptions | undefined | null): void
4756
+ /**
4757
+ * Merge two commits, producing an index that reflects the result of
4758
+ * the merge. The index may be written as-is to the working directory or
4759
+ * checked out. If the index is to be converted to a tree, the caller
4760
+ * should resolve any conflicts that arose as part of the merge.
4761
+ *
4762
+ * @category Repository/Methods
4763
+ * @signature
4764
+ * ```ts
4765
+ * class Repository {
4766
+ * mergeCommits(
4767
+ * ourCommit: Commit,
4768
+ * theirCommit: Commit,
4769
+ * options?: MergeOptions | undefined | null,
4770
+ * ): Index;
4771
+ * }
4772
+ * ```
4773
+ *
4774
+ * @param {Commit} outCommit - The commit that reflects the destination tree.
4775
+ * @param {Commit} theirCommit - The commit to merge in to `ourCommit`.
4776
+ * @param {MergeOptions} [options] - Merge options.
4777
+ * @returns The index result.
4778
+ */
4779
+ mergeCommits(ourCommit: Commit, theirCommit: Commit, options?: MergeOptions | undefined | null): Index
4780
+ /**
4781
+ * Merge two trees, producing an index that reflects the result of
4782
+ * the merge. The index may be written as-is to the working directory or
4783
+ * checked out. If the index is to be converted to a tree, the caller
4784
+ * should resolve any conflicts that arose as part of the merge.
4785
+ *
4786
+ * @category Repository/Methods
4787
+ * @signature
4788
+ * ```ts
4789
+ * class Repository {
4790
+ * mergeTrees(
4791
+ * ancestorTree: Tree,
4792
+ * ourTree: Tree,
4793
+ * theirTree: Tree,
4794
+ * options?: MergeOptions | undefined | null,
4795
+ * ): Index;
4796
+ * }
4797
+ * ```
4798
+ *
4799
+ * @param {Tree} ancestorTree - The common ancestor between.
4800
+ * @param {Tree} outTree - The tree that reflects the destination tree.
4801
+ * @param {Tree} theirTree - The tree to merge in to `ourTree`.
4802
+ * @param {MergeOptions} [options] - Merge options.
4803
+ * @returns The index result.
4804
+ */
4805
+ mergeTrees(ancestorTree: Tree, ourTree: Tree, theirTree: Tree, options?: MergeOptions | undefined | null): Index
4806
+ /**
4807
+ * Analyzes the given branch(es) and determines the opportunities for
4808
+ * merging them into the HEAD of the repository.
4809
+ *
4810
+ * @category Repository/Methods
4811
+ * @signature
4812
+ * ```ts
4813
+ * class Repository {
4814
+ * analyzeMergeFor(theirHeads: AnnotatedCommit[]): MergeAnalysisResult;
4815
+ * }
4816
+ * ```
4817
+ *
4818
+ * @param {AnnotatedCommit[]} theirHeads - The heads to merge into.
4819
+ * @returns Merge analysis result.
4820
+ */
4821
+ analyzeMerge(theirHeads: Array<AnnotatedCommit>): MergeAnalysisResult
4822
+ /**
4823
+ * Analyzes the given branch(es) and determines the opportunities for
4824
+ * merging them into a reference.
4825
+ *
4826
+ * @category Repository/Methods
4827
+ * @signature
4828
+ * ```ts
4829
+ * class Repository {
4830
+ * analyzeMergeForRef(ourRef: Reference, theirHeads: AnnotatedCommit[]): MergeAnalysisResult;
4831
+ * }
4832
+ * ```
4833
+ *
4834
+ * @param {Reference} ourRef - The reference to perform the analysis from.
4835
+ * @param {AnnotatedCommit[]} theirHeads - The heads to merge into.
4836
+ * @returns Merge analysis result.
4837
+ */
4838
+ analyzeMergeForRef(ourRef: Reference, theirHeads: Array<AnnotatedCommit>): MergeAnalysisResult
4220
4839
  /**
4221
4840
  * Lookup a reference to one of the objects in a repository.
4222
4841
  *
@@ -4510,6 +5129,64 @@ export declare class Repository {
4510
5129
  * @param {string} refname - Specified reference to point into `HEAD`.
4511
5130
  */
4512
5131
  setHead(refname: string): void
5132
+ /**
5133
+ * Determines whether the repository `HEAD` is detached.
5134
+ *
5135
+ * @category Repository/Methods
5136
+ * @signature
5137
+ * ```ts
5138
+ * class Repository {
5139
+ * headDetached(): boolean;
5140
+ * }
5141
+ * ```
5142
+ *
5143
+ * @returns Returns `true` if the repository `HEAD` is detached.
5144
+ */
5145
+ headDetached(): boolean
5146
+ /**
5147
+ * Make the repository HEAD directly point to the commit.
5148
+ *
5149
+ * If the provided commitish cannot be found in the repository, the HEAD
5150
+ * is unaltered and an error is returned.
5151
+ *
5152
+ * If the provided commitish cannot be peeled into a commit, the HEAD is
5153
+ * unaltered and an error is returned.
5154
+ *
5155
+ * Otherwise, the HEAD will eventually be detached and will directly point
5156
+ * to the peeled commit.
5157
+ *
5158
+ * @category Repository/Methods
5159
+ * @signature
5160
+ * ```ts
5161
+ * class Repository {
5162
+ * setHeadDetached(commitish: Commit): void;
5163
+ * }
5164
+ * ```
5165
+ *
5166
+ * @param {Commit} commitish - A Commit which the HEAD should point to.
5167
+ */
5168
+ setHeadDetached(commit: Commit): void
5169
+ /**
5170
+ * Make the repository HEAD directly point to the commit.
5171
+ *
5172
+ * If the provided commitish cannot be found in the repository, the HEAD
5173
+ * is unaltered and an error is returned.
5174
+ * If the provided commitish cannot be peeled into a commit, the HEAD is
5175
+ * unaltered and an error is returned.
5176
+ * Otherwise, the HEAD will eventually be detached and will directly point
5177
+ * to the peeled commit.
5178
+ *
5179
+ * @category Repository/Methods
5180
+ * @signature
5181
+ * ```ts
5182
+ * class Repository {
5183
+ * setHeadDetachedFromAnnotated(commitish: AnnotatedCommit): void;
5184
+ * }
5185
+ * ```
5186
+ *
5187
+ * @param {AnnotatedCommit} commitish - An Annotated Commit which the HEAD should point to.
5188
+ */
5189
+ setHeadDetachedFromAnnotated(commitish: AnnotatedCommit): void
4513
5190
  /**
4514
5191
  * Extract a signature from an object identified by its ID.
4515
5192
  *
@@ -4527,8 +5204,40 @@ export declare class Repository {
4527
5204
  * @param {string} oid - Object ID (SHA1) of the signed object to extract the signature from.
4528
5205
  * @returns An ExtractedSignature object containing the signature and signed data if the object is signed,
4529
5206
  * or null if the object is not signed.
5207
+ *
5208
+ * @example
5209
+ * ```ts
5210
+ * import { openRepository } from 'es-git';
5211
+ *
5212
+ * const repo = await openRepository('.');
5213
+ * const commit = repo.getCommit('a01e9888e46729ef4aa68953ba19b02a7a64eb82');
5214
+ *
5215
+ * // Extract the signature from a commit
5216
+ * const signatureInfo = repo.extractSignature(commit.id());
5217
+ *
5218
+ * if (signatureInfo) {
5219
+ * console.log('Object is signed!');
5220
+ * console.log('Signature:', signatureInfo.signature);
5221
+ * console.log('Signed data:', signatureInfo.signedData);
5222
+ * } else {
5223
+ * console.log('Object is not signed');
5224
+ * }
5225
+ * ```
4530
5226
  */
4531
5227
  extractSignature(oid: string): ExtractedSignature | null
5228
+ /**
5229
+ * Remove all the metadata associated with an ongoing command like merge,
5230
+ * revert, cherry-pick, etc. For example: `MERGE_HEAD`, `MERGE_MSG`, etc.
5231
+ *
5232
+ * @category Repository/Methods
5233
+ * @signature
5234
+ * ```ts
5235
+ * class Repository {
5236
+ * cleanupState(): void;
5237
+ * }
5238
+ * ```
5239
+ */
5240
+ cleanupState(): void
4532
5241
  /**
4533
5242
  * Execute a rev-parse operation against the `spec` listed.
4534
5243
  *
package/index.js CHANGED
@@ -310,8 +310,9 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
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, Mailmap, createMailmapFromBuffer, 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, 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, ReferenceType, Reference, isValidReferenceName, ReferenceFormat, normalizeReferenceName, Direction, CredentialType, FetchPrune, AutotagOption, RemoteRedirect, Remote, RepositoryState, RepositoryInitMode, Repository, initRepository, openRepository, discoverRepository, cloneRepository, RevparseMode, revparseModeContains, RevwalkSort, Revwalk, createSignature, StatusShow, Statuses, StatusesIter, StatusEntry, isValidTagName, Tag, TreeWalkMode, Tree, TreeIter, TreeEntry } = nativeBinding
314
314
 
315
+ module.exports.AnnotatedCommit = AnnotatedCommit
315
316
  module.exports.Blame = Blame
316
317
  module.exports.BlameHunks = BlameHunks
317
318
  module.exports.BlameHunksByLine = BlameHunksByLine
@@ -347,6 +348,7 @@ module.exports.Index = Index
347
348
  module.exports.IndexEntries = IndexEntries
348
349
  module.exports.Mailmap = Mailmap
349
350
  module.exports.createMailmapFromBuffer = createMailmapFromBuffer
351
+ module.exports.FileFavor = FileFavor
350
352
  module.exports.ObjectType = ObjectType
351
353
  module.exports.GitObject = GitObject
352
354
  module.exports.isValidOid = isValidOid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-git",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-next.135+be674ce",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/toss/es-git.git"
14
14
  },
15
15
  "license": "MIT",
16
- "packageManager": "yarn@4.6.0",
16
+ "packageManager": "yarn@4.9.1",
17
17
  "napi": {
18
18
  "name": "es-git",
19
19
  "triples": {
@@ -57,15 +57,15 @@
57
57
  "vitest": "^3.0.5"
58
58
  },
59
59
  "optionalDependencies": {
60
- "es-git-darwin-x64": "0.3.0",
61
- "es-git-darwin-arm64": "0.3.0",
62
- "es-git-win32-x64-msvc": "0.3.0",
63
- "es-git-win32-arm64-msvc": "0.3.0",
64
- "es-git-linux-x64-gnu": "0.3.0",
65
- "es-git-linux-x64-musl": "0.3.0",
66
- "es-git-android-arm64": "0.3.0",
67
- "es-git-linux-arm64-gnu": "0.3.0",
68
- "es-git-linux-arm64-musl": "0.3.0",
69
- "es-git-android-arm-eabi": "0.3.0"
60
+ "es-git-darwin-x64": "0.4.0-next.135+be674ce",
61
+ "es-git-darwin-arm64": "0.4.0-next.135+be674ce",
62
+ "es-git-win32-x64-msvc": "0.4.0-next.135+be674ce",
63
+ "es-git-win32-arm64-msvc": "0.4.0-next.135+be674ce",
64
+ "es-git-linux-x64-gnu": "0.4.0-next.135+be674ce",
65
+ "es-git-linux-x64-musl": "0.4.0-next.135+be674ce",
66
+ "es-git-android-arm64": "0.4.0-next.135+be674ce",
67
+ "es-git-linux-arm64-gnu": "0.4.0-next.135+be674ce",
68
+ "es-git-linux-arm64-musl": "0.4.0-next.135+be674ce",
69
+ "es-git-android-arm-eabi": "0.4.0-next.135+be674ce"
70
70
  }
71
71
  }