@statewalker/vcs-commands 0.1.1

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 (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +591 -0
  3. package/dist/commands/add-command.d.ts +170 -0
  4. package/dist/commands/add-command.d.ts.map +1 -0
  5. package/dist/commands/blame-command.d.ts +267 -0
  6. package/dist/commands/blame-command.d.ts.map +1 -0
  7. package/dist/commands/branch-command.d.ts +211 -0
  8. package/dist/commands/branch-command.d.ts.map +1 -0
  9. package/dist/commands/checkout-command.d.ts +261 -0
  10. package/dist/commands/checkout-command.d.ts.map +1 -0
  11. package/dist/commands/cherry-pick-command.d.ts +128 -0
  12. package/dist/commands/cherry-pick-command.d.ts.map +1 -0
  13. package/dist/commands/clean-command.d.ts +91 -0
  14. package/dist/commands/clean-command.d.ts.map +1 -0
  15. package/dist/commands/clone-command.d.ts +233 -0
  16. package/dist/commands/clone-command.d.ts.map +1 -0
  17. package/dist/commands/commit-command.d.ts +199 -0
  18. package/dist/commands/commit-command.d.ts.map +1 -0
  19. package/dist/commands/describe-command.d.ts +175 -0
  20. package/dist/commands/describe-command.d.ts.map +1 -0
  21. package/dist/commands/diff-command.d.ts +96 -0
  22. package/dist/commands/diff-command.d.ts.map +1 -0
  23. package/dist/commands/fetch-command.d.ts +266 -0
  24. package/dist/commands/fetch-command.d.ts.map +1 -0
  25. package/dist/commands/gc-command.d.ts +83 -0
  26. package/dist/commands/gc-command.d.ts.map +1 -0
  27. package/dist/commands/index.d.ts +32 -0
  28. package/dist/commands/index.d.ts.map +1 -0
  29. package/dist/commands/index.js +2 -0
  30. package/dist/commands/init-command.d.ts +175 -0
  31. package/dist/commands/init-command.d.ts.map +1 -0
  32. package/dist/commands/log-command.d.ts +246 -0
  33. package/dist/commands/log-command.d.ts.map +1 -0
  34. package/dist/commands/ls-remote-command.d.ts +122 -0
  35. package/dist/commands/ls-remote-command.d.ts.map +1 -0
  36. package/dist/commands/merge-command.d.ts +169 -0
  37. package/dist/commands/merge-command.d.ts.map +1 -0
  38. package/dist/commands/pack-refs-command.d.ts +57 -0
  39. package/dist/commands/pack-refs-command.d.ts.map +1 -0
  40. package/dist/commands/pull-command.d.ts +111 -0
  41. package/dist/commands/pull-command.d.ts.map +1 -0
  42. package/dist/commands/push-command.d.ts +220 -0
  43. package/dist/commands/push-command.d.ts.map +1 -0
  44. package/dist/commands/rebase-command.d.ts +186 -0
  45. package/dist/commands/rebase-command.d.ts.map +1 -0
  46. package/dist/commands/reflog-command.d.ts +45 -0
  47. package/dist/commands/reflog-command.d.ts.map +1 -0
  48. package/dist/commands/remote-command.d.ts +205 -0
  49. package/dist/commands/remote-command.d.ts.map +1 -0
  50. package/dist/commands/reset-command.d.ts +114 -0
  51. package/dist/commands/reset-command.d.ts.map +1 -0
  52. package/dist/commands/revert-command.d.ts +129 -0
  53. package/dist/commands/revert-command.d.ts.map +1 -0
  54. package/dist/commands/rm-command.d.ts +72 -0
  55. package/dist/commands/rm-command.d.ts.map +1 -0
  56. package/dist/commands/stash-apply-command.d.ts +132 -0
  57. package/dist/commands/stash-apply-command.d.ts.map +1 -0
  58. package/dist/commands/stash-create-command.d.ts +137 -0
  59. package/dist/commands/stash-create-command.d.ts.map +1 -0
  60. package/dist/commands/stash-drop-command.d.ts +63 -0
  61. package/dist/commands/stash-drop-command.d.ts.map +1 -0
  62. package/dist/commands/stash-list-command.d.ts +42 -0
  63. package/dist/commands/stash-list-command.d.ts.map +1 -0
  64. package/dist/commands/status-command.d.ts +55 -0
  65. package/dist/commands/status-command.d.ts.map +1 -0
  66. package/dist/commands/tag-command.d.ts +155 -0
  67. package/dist/commands/tag-command.d.ts.map +1 -0
  68. package/dist/commands/tree-restore.d.ts +51 -0
  69. package/dist/commands/tree-restore.d.ts.map +1 -0
  70. package/dist/commands-COO4tJhv.js +10274 -0
  71. package/dist/core-commands/add.command.d.ts +71 -0
  72. package/dist/core-commands/add.command.d.ts.map +1 -0
  73. package/dist/core-commands/add.command.impl.d.ts +53 -0
  74. package/dist/core-commands/add.command.impl.d.ts.map +1 -0
  75. package/dist/core-commands/checkout.command.d.ts +103 -0
  76. package/dist/core-commands/checkout.command.d.ts.map +1 -0
  77. package/dist/core-commands/checkout.command.impl.d.ts +114 -0
  78. package/dist/core-commands/checkout.command.impl.d.ts.map +1 -0
  79. package/dist/core-commands/index.d.ts +6 -0
  80. package/dist/core-commands/index.d.ts.map +1 -0
  81. package/dist/errors/add-errors.d.ts +16 -0
  82. package/dist/errors/add-errors.d.ts.map +1 -0
  83. package/dist/errors/checkout-errors.d.ts +24 -0
  84. package/dist/errors/checkout-errors.d.ts.map +1 -0
  85. package/dist/errors/command-errors.d.ts +38 -0
  86. package/dist/errors/command-errors.d.ts.map +1 -0
  87. package/dist/errors/commit-errors.d.ts +27 -0
  88. package/dist/errors/commit-errors.d.ts.map +1 -0
  89. package/dist/errors/git-api-error.d.ts +9 -0
  90. package/dist/errors/git-api-error.d.ts.map +1 -0
  91. package/dist/errors/index.d.ts +13 -0
  92. package/dist/errors/index.d.ts.map +1 -0
  93. package/dist/errors/index.js +509 -0
  94. package/dist/errors/merge-errors.d.ts +63 -0
  95. package/dist/errors/merge-errors.d.ts.map +1 -0
  96. package/dist/errors/rebase-errors.d.ts +21 -0
  97. package/dist/errors/rebase-errors.d.ts.map +1 -0
  98. package/dist/errors/ref-errors.d.ts +63 -0
  99. package/dist/errors/ref-errors.d.ts.map +1 -0
  100. package/dist/errors/remote-errors.d.ts +16 -0
  101. package/dist/errors/remote-errors.d.ts.map +1 -0
  102. package/dist/errors/stash-errors.d.ts +24 -0
  103. package/dist/errors/stash-errors.d.ts.map +1 -0
  104. package/dist/errors/tag-errors.d.ts +11 -0
  105. package/dist/errors/tag-errors.d.ts.map +1 -0
  106. package/dist/errors/transport-errors.d.ts +42 -0
  107. package/dist/errors/transport-errors.d.ts.map +1 -0
  108. package/dist/git-command.d.ts +139 -0
  109. package/dist/git-command.d.ts.map +1 -0
  110. package/dist/git.d.ts +637 -0
  111. package/dist/git.d.ts.map +1 -0
  112. package/dist/index.d.ts +8 -0
  113. package/dist/index.d.ts.map +1 -0
  114. package/dist/index.js +5 -0
  115. package/dist/pack-import/index.d.ts +8 -0
  116. package/dist/pack-import/index.d.ts.map +1 -0
  117. package/dist/pack-import/pack-import.d.ts +11 -0
  118. package/dist/pack-import/pack-import.d.ts.map +1 -0
  119. package/dist/remote-config/index.d.ts +7 -0
  120. package/dist/remote-config/index.d.ts.map +1 -0
  121. package/dist/remote-config/remote-config-store.d.ts +93 -0
  122. package/dist/remote-config/remote-config-store.d.ts.map +1 -0
  123. package/dist/rename/index.d.ts +5 -0
  124. package/dist/rename/index.d.ts.map +1 -0
  125. package/dist/rename/similarity-index.d.ts +64 -0
  126. package/dist/rename/similarity-index.d.ts.map +1 -0
  127. package/dist/results/cherry-pick-result.d.ts +33 -0
  128. package/dist/results/cherry-pick-result.d.ts.map +1 -0
  129. package/dist/results/clone-result.d.ts +24 -0
  130. package/dist/results/clone-result.d.ts.map +1 -0
  131. package/dist/results/diff-entry.d.ts +77 -0
  132. package/dist/results/diff-entry.d.ts.map +1 -0
  133. package/dist/results/diff-formatter.d.ts +149 -0
  134. package/dist/results/diff-formatter.d.ts.map +1 -0
  135. package/dist/results/fetch-result.d.ts +78 -0
  136. package/dist/results/fetch-result.d.ts.map +1 -0
  137. package/dist/results/index.d.ts +14 -0
  138. package/dist/results/index.d.ts.map +1 -0
  139. package/dist/results/index.js +247 -0
  140. package/dist/results/init-result.d.ts +23 -0
  141. package/dist/results/init-result.d.ts.map +1 -0
  142. package/dist/results/merge-result.d.ts +117 -0
  143. package/dist/results/merge-result.d.ts.map +1 -0
  144. package/dist/results/pull-result.d.ts +24 -0
  145. package/dist/results/pull-result.d.ts.map +1 -0
  146. package/dist/results/push-result.d.ts +71 -0
  147. package/dist/results/push-result.d.ts.map +1 -0
  148. package/dist/results/rebase-result.d.ts +108 -0
  149. package/dist/results/rebase-result.d.ts.map +1 -0
  150. package/dist/results/revert-result.d.ts +33 -0
  151. package/dist/results/revert-result.d.ts.map +1 -0
  152. package/dist/results/stash-result.d.ts +48 -0
  153. package/dist/results/stash-result.d.ts.map +1 -0
  154. package/dist/results/status-result.d.ts +48 -0
  155. package/dist/results/status-result.d.ts.map +1 -0
  156. package/dist/status-result-BwAyxq6R.js +409 -0
  157. package/dist/transport-command.d.ts +83 -0
  158. package/dist/transport-command.d.ts.map +1 -0
  159. package/dist/tree-merge/index.d.ts +8 -0
  160. package/dist/tree-merge/index.d.ts.map +1 -0
  161. package/dist/tree-merge/tree-merge.d.ts +41 -0
  162. package/dist/tree-merge/tree-merge.d.ts.map +1 -0
  163. package/dist/types.d.ts +64 -0
  164. package/dist/types.d.ts.map +1 -0
  165. package/package.json +62 -0
@@ -0,0 +1,261 @@
1
+ /**
2
+ * CheckoutCommand - Switch branches or restore files.
3
+ *
4
+ * Implements JGit-compatible fluent API for `git checkout` command:
5
+ * - Checkout branches, tags, or commits
6
+ * - Create new branches on checkout (-b flag)
7
+ * - Restore specific paths from index or commits
8
+ * - Detached HEAD mode for commit checkout
9
+ *
10
+ * Reference: jgit/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Checkout existing branch
15
+ * await git.checkout().setName("feature").call();
16
+ *
17
+ * // Create and checkout new branch
18
+ * await git.checkout()
19
+ * .setCreateBranch(true)
20
+ * .setName("newbranch")
21
+ * .call();
22
+ *
23
+ * // Checkout paths from index
24
+ * await git.checkout()
25
+ * .addPath("file.txt")
26
+ * .call();
27
+ *
28
+ * // Checkout paths from specific commit
29
+ * await git.checkout()
30
+ * .setStartPoint("HEAD~1")
31
+ * .addPath("file.txt")
32
+ * .call();
33
+ * ```
34
+ */
35
+ import { type Ref } from "@statewalker/vcs-core";
36
+ import { GitCommand } from "../git-command.js";
37
+ /**
38
+ * Stage to check out for conflicting files.
39
+ */
40
+ export declare enum CheckoutStage {
41
+ /** Base stage (ancestor) */
42
+ BASE = 1,
43
+ /** Ours stage (current branch) */
44
+ OURS = 2,
45
+ /** Theirs stage (merged branch) */
46
+ THEIRS = 3
47
+ }
48
+ /**
49
+ * Status of checkout operation.
50
+ */
51
+ export declare enum CheckoutStatus {
52
+ /** Checkout completed successfully */
53
+ OK = "OK",
54
+ /** Checkout had conflicts */
55
+ CONFLICTS = "CONFLICTS",
56
+ /** Some files couldn't be deleted */
57
+ NONDELETED = "NONDELETED",
58
+ /** Checkout not attempted */
59
+ NOT_TRIED = "NOT_TRIED",
60
+ /** Checkout failed with error */
61
+ ERROR = "ERROR"
62
+ }
63
+ /**
64
+ * Result of CheckoutCommand execution.
65
+ */
66
+ export interface CheckoutResult {
67
+ /** Status of the operation */
68
+ readonly status: CheckoutStatus;
69
+ /** Files that were updated */
70
+ readonly updated: string[];
71
+ /** Files that were removed */
72
+ readonly removed: string[];
73
+ /** Files that couldn't be checked out (conflicts) */
74
+ readonly conflicts: string[];
75
+ /** The ref that was checked out (null for path checkout) */
76
+ readonly ref: Ref | null;
77
+ }
78
+ /**
79
+ * Command to checkout branches, commits, or paths.
80
+ *
81
+ * Based on JGit's CheckoutCommand. Supports both branch checkout
82
+ * (switching HEAD) and path checkout (restoring files).
83
+ */
84
+ export declare class CheckoutCommand extends GitCommand<CheckoutResult> {
85
+ private name;
86
+ private createBranch;
87
+ private orphan;
88
+ private force;
89
+ private forceRefUpdate;
90
+ private startPoint;
91
+ private paths;
92
+ private allPaths;
93
+ private stage;
94
+ /**
95
+ * Set the name of the branch or commit to check out.
96
+ *
97
+ * When checking out a branch, HEAD becomes a symbolic ref to that branch.
98
+ * When checking out a commit/tag, HEAD becomes detached.
99
+ *
100
+ * @param name Branch name, tag name, or commit ID
101
+ * @returns this for chaining
102
+ */
103
+ setName(name: string): this;
104
+ /**
105
+ * Set whether to create a new branch.
106
+ *
107
+ * If true, a new branch with setName() will be created at setStartPoint()
108
+ * (or HEAD if not specified) and checked out.
109
+ *
110
+ * Equivalent to `git checkout -b <name>`.
111
+ *
112
+ * @param createBranch Whether to create a new branch
113
+ * @returns this for chaining
114
+ */
115
+ setCreateBranch(createBranch: boolean): this;
116
+ /**
117
+ * Set whether to create an orphan branch.
118
+ *
119
+ * An orphan branch has no parent commits. The index and working tree
120
+ * are set to the start point, but no commit is made.
121
+ *
122
+ * Equivalent to `git checkout --orphan <name>`.
123
+ *
124
+ * @param orphan Whether to create orphan branch
125
+ * @returns this for chaining
126
+ */
127
+ setOrphan(orphan: boolean): this;
128
+ /**
129
+ * Set whether to force checkout.
130
+ *
131
+ * If true, checkout will proceed even if there are local changes
132
+ * that would be overwritten.
133
+ *
134
+ * Equivalent to `git checkout -f` or `git checkout --force`.
135
+ *
136
+ * @param force Whether to force checkout
137
+ * @returns this for chaining
138
+ */
139
+ setForced(force: boolean): this;
140
+ /**
141
+ * Set whether to force ref update.
142
+ *
143
+ * If true and the branch already exists, it will be reset to
144
+ * the start point.
145
+ *
146
+ * @param forceRefUpdate Whether to force ref update
147
+ * @returns this for chaining
148
+ */
149
+ setForceRefUpdate(forceRefUpdate: boolean): this;
150
+ /**
151
+ * Set the start point for branch creation or path checkout.
152
+ *
153
+ * For branch creation: the commit where the new branch starts.
154
+ * For path checkout: the commit to restore files from (default: index).
155
+ *
156
+ * @param startPoint Commit ID, branch name, or tag name
157
+ * @returns this for chaining
158
+ */
159
+ setStartPoint(startPoint: string): this;
160
+ /**
161
+ * Add a path to checkout.
162
+ *
163
+ * When paths are specified, this becomes a path checkout rather than
164
+ * a branch checkout. Files are restored from index or setStartPoint().
165
+ *
166
+ * @param path Path to checkout
167
+ * @returns this for chaining
168
+ */
169
+ addPath(path: string): this;
170
+ /**
171
+ * Set whether to checkout all paths.
172
+ *
173
+ * When true, all files in the index (or start point) are checked out.
174
+ *
175
+ * @param allPaths Whether to checkout all paths
176
+ * @returns this for chaining
177
+ */
178
+ setAllPaths(allPaths: boolean): this;
179
+ /**
180
+ * Set the stage to checkout for conflicting files.
181
+ *
182
+ * Only applicable for path checkout from index when files have
183
+ * conflicts (multiple stages).
184
+ *
185
+ * @param stage Stage to checkout (OURS, THEIRS, or BASE)
186
+ * @returns this for chaining
187
+ */
188
+ setStage(stage: CheckoutStage): this;
189
+ /**
190
+ * Execute the checkout command.
191
+ *
192
+ * @returns Result with status and affected files
193
+ * @throws RefNotFoundError if target cannot be resolved
194
+ */
195
+ call(): Promise<CheckoutResult>;
196
+ /**
197
+ * Checkout paths from index or commit.
198
+ */
199
+ private checkoutPaths;
200
+ /**
201
+ * Detect conflicts between staged changes and checkout target.
202
+ *
203
+ * Returns list of paths that have uncommitted staged changes.
204
+ * Git prevents checkout when staged changes differ from HEAD,
205
+ * as they would be lost during checkout.
206
+ *
207
+ * @param _targetTreeId Target tree to checkout (unused for now, checks HEAD vs staging)
208
+ * @returns Array of conflicting paths
209
+ */
210
+ private detectCheckoutConflicts;
211
+ /**
212
+ * Checkout a branch or commit.
213
+ */
214
+ private checkoutBranch;
215
+ /**
216
+ * Check if the store supports file writes (not a bare repository).
217
+ *
218
+ * A repository is considered "bare" if it doesn't have a worktree interface.
219
+ */
220
+ private hasFileWriteSupport;
221
+ /**
222
+ * Write all files from a tree to the working directory.
223
+ *
224
+ * @param treeId The tree ID to checkout
225
+ * @param basePath The base path prefix for entries in this tree
226
+ */
227
+ private writeTreeToWorkdir;
228
+ /**
229
+ * Checkout a path from the staging index.
230
+ */
231
+ private checkoutPathFromIndex;
232
+ /**
233
+ * Checkout a path from a tree.
234
+ */
235
+ private checkoutPathFromTree;
236
+ /**
237
+ * Get all paths from staging or tree.
238
+ */
239
+ private getAllPaths;
240
+ /**
241
+ * Collect all paths from a tree recursively.
242
+ */
243
+ private collectTreePaths;
244
+ /**
245
+ * Collect tree entries into a map.
246
+ */
247
+ private collectTreeEntries;
248
+ /**
249
+ * Resolve a ref to a tree ID.
250
+ */
251
+ private resolveTreeId;
252
+ /**
253
+ * Resolve a ref to a commit ID.
254
+ */
255
+ private resolveCommitId;
256
+ /**
257
+ * Collect object IDs from a tree recursively.
258
+ */
259
+ private collectTreeObjectIds;
260
+ }
261
+ //# sourceMappingURL=checkout-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-command.d.ts","sourceRoot":"","sources":["../../src/commands/checkout-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAA2B,KAAK,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAU1E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,oBAAY,aAAa;IACvB,4BAA4B;IAC5B,IAAI,IAAI;IACR,kCAAkC;IAClC,IAAI,IAAI;IACR,mCAAmC;IACnC,MAAM,IAAI;CACX;AAED;;GAEG;AACH,oBAAY,cAAc;IACxB,sCAAsC;IACtC,EAAE,OAAO;IACT,6BAA6B;IAC7B,SAAS,cAAc;IACvB,qCAAqC;IACrC,UAAU,eAAe;IACzB,6BAA6B;IAC7B,SAAS,cAAc;IACvB,iCAAiC;IACjC,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAE3B,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAE3B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAE7B,4DAA4D;IAC5D,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,UAAU,CAAC,cAAc,CAAC;IAC7D,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CA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;IAM3B;;OAEG;YACW,eAAe;IAqB7B;;OAEG;YACW,oBAAoB;CAenC"}
@@ -0,0 +1,128 @@
1
+ import { GitCommand } from "../git-command.js";
2
+ import { type CherryPickResult } from "../results/cherry-pick-result.js";
3
+ import { type ContentMergeStrategy, MergeStrategy } from "../results/merge-result.js";
4
+ /**
5
+ * Cherry-pick commits onto current branch.
6
+ *
7
+ * Equivalent to `git cherry-pick`.
8
+ *
9
+ * Based on JGit's CherryPickCommand.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // Cherry-pick a single commit
14
+ * const result = await git.cherryPick()
15
+ * .include(commitId)
16
+ * .call();
17
+ *
18
+ * // Cherry-pick without committing
19
+ * const result = await git.cherryPick()
20
+ * .include(commitId)
21
+ * .setNoCommit(true)
22
+ * .call();
23
+ *
24
+ * // Cherry-pick a merge commit
25
+ * const result = await git.cherryPick()
26
+ * .include(mergeCommitId)
27
+ * .setMainlineParentNumber(1)
28
+ * .call();
29
+ * ```
30
+ */
31
+ export declare class CherryPickCommand extends GitCommand<CherryPickResult> {
32
+ private includes;
33
+ private noCommit;
34
+ private mainlineParent?;
35
+ private strategy;
36
+ private contentStrategy?;
37
+ private ourCommitName?;
38
+ private reflogPrefix;
39
+ /**
40
+ * Add a commit to cherry-pick.
41
+ *
42
+ * @param refOrId Commit ID or reference to cherry-pick
43
+ */
44
+ include(refOrId: string): this;
45
+ /**
46
+ * Set whether to commit after cherry-pick.
47
+ *
48
+ * When true, changes are staged but not committed.
49
+ *
50
+ * @param noCommit Whether to skip committing (default: false)
51
+ */
52
+ setNoCommit(noCommit: boolean): this;
53
+ /**
54
+ * Set mainline parent number for cherry-picking merge commits.
55
+ *
56
+ * For regular commits, this is not needed. For merge commits,
57
+ * this specifies which parent to diff against (1-indexed).
58
+ *
59
+ * @param parent Parent number (1 = first parent, 2 = second parent)
60
+ */
61
+ setMainlineParentNumber(parent: number): this;
62
+ /**
63
+ * Set the merge strategy.
64
+ *
65
+ * Default is "recursive".
66
+ *
67
+ * @param strategy Merge strategy to use
68
+ */
69
+ setStrategy(strategy: MergeStrategy): this;
70
+ /**
71
+ * Get the merge strategy.
72
+ */
73
+ getStrategy(): MergeStrategy;
74
+ /**
75
+ * Set the content merge strategy for handling conflicts.
76
+ *
77
+ * @param contentStrategy Content merge strategy
78
+ */
79
+ setContentMergeStrategy(contentStrategy: ContentMergeStrategy): this;
80
+ /**
81
+ * Get the content merge strategy.
82
+ */
83
+ getContentMergeStrategy(): ContentMergeStrategy | undefined;
84
+ /**
85
+ * Set the name to be used for "ours" in conflict markers.
86
+ *
87
+ * @param name Name for ours side (default: HEAD)
88
+ */
89
+ setOurCommitName(name: string): this;
90
+ /**
91
+ * Get the name used for "ours" in conflict markers.
92
+ */
93
+ getOurCommitName(): string | undefined;
94
+ /**
95
+ * Set the reflog prefix.
96
+ *
97
+ * @param prefix Reflog message prefix (default: "cherry-pick:")
98
+ */
99
+ setReflogPrefix(prefix: string): this;
100
+ /**
101
+ * Get the reflog prefix.
102
+ */
103
+ getReflogPrefix(): string;
104
+ call(): Promise<CherryPickResult>;
105
+ /**
106
+ * Cherry-pick a single commit.
107
+ */
108
+ private cherryPickOne;
109
+ /**
110
+ * Collect all blob entries from a tree recursively.
111
+ */
112
+ private collectTreeEntries;
113
+ /**
114
+ * Perform three-way merge for cherry-pick.
115
+ *
116
+ * The cherry-pick merge is: apply changes from parent->commit onto head.
117
+ */
118
+ private threeWayMerge;
119
+ /**
120
+ * Merge a single entry in three-way merge.
121
+ */
122
+ private mergeEntry;
123
+ /**
124
+ * Write conflict entries to staging.
125
+ */
126
+ private writeConflictStaging;
127
+ }
128
+ //# sourceMappingURL=cherry-pick-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cherry-pick-command.d.ts","sourceRoot":"","sources":["../../src/commands/cherry-pick-command.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,gBAAgB,EAAo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AkB;IAoBhC;;;;OAIG;IACH,OAAO,CAAC,aAAa;IA0BrB;;OAEG;IACH,OAAO,CAAC,UAAU;IAqElB;;OAEG;YACW,oBAAoB;CA8DnC"}
@@ -0,0 +1,91 @@
1
+ import { GitCommand } from "../git-command.js";
2
+ /**
3
+ * Result of a clean operation
4
+ */
5
+ export interface CleanResult {
6
+ /** Files that were (or would be) removed */
7
+ cleaned: Set<string>;
8
+ /** Whether this was a dry run (no files actually removed) */
9
+ dryRun: boolean;
10
+ }
11
+ /**
12
+ * Remove untracked files from working tree.
13
+ *
14
+ * Equivalent to `git clean`.
15
+ *
16
+ * Based on JGit's CleanCommand.
17
+ *
18
+ * This command DELETES files from the working tree when dry-run is disabled.
19
+ * Dry-run is the default for exactly that reason: a caller must opt in to
20
+ * destruction with `setDryRun(false)`. The returned `dryRun` flag always
21
+ * reports what the caller asked for, so a `false` there means files were
22
+ * really removed.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Preview what would be cleaned (dry run - the default)
27
+ * const result = await git.clean()
28
+ * .setDryRun(true)
29
+ * .call();
30
+ * for (const file of result.cleaned) {
31
+ * console.log(`Would remove: ${file}`);
32
+ * }
33
+ *
34
+ * // Actually delete the untracked files
35
+ * const result = await git.clean()
36
+ * .setDryRun(false)
37
+ * .call();
38
+ *
39
+ * // Include directories
40
+ * const result = await git.clean()
41
+ * .setCleanDirectories(true)
42
+ * .call();
43
+ * ```
44
+ */
45
+ export declare class CleanCommand extends GitCommand<CleanResult> {
46
+ private paths;
47
+ private dryRun;
48
+ private directories;
49
+ private ignore;
50
+ /**
51
+ * Limit clean to specific paths.
52
+ *
53
+ * @param paths Set of paths to clean
54
+ */
55
+ setPaths(paths: Set<string>): this;
56
+ /**
57
+ * Set dry run mode.
58
+ *
59
+ * When true (default), no files are actually deleted.
60
+ * The result will still contain the list of files that would be cleaned.
61
+ *
62
+ * @param dryRun Whether to run in dry-run mode
63
+ */
64
+ setDryRun(dryRun: boolean): this;
65
+ /**
66
+ * Set whether to also clean directories.
67
+ *
68
+ * @param directories Whether to clean directories
69
+ */
70
+ setCleanDirectories(directories: boolean): this;
71
+ /**
72
+ * Set whether to respect .gitignore patterns.
73
+ *
74
+ * When true (default), ignored files are not cleaned.
75
+ * When false, ignored files are also cleaned.
76
+ *
77
+ * @param ignore Whether to respect .gitignore
78
+ */
79
+ setIgnore(ignore: boolean): this;
80
+ /**
81
+ * Execute the clean command.
82
+ *
83
+ * @returns CleanResult with set of cleaned files
84
+ */
85
+ call(): Promise<CleanResult>;
86
+ /**
87
+ * Collect all paths from a tree recursively.
88
+ */
89
+ private collectTreePaths;
90
+ }
91
+ //# sourceMappingURL=clean-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clean-command.d.ts","sourceRoot":"","sources":["../../src/commands/clean-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,6DAA6D;IAC7D,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,YAAa,SAAQ,UAAU,CAAC,WAAW,CAAC;IACvD,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAQ;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAIjC;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAI/B;IAED;;;;OAIG;IACH,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAI9C;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAI/B;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,CAyFjC;IAED;;OAEG;YACW,gBAAgB;CAgB/B"}