git-chopstick-core 0.1.1 → 0.1.2

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 (426) hide show
  1. package/README.md +324 -32
  2. package/dist/git/add.d.ts +9 -0
  3. package/dist/git/add.js +11 -0
  4. package/dist/git/add.js.map +1 -0
  5. package/dist/git/apply.d.ts +33 -0
  6. package/dist/git/apply.js +103 -0
  7. package/dist/git/apply.js.map +1 -0
  8. package/dist/git/authentication.d.ts +5 -0
  9. package/dist/git/authentication.js +19 -0
  10. package/dist/git/authentication.js.map +1 -0
  11. package/dist/git/branch.d.ts +43 -0
  12. package/dist/git/branch.js +150 -0
  13. package/dist/git/branch.js.map +1 -0
  14. package/dist/git/checkout-index.d.ts +19 -0
  15. package/dist/git/checkout-index.js +29 -0
  16. package/dist/git/checkout-index.js.map +1 -0
  17. package/dist/git/checkout.d.ts +46 -0
  18. package/dist/git/checkout.js +126 -0
  19. package/dist/git/checkout.js.map +1 -0
  20. package/dist/git/cherry-pick.d.ts +82 -0
  21. package/dist/git/cherry-pick.js +371 -0
  22. package/dist/git/cherry-pick.js.map +1 -0
  23. package/dist/git/clean.d.ts +5 -0
  24. package/dist/git/clean.js +8 -0
  25. package/dist/git/clean.js.map +1 -0
  26. package/dist/git/clone.d.ts +22 -0
  27. package/dist/git/clone.js +58 -0
  28. package/dist/git/clone.js.map +1 -0
  29. package/dist/git/coerce-to-buffer.d.ts +1 -0
  30. package/dist/git/coerce-to-buffer.js +2 -0
  31. package/dist/git/coerce-to-buffer.js.map +1 -0
  32. package/dist/git/coerce-to-string.d.ts +1 -0
  33. package/dist/git/coerce-to-string.js +2 -0
  34. package/dist/git/coerce-to-string.js.map +1 -0
  35. package/dist/git/commit.d.ts +25 -0
  36. package/dist/git/commit.js +99 -0
  37. package/dist/git/commit.js.map +1 -0
  38. package/dist/git/config.d.ts +98 -0
  39. package/dist/git/config.js +249 -0
  40. package/dist/git/config.js.map +1 -0
  41. package/dist/git/core.d.ts +167 -0
  42. package/dist/git/core.js +368 -0
  43. package/dist/git/core.js.map +1 -0
  44. package/dist/git/create-tail-stream.d.ts +4 -0
  45. package/dist/git/create-tail-stream.js +30 -0
  46. package/dist/git/create-tail-stream.js.map +1 -0
  47. package/dist/git/credential.d.ts +5 -0
  48. package/dist/git/credential.js +64 -0
  49. package/dist/git/credential.js.map +1 -0
  50. package/dist/git/description.d.ts +5 -0
  51. package/dist/git/description.js +24 -0
  52. package/dist/git/description.js.map +1 -0
  53. package/dist/git/diff-check.d.ts +7 -0
  54. package/dist/git/diff-check.js +17 -0
  55. package/dist/git/diff-check.js.map +1 -0
  56. package/dist/git/diff-index.d.ts +31 -0
  57. package/dist/git/diff-index.js +76 -0
  58. package/dist/git/diff-index.js.map +1 -0
  59. package/dist/git/diff.d.ts +81 -0
  60. package/dist/git/diff.js +611 -0
  61. package/dist/git/diff.js.map +1 -0
  62. package/dist/git/environment.d.ts +51 -0
  63. package/dist/git/environment.js +97 -0
  64. package/dist/git/environment.js.map +1 -0
  65. package/dist/git/exec.d.ts +109 -0
  66. package/dist/git/exec.js +224 -0
  67. package/dist/git/exec.js.map +1 -0
  68. package/dist/git/fetch.d.ts +25 -0
  69. package/dist/git/fetch.js +100 -0
  70. package/dist/git/fetch.js.map +1 -0
  71. package/dist/git/for-each-ref.d.ts +13 -0
  72. package/dist/git/for-each-ref.js +114 -0
  73. package/dist/git/for-each-ref.js.map +1 -0
  74. package/dist/git/format-patch.d.ts +10 -0
  75. package/dist/git/format-patch.js +16 -0
  76. package/dist/git/format-patch.js.map +1 -0
  77. package/dist/git/git-delimiter-parser.d.ts +38 -0
  78. package/dist/git/git-delimiter-parser.js +79 -0
  79. package/dist/git/git-delimiter-parser.js.map +1 -0
  80. package/dist/git/gitignore.d.ts +26 -0
  81. package/dist/git/gitignore.js +124 -0
  82. package/dist/git/gitignore.js.map +1 -0
  83. package/dist/git/index.d.ts +46 -0
  84. package/dist/git/index.js +47 -0
  85. package/dist/git/index.js.map +1 -0
  86. package/dist/git/init.d.ts +2 -0
  87. package/dist/git/init.js +7 -0
  88. package/dist/git/init.js.map +1 -0
  89. package/dist/git/interpret-trailers.d.ts +88 -0
  90. package/dist/git/interpret-trailers.js +130 -0
  91. package/dist/git/interpret-trailers.js.map +1 -0
  92. package/dist/git/lfs.d.ts +25 -0
  93. package/dist/git/lfs.js +73 -0
  94. package/dist/git/lfs.js.map +1 -0
  95. package/dist/git/log.d.ts +56 -0
  96. package/dist/git/log.js +258 -0
  97. package/dist/git/log.js.map +1 -0
  98. package/dist/git/merge-tree.d.ts +13 -0
  99. package/dist/git/merge-tree.js +24 -0
  100. package/dist/git/merge-tree.js.map +1 -0
  101. package/dist/git/merge.d.ts +50 -0
  102. package/dist/git/merge.js +111 -0
  103. package/dist/git/merge.js.map +1 -0
  104. package/dist/git/multi-operation-terminal-output.d.ts +20 -0
  105. package/dist/git/multi-operation-terminal-output.js +56 -0
  106. package/dist/git/multi-operation-terminal-output.js.map +1 -0
  107. package/dist/git/pull.d.ts +24 -0
  108. package/dist/git/pull.js +91 -0
  109. package/dist/git/pull.js.map +1 -0
  110. package/dist/git/push-terminal-chunk.d.ts +19 -0
  111. package/dist/git/push-terminal-chunk.js +36 -0
  112. package/dist/git/push-terminal-chunk.js.map +1 -0
  113. package/dist/git/push.d.ts +42 -0
  114. package/dist/git/push.js +80 -0
  115. package/dist/git/push.js.map +1 -0
  116. package/dist/git/rebase.d.ts +119 -0
  117. package/dist/git/rebase.js +415 -0
  118. package/dist/git/rebase.js.map +1 -0
  119. package/dist/git/reflog.d.ts +14 -0
  120. package/dist/git/reflog.js +88 -0
  121. package/dist/git/reflog.js.map +1 -0
  122. package/dist/git/refs.d.ts +26 -0
  123. package/dist/git/refs.js +53 -0
  124. package/dist/git/refs.js.map +1 -0
  125. package/dist/git/remote.d.ts +31 -0
  126. package/dist/git/remote.js +81 -0
  127. package/dist/git/remote.js.map +1 -0
  128. package/dist/git/reorder.d.ts +23 -0
  129. package/dist/git/reorder.js +111 -0
  130. package/dist/git/reorder.js.map +1 -0
  131. package/dist/git/reset.d.ts +41 -0
  132. package/dist/git/reset.js +86 -0
  133. package/dist/git/reset.js.map +1 -0
  134. package/dist/git/rev-list.d.ts +67 -0
  135. package/dist/git/rev-list.js +157 -0
  136. package/dist/git/rev-list.js.map +1 -0
  137. package/dist/git/rev-parse.d.ts +24 -0
  138. package/dist/git/rev-parse.js +65 -0
  139. package/dist/git/rev-parse.js.map +1 -0
  140. package/dist/git/revert.d.ts +12 -0
  141. package/dist/git/revert.js +30 -0
  142. package/dist/git/revert.js.map +1 -0
  143. package/dist/git/rm.d.ts +12 -0
  144. package/dist/git/rm.js +22 -0
  145. package/dist/git/rm.js.map +1 -0
  146. package/dist/git/show.d.ts +42 -0
  147. package/dist/git/show.js +59 -0
  148. package/dist/git/show.js.map +1 -0
  149. package/dist/git/spawn.d.ts +18 -0
  150. package/dist/git/spawn.js +16 -0
  151. package/dist/git/spawn.js.map +1 -0
  152. package/dist/git/squash.d.ts +28 -0
  153. package/dist/git/squash.js +127 -0
  154. package/dist/git/squash.js.map +1 -0
  155. package/dist/git/stage.d.ts +21 -0
  156. package/dist/git/stage.js +72 -0
  157. package/dist/git/stage.js.map +1 -0
  158. package/dist/git/stash.d.ts +53 -0
  159. package/dist/git/stash.js +204 -0
  160. package/dist/git/stash.js.map +1 -0
  161. package/dist/git/status.d.ts +39 -0
  162. package/dist/git/status.js +293 -0
  163. package/dist/git/status.js.map +1 -0
  164. package/dist/git/submodule.d.ts +20 -0
  165. package/dist/git/submodule.js +153 -0
  166. package/dist/git/submodule.js.map +1 -0
  167. package/dist/git/tag.d.ts +32 -0
  168. package/dist/git/tag.js +101 -0
  169. package/dist/git/tag.js.map +1 -0
  170. package/dist/git/update-index.d.ts +11 -0
  171. package/dist/git/update-index.js +99 -0
  172. package/dist/git/update-index.js.map +1 -0
  173. package/dist/git/update-ref.d.ts +23 -0
  174. package/dist/git/update-ref.js +32 -0
  175. package/dist/git/update-ref.js.map +1 -0
  176. package/dist/git/var.d.ts +18 -0
  177. package/dist/git/var.js +33 -0
  178. package/dist/git/var.js.map +1 -0
  179. package/dist/git/worktree-include.d.ts +42 -0
  180. package/dist/git/worktree-include.js +109 -0
  181. package/dist/git/worktree-include.js.map +1 -0
  182. package/dist/git/worktree.d.ts +25 -0
  183. package/dist/git/worktree.js +139 -0
  184. package/dist/git/worktree.js.map +1 -0
  185. package/dist/index.d.ts +4 -0
  186. package/dist/index.js +7 -0
  187. package/dist/index.js.map +1 -0
  188. package/dist/lib/api.d.ts +2 -0
  189. package/dist/lib/api.js +7 -0
  190. package/dist/lib/api.js.map +1 -0
  191. package/dist/lib/diff-parser.d.ts +20 -0
  192. package/dist/lib/diff-parser.js +184 -0
  193. package/dist/lib/diff-parser.js.map +1 -0
  194. package/dist/lib/directory-exists.d.ts +1 -0
  195. package/dist/lib/directory-exists.js +11 -0
  196. package/dist/lib/directory-exists.js.map +1 -0
  197. package/dist/lib/errno-exception.d.ts +6 -0
  198. package/dist/lib/errno-exception.js +6 -0
  199. package/dist/lib/errno-exception.js.map +1 -0
  200. package/dist/lib/fatal-error.d.ts +4 -0
  201. package/dist/lib/fatal-error.js +18 -0
  202. package/dist/lib/fatal-error.js.map +1 -0
  203. package/dist/lib/feature-flag.d.ts +14 -0
  204. package/dist/lib/feature-flag.js +25 -0
  205. package/dist/lib/feature-flag.js.map +1 -0
  206. package/dist/lib/file-system.d.ts +1 -0
  207. package/dist/lib/file-system.js +7 -0
  208. package/dist/lib/file-system.js.map +1 -0
  209. package/dist/lib/get-old-path.d.ts +2 -0
  210. package/dist/lib/get-old-path.js +9 -0
  211. package/dist/lib/get-old-path.js.map +1 -0
  212. package/dist/lib/git/environment.d.ts +3 -0
  213. package/dist/lib/git/environment.js +7 -0
  214. package/dist/lib/git/environment.js.map +1 -0
  215. package/dist/lib/git-perf.d.ts +1 -0
  216. package/dist/lib/git-perf.js +4 -0
  217. package/dist/lib/git-perf.js.map +1 -0
  218. package/dist/lib/helpers/default-branch.d.ts +1 -0
  219. package/dist/lib/helpers/default-branch.js +4 -0
  220. package/dist/lib/helpers/default-branch.js.map +1 -0
  221. package/dist/lib/helpers/path.d.ts +1 -0
  222. package/dist/lib/helpers/path.js +5 -0
  223. package/dist/lib/helpers/path.js.map +1 -0
  224. package/dist/lib/hooks/with-hooks-env.d.ts +3 -0
  225. package/dist/lib/hooks/with-hooks-env.js +4 -0
  226. package/dist/lib/hooks/with-hooks-env.js.map +1 -0
  227. package/dist/lib/merge.d.ts +1 -0
  228. package/dist/lib/merge.js +4 -0
  229. package/dist/lib/merge.js.map +1 -0
  230. package/dist/lib/noop.d.ts +1 -0
  231. package/dist/lib/noop.js +2 -0
  232. package/dist/lib/noop.js.map +1 -0
  233. package/dist/lib/patch-formatter.d.ts +5 -0
  234. package/dist/lib/patch-formatter.js +7 -0
  235. package/dist/lib/patch-formatter.js.map +1 -0
  236. package/dist/lib/path-exists.d.ts +1 -0
  237. package/dist/lib/path-exists.js +3 -0
  238. package/dist/lib/path-exists.js.map +1 -0
  239. package/dist/lib/progress/from-process.d.ts +2 -0
  240. package/dist/lib/progress/from-process.js +4 -0
  241. package/dist/lib/progress/from-process.js.map +1 -0
  242. package/dist/lib/progress/index.d.ts +49 -0
  243. package/dist/lib/progress/index.js +32 -0
  244. package/dist/lib/progress/index.js.map +1 -0
  245. package/dist/lib/progress/revert.d.ts +8 -0
  246. package/dist/lib/progress/revert.js +15 -0
  247. package/dist/lib/progress/revert.js.map +1 -0
  248. package/dist/lib/rebase.d.ts +1 -0
  249. package/dist/lib/rebase.js +4 -0
  250. package/dist/lib/rebase.js.map +1 -0
  251. package/dist/lib/remove-remote-prefix.d.ts +1 -0
  252. package/dist/lib/remove-remote-prefix.js +5 -0
  253. package/dist/lib/remove-remote-prefix.js.map +1 -0
  254. package/dist/lib/resolve-git-proxy.d.ts +1 -0
  255. package/dist/lib/resolve-git-proxy.js +4 -0
  256. package/dist/lib/resolve-git-proxy.js.map +1 -0
  257. package/dist/lib/round.d.ts +1 -0
  258. package/dist/lib/round.js +5 -0
  259. package/dist/lib/round.js.map +1 -0
  260. package/dist/lib/split-buffer.d.ts +1 -0
  261. package/dist/lib/split-buffer.js +15 -0
  262. package/dist/lib/split-buffer.js.map +1 -0
  263. package/dist/lib/status-parser.d.ts +19 -0
  264. package/dist/lib/status-parser.js +137 -0
  265. package/dist/lib/status-parser.js.map +1 -0
  266. package/dist/lib/stores/helpers/find-default-remote.d.ts +1 -0
  267. package/dist/lib/stores/helpers/find-default-remote.js +4 -0
  268. package/dist/lib/stores/helpers/find-default-remote.js.map +1 -0
  269. package/dist/lib/trampoline/trampoline-environment.d.ts +1 -0
  270. package/dist/lib/trampoline/trampoline-environment.js +4 -0
  271. package/dist/lib/trampoline/trampoline-environment.js.map +1 -0
  272. package/dist/models/branch.d.ts +44 -0
  273. package/dist/models/branch.js +59 -0
  274. package/dist/models/branch.js.map +1 -0
  275. package/dist/models/cherry-pick.d.ts +11 -0
  276. package/dist/models/cherry-pick.js +2 -0
  277. package/dist/models/cherry-pick.js.map +1 -0
  278. package/dist/models/clone-options.d.ts +6 -0
  279. package/dist/models/clone-options.js +2 -0
  280. package/dist/models/clone-options.js.map +1 -0
  281. package/dist/models/commit-identity.d.ts +9 -0
  282. package/dist/models/commit-identity.js +34 -0
  283. package/dist/models/commit-identity.js.map +1 -0
  284. package/dist/models/commit.d.ts +30 -0
  285. package/dist/models/commit.js +32 -0
  286. package/dist/models/commit.js.map +1 -0
  287. package/dist/models/computed-action.d.ts +6 -0
  288. package/dist/models/computed-action.js +8 -0
  289. package/dist/models/computed-action.js.map +1 -0
  290. package/dist/models/diff/diff-data.d.ts +53 -0
  291. package/dist/models/diff/diff-data.js +19 -0
  292. package/dist/models/diff/diff-data.js.map +1 -0
  293. package/dist/models/diff/diff-line.d.ts +18 -0
  294. package/dist/models/diff/diff-line.js +33 -0
  295. package/dist/models/diff/diff-line.js.map +1 -0
  296. package/dist/models/diff/diff-selection.d.ts +22 -0
  297. package/dist/models/diff/diff-selection.js +127 -0
  298. package/dist/models/diff/diff-selection.js.map +1 -0
  299. package/dist/models/diff/image-diff.d.ts +6 -0
  300. package/dist/models/diff/image-diff.js +8 -0
  301. package/dist/models/diff/image-diff.js.map +1 -0
  302. package/dist/models/diff/image.d.ts +7 -0
  303. package/dist/models/diff/image.js +13 -0
  304. package/dist/models/diff/image.js.map +1 -0
  305. package/dist/models/diff/index.d.ts +6 -0
  306. package/dist/models/diff/index.js +7 -0
  307. package/dist/models/diff/index.js.map +1 -0
  308. package/dist/models/diff/raw-diff.d.ts +32 -0
  309. package/dist/models/diff/raw-diff.js +38 -0
  310. package/dist/models/diff/raw-diff.js.map +1 -0
  311. package/dist/models/git-author.d.ts +7 -0
  312. package/dist/models/git-author.js +18 -0
  313. package/dist/models/git-author.js.map +1 -0
  314. package/dist/models/index.d.ts +21 -0
  315. package/dist/models/index.js +20 -0
  316. package/dist/models/index.js.map +1 -0
  317. package/dist/models/manual-conflict-resolution.d.ts +4 -0
  318. package/dist/models/manual-conflict-resolution.js +6 -0
  319. package/dist/models/manual-conflict-resolution.js.map +1 -0
  320. package/dist/models/merge.d.ts +6 -0
  321. package/dist/models/merge.js +2 -0
  322. package/dist/models/merge.js.map +1 -0
  323. package/dist/models/multi-commit-operation.d.ts +6 -0
  324. package/dist/models/multi-commit-operation.js +8 -0
  325. package/dist/models/multi-commit-operation.js.map +1 -0
  326. package/dist/models/progress.d.ts +41 -0
  327. package/dist/models/progress.js +7 -0
  328. package/dist/models/progress.js.map +1 -0
  329. package/dist/models/rebase.d.ts +17 -0
  330. package/dist/models/rebase.js +8 -0
  331. package/dist/models/rebase.js.map +1 -0
  332. package/dist/models/remote.d.ts +5 -0
  333. package/dist/models/remote.js +8 -0
  334. package/dist/models/remote.js.map +1 -0
  335. package/dist/models/repository.d.ts +7 -0
  336. package/dist/models/repository.js +15 -0
  337. package/dist/models/repository.js.map +1 -0
  338. package/dist/models/stash-entry.d.ts +20 -0
  339. package/dist/models/stash-entry.js +7 -0
  340. package/dist/models/stash-entry.js.map +1 -0
  341. package/dist/models/status.d.ts +166 -0
  342. package/dist/models/status.js +135 -0
  343. package/dist/models/status.js.map +1 -0
  344. package/dist/models/submodule.d.ts +12 -0
  345. package/dist/models/submodule.js +2 -0
  346. package/dist/models/submodule.js.map +1 -0
  347. package/dist/models/worktree.d.ts +10 -0
  348. package/dist/models/worktree.js +2 -0
  349. package/dist/models/worktree.js.map +1 -0
  350. package/package.json +13 -4
  351. package/src/git/add.ts +3 -3
  352. package/src/git/apply.ts +8 -8
  353. package/src/git/authentication.ts +3 -2
  354. package/src/git/branch.ts +10 -10
  355. package/src/git/checkout-index.ts +2 -2
  356. package/src/git/checkout.ts +12 -12
  357. package/src/git/cherry-pick.ts +16 -16
  358. package/src/git/clean.ts +2 -2
  359. package/src/git/clone.ts +6 -6
  360. package/src/git/commit.ts +7 -7
  361. package/src/git/config.ts +2 -2
  362. package/src/git/core.ts +8 -8
  363. package/src/git/credential.ts +1 -1
  364. package/src/git/diff-check.ts +1 -1
  365. package/src/git/diff-index.ts +2 -2
  366. package/src/git/diff.ts +18 -18
  367. package/src/git/environment.ts +5 -5
  368. package/src/git/fetch.ts +7 -7
  369. package/src/git/for-each-ref.ts +5 -5
  370. package/src/git/format-patch.ts +3 -3
  371. package/src/git/git-delimiter-parser.ts +1 -1
  372. package/src/git/gitignore.ts +2 -2
  373. package/src/git/index.ts +46 -36
  374. package/src/git/init.ts +2 -2
  375. package/src/git/interpret-trailers.ts +3 -3
  376. package/src/git/lfs.ts +2 -2
  377. package/src/git/log.ts +8 -8
  378. package/src/git/merge-tree.ts +5 -5
  379. package/src/git/merge.ts +5 -5
  380. package/src/git/multi-operation-terminal-output.ts +3 -3
  381. package/src/git/pull.ts +7 -7
  382. package/src/git/push-terminal-chunk.ts +1 -1
  383. package/src/git/push.ts +7 -7
  384. package/src/git/rebase.ts +16 -16
  385. package/src/git/reflog.ts +2 -2
  386. package/src/git/refs.ts +2 -2
  387. package/src/git/remote.ts +6 -6
  388. package/src/git/reorder.ts +7 -7
  389. package/src/git/reset.ts +3 -3
  390. package/src/git/rev-list.ts +5 -5
  391. package/src/git/rev-parse.ts +2 -2
  392. package/src/git/revert.ts +8 -8
  393. package/src/git/rm.ts +3 -3
  394. package/src/git/show.ts +4 -4
  395. package/src/git/spawn.ts +3 -3
  396. package/src/git/squash.ts +7 -7
  397. package/src/git/stage.ts +7 -7
  398. package/src/git/stash.ts +10 -10
  399. package/src/git/status.ts +13 -13
  400. package/src/git/submodule.ts +9 -9
  401. package/src/git/tag.ts +4 -4
  402. package/src/git/update-index.ts +5 -5
  403. package/src/git/update-ref.ts +2 -2
  404. package/src/git/var.ts +3 -3
  405. package/src/git/worktree-include.ts +3 -3
  406. package/src/git/worktree.ts +4 -4
  407. package/src/index.ts +9 -21
  408. package/src/lib/diff-parser.ts +2 -2
  409. package/src/lib/get-old-path.ts +1 -1
  410. package/src/lib/git/environment.ts +1 -1
  411. package/src/lib/patch-formatter.ts +3 -3
  412. package/src/lib/progress/from-process.ts +1 -1
  413. package/src/lib/progress/index.ts +1 -1
  414. package/src/lib/status-parser.ts +2 -2
  415. package/src/models/branch.ts +1 -1
  416. package/src/models/cherry-pick.ts +2 -2
  417. package/src/models/commit.ts +1 -1
  418. package/src/models/diff/diff-data.ts +3 -3
  419. package/src/models/diff/index.ts +6 -6
  420. package/src/models/diff/raw-diff.ts +1 -1
  421. package/src/models/index.ts +36 -0
  422. package/src/models/rebase.ts +2 -2
  423. package/src/models/stash-entry.ts +1 -1
  424. package/src/models/status.ts +1 -1
  425. package/examples/get-status.ts +0 -84
  426. package/tsconfig.json +0 -17
@@ -0,0 +1,371 @@
1
+ import { GitError } from './exec.js';
2
+ import { AppFileStatusKind, } from '../models/status.js';
3
+ import { git, } from './core.js';
4
+ import { getStatus } from './status.js';
5
+ import { stageFiles } from './update-index.js';
6
+ import { getCommitsInRange, revRange } from './rev-list.js';
7
+ import { merge } from '../lib/merge.js';
8
+ import { round } from '../lib/round.js';
9
+ import byline from 'byline';
10
+ import { stageManualConflictResolution } from './stage.js';
11
+ import { getCommit } from './index.js';
12
+ import { join } from 'path';
13
+ import { readFile } from 'fs/promises';
14
+ import { pathExists } from '../lib/path-exists.js';
15
+ /** The app-specific results from attempting to cherry pick commits*/
16
+ export var CherryPickResult;
17
+ (function (CherryPickResult) {
18
+ /**
19
+ * Git completed the cherry pick without reporting any errors, and the caller can
20
+ * signal success to the user.
21
+ */
22
+ CherryPickResult["CompletedWithoutError"] = "CompletedWithoutError";
23
+ /**
24
+ * The cherry pick encountered conflicts while attempting to cherry pick and
25
+ * need to be resolved before the user can continue.
26
+ */
27
+ CherryPickResult["ConflictsEncountered"] = "ConflictsEncountered";
28
+ /**
29
+ * The cherry pick was not able to continue as tracked files were not staged in
30
+ * the index.
31
+ */
32
+ CherryPickResult["OutstandingFilesNotStaged"] = "OutstandingFilesNotStaged";
33
+ /**
34
+ * The cherry pick was not attempted:
35
+ * - it could not check the status of the repository.
36
+ * - there was an invalid revision range provided.
37
+ * - there were uncommitted changes present.
38
+ * - there were errors in checkout the target branch
39
+ */
40
+ CherryPickResult["UnableToStart"] = "UnableToStart";
41
+ /**
42
+ * An unexpected error as part of the cherry pick flow was caught and handled.
43
+ *
44
+ * Check the logs to find the relevant Git details.
45
+ */
46
+ CherryPickResult["Error"] = "Error";
47
+ })(CherryPickResult || (CherryPickResult = {}));
48
+ /**
49
+ * A parser to read and emit cherry pick progress from Git `stdout`.
50
+ *
51
+ * Each successful cherry picked commit outputs a set of lines similar to the
52
+ * following example:
53
+ * [branchName commitSha] commitSummary
54
+ * Date: timestamp
55
+ * 1 file changed, 1 insertion(+)
56
+ * create mode 100644 filename
57
+ */
58
+ class GitCherryPickParser {
59
+ commits;
60
+ count;
61
+ constructor(commits, count = 0) {
62
+ this.commits = commits;
63
+ this.count = count;
64
+ }
65
+ parse(line) {
66
+ const cherryPickRe = /^\[(.*\s.*)\]/;
67
+ const match = cherryPickRe.exec(line);
68
+ if (match === null) {
69
+ // Skip lines that don't represent the first line of a successfully picked
70
+ // commit. -- i.e. timestamp, files changed, conflicts, etc..
71
+ return null;
72
+ }
73
+ this.count++;
74
+ return {
75
+ kind: 'multiCommitOperation',
76
+ value: round(this.count / this.commits.length, 2),
77
+ position: this.count,
78
+ totalCommitCount: this.commits.length,
79
+ currentCommitSummary: this.commits[this.count - 1]?.summary ?? '',
80
+ };
81
+ }
82
+ }
83
+ /**
84
+ * This method merges `baseOptions` with a call back method that obtains a
85
+ * `ICherryPickProgress` instance from `stdout` parsing.
86
+ *
87
+ * @param baseOptions - contains git execution options other than the
88
+ * progressCallBack such as expectedErrors
89
+ * @param commits - used by the parser to form `ICherryPickProgress` instance
90
+ * @param progressCallback - the callback method that accepts an
91
+ * `ICherryPickProgress` instance created by the parser
92
+ */
93
+ function configureOptionsWithCallBack(baseOptions, commits, progressCallback, cherryPickedCount = 0) {
94
+ return merge(baseOptions, {
95
+ processCallback: (process) => {
96
+ if (process.stdout === null) {
97
+ return;
98
+ }
99
+ const parser = new GitCherryPickParser(commits, cherryPickedCount);
100
+ byline(process.stdout).on('data', (line) => {
101
+ const progress = parser.parse(line);
102
+ if (progress != null) {
103
+ progressCallback(progress);
104
+ }
105
+ });
106
+ },
107
+ });
108
+ }
109
+ /**
110
+ * A function to initiate cherry picking in the app.
111
+ *
112
+ * @param commits - array of commits to cherry-pick
113
+ * For a cherry-pick operation, it does not matter what order the commits
114
+ * appear. But, it is best practice to send them in ascending order to prevent
115
+ * conflicts. First one on the array is first to be cherry-picked.
116
+ */
117
+ export async function cherryPick(repository, commits, progressCallback) {
118
+ if (commits.length === 0) {
119
+ return CherryPickResult.UnableToStart;
120
+ }
121
+ let baseOptions = {
122
+ expectedErrors: new Set([
123
+ GitError.MergeConflicts,
124
+ GitError.ConflictModifyDeletedInBranch,
125
+ ]),
126
+ };
127
+ if (progressCallback !== undefined) {
128
+ baseOptions = await configureOptionsWithCallBack(baseOptions, commits, progressCallback);
129
+ }
130
+ // --empty=keep follows pattern of making sure someone cherry
131
+ // picked commit summaries appear in target branch history even tho they may
132
+ // be empty. This flag also results in the ability to cherry pick empty
133
+ // commits (thus, --allow-empty is not required.)
134
+ //
135
+ // -m 1 makes it so a merge commit always takes the first parent's history
136
+ // (the branch you are cherry-picking from) for the commit. It also means
137
+ // there could be multiple empty commits. I.E. If user does a range that
138
+ // includes commits from that merge.
139
+ const result = await git(['cherry-pick', ...commits.map(c => c.sha), '--empty=keep', '-m 1'], repository.path, 'cherry-pick', baseOptions);
140
+ return parseCherryPickResult(result);
141
+ }
142
+ function parseCherryPickResult(result) {
143
+ if (result.exitCode === 0) {
144
+ return CherryPickResult.CompletedWithoutError;
145
+ }
146
+ switch (result.gitError) {
147
+ case GitError.ConflictModifyDeletedInBranch:
148
+ case GitError.MergeConflicts:
149
+ return CherryPickResult.ConflictsEncountered;
150
+ case GitError.UnresolvedConflicts:
151
+ return CherryPickResult.OutstandingFilesNotStaged;
152
+ default:
153
+ throw new Error(`Unhandled result found: '${JSON.stringify(result)}'`);
154
+ }
155
+ }
156
+ /**
157
+ * Inspect the `.git/sequencer` folder and convert the current cherry pick
158
+ * state into am `ICherryPickProgress` instance as well as return an array of
159
+ * remaining commits queued for cherry picking.
160
+ * - Progress instance required to display progress to user.
161
+ * - Commits required to track progress after a conflict has been resolved.
162
+ *
163
+ * This is required when Desktop is not responsible for initiating the cherry
164
+ * pick and when continuing a cherry pick after conflicts are resolved:
165
+ *
166
+ * It returns null if it cannot parse an ongoing cherry pick. This happens when,
167
+ * - There isn't a cherry pick in progress (expected null outcome).
168
+ * - Runs into errors parsing cherry pick files. This is expected if cherry
169
+ * pick is aborted or finished during parsing. It could also occur if cherry
170
+ * pick sequencer files are corrupted.
171
+ */
172
+ export async function getCherryPickSnapshot(repository) {
173
+ if (!isCherryPickHeadFound(repository)) {
174
+ // If there no cherry pick head, there is no cherry pick in progress.
175
+ return null;
176
+ }
177
+ // Abort safety sha is stored in.git/sequencer/abort-safety. It is the sha of
178
+ // the last cherry-picked commit in the operation or the head of target branch
179
+ // if no commits have been cherry-picked yet.
180
+ let abortSafetySha = '';
181
+ // The head sha is stored in .git/sequencer/head. It is the sha of target
182
+ // branch before the cherry-pick operation occurred.
183
+ let headSha = '';
184
+ // Each line of .git/sequencer/todo holds a sha of a commit lined up to be
185
+ // cherry-picked. These shas are in historical order starting oldest commit as
186
+ // the first line and newest as the last line.
187
+ const remainingCommits = [];
188
+ // Try block included as files may throw an error if it cannot locate
189
+ // the sequencer files. This is possible if cherry pick is continued
190
+ // or aborted at the same time.
191
+ try {
192
+ abortSafetySha = (await readFile(join(repository.resolvedGitDir, 'sequencer', 'abort-safety'), 'utf8')).trim();
193
+ if (abortSafetySha === '') {
194
+ // Technically possible if someone continued or aborted the cherry pick at
195
+ // the same time
196
+ return null;
197
+ }
198
+ headSha = (await readFile(join(repository.resolvedGitDir, 'sequencer', 'head'), 'utf8')).trim();
199
+ if (headSha === '') {
200
+ // Technically possible if someone continued or aborted the cherry pick at
201
+ // the same time
202
+ return null;
203
+ }
204
+ const remainingPicks = (await readFile(join(repository.resolvedGitDir, 'sequencer', 'todo'), 'utf8')).trim();
205
+ if (remainingPicks === '') {
206
+ // Technically possible if someone continued or aborted the cherry pick at
207
+ // the same time
208
+ return null;
209
+ }
210
+ // Each line is of the format: `pick shortSha commitSummary`
211
+ remainingPicks.split('\n').forEach(line => {
212
+ line = line.replace(/^pick /, '');
213
+ if (line.trim().includes(' ')) {
214
+ const sha = line.substr(0, line.indexOf(' '));
215
+ const commit = {
216
+ sha,
217
+ summary: line.substr(sha.length + 1),
218
+ };
219
+ remainingCommits.push(commit);
220
+ }
221
+ });
222
+ if (remainingCommits.length === 0) {
223
+ // This should only be possible with corrupt sequencer files.
224
+ return null;
225
+ }
226
+ }
227
+ catch {
228
+ // could not parse sequencer files
229
+ if (!isCherryPickHeadFound(repository)) {
230
+ // We redo this check just because a user technically could end the
231
+ // cherry-pick by the time we got here.
232
+ return null;
233
+ }
234
+ // If cherry-pick is in progress, then there was only one commit cherry-picked
235
+ // thus sequencer files were not used.
236
+ const cherryPickHeadSha = (await readFile(join(repository.resolvedGitDir, 'CHERRY_PICK_HEAD'), 'utf8')).trim();
237
+ const commit = await getCommit(repository, cherryPickHeadSha);
238
+ if (commit === null) {
239
+ return null;
240
+ }
241
+ return {
242
+ sha: commit.sha,
243
+ parentCount: 1,
244
+ progress: {
245
+ kind: 'multiCommitOperation',
246
+ value: 1,
247
+ position: 1,
248
+ totalCommitCount: 1,
249
+ currentCommitSummary: commit.summary,
250
+ },
251
+ remainingCommits: [],
252
+ commits: [{ sha: commit.sha, summary: commit.summary }],
253
+ targetBranchUndoSha: headSha,
254
+ cherryPickedCount: 0,
255
+ };
256
+ }
257
+ // To get all the commits for the cherry-pick operation, we need to get the
258
+ // ones already cherry-picked. If abortSafetySha is headSha; none have been
259
+ // cherry-picked yet.
260
+ const commitsCherryPicked = abortSafetySha !== headSha
261
+ ? await getCommitsInRange(repository, revRange(headSha, abortSafetySha))
262
+ : [];
263
+ if (commitsCherryPicked === null) {
264
+ // This should only be possible with corrupt sequencer files resulting in a
265
+ // bad revision range.
266
+ return null;
267
+ }
268
+ const commits = [...commitsCherryPicked, ...remainingCommits];
269
+ const position = commitsCherryPicked.length + 1;
270
+ const sha = remainingCommits[0]?.sha ?? '';
271
+ return {
272
+ sha,
273
+ parentCount: commits.length,
274
+ progress: {
275
+ kind: 'multiCommitOperation',
276
+ value: round(position / commits.length, 2),
277
+ position,
278
+ totalCommitCount: commits.length,
279
+ currentCommitSummary: remainingCommits[0].summary ?? '',
280
+ },
281
+ remainingCommits,
282
+ commits,
283
+ targetBranchUndoSha: headSha,
284
+ cherryPickedCount: commitsCherryPicked.length,
285
+ };
286
+ }
287
+ /**
288
+ * Proceed with the current cherry pick operation and report back on whether it completed
289
+ *
290
+ * It is expected that the index has staged files which are cleanly cherry
291
+ * picked onto the base branch, and the remaining unstaged files are those which
292
+ * need manual resolution or were changed by the user to address inline
293
+ * conflicts.
294
+ *
295
+ * @param files - The working directory of files. These are the files that are
296
+ * detected to have changes that we want to stage for the cherry pick.
297
+ */
298
+ export async function continueCherryPick(repository, files, manualResolutions = new Map(), progressCallback) {
299
+ // only stage files related to cherry pick
300
+ const trackedFiles = files.filter(f => {
301
+ return f.status.kind !== AppFileStatusKind.Untracked;
302
+ });
303
+ // apply conflict resolutions
304
+ for (const [path, resolution] of manualResolutions) {
305
+ const file = files.find(f => f.path === path);
306
+ if (file === undefined) {
307
+ console.error(`[continueCherryPick] couldn't find file ${path} even though there's a manual resolution for it`);
308
+ continue;
309
+ }
310
+ await stageManualConflictResolution(repository, file, resolution);
311
+ }
312
+ const otherFiles = trackedFiles.filter(f => !manualResolutions.has(f.path));
313
+ await stageFiles(repository, otherFiles);
314
+ const status = await getStatus(repository, false);
315
+ if (status == null) {
316
+ console.warn(`[continueCherryPick] unable to get status after staging changes,
317
+ skipping any other steps`);
318
+ return CherryPickResult.UnableToStart;
319
+ }
320
+ // make sure cherry pick is still in progress to continue
321
+ if (await !isCherryPickHeadFound(repository)) {
322
+ return CherryPickResult.UnableToStart;
323
+ }
324
+ let options = {
325
+ expectedErrors: new Set([
326
+ GitError.MergeConflicts,
327
+ GitError.ConflictModifyDeletedInBranch,
328
+ GitError.UnresolvedConflicts,
329
+ ]),
330
+ env: {
331
+ // if we don't provide editor, we can't detect git errors
332
+ GIT_EDITOR: ':',
333
+ },
334
+ };
335
+ if (progressCallback !== undefined) {
336
+ const snapshot = await getCherryPickSnapshot(repository);
337
+ if (snapshot === null) {
338
+ console.warn(`[continueCherryPick] unable to get cherry-pick status, skipping other steps`);
339
+ return CherryPickResult.UnableToStart;
340
+ }
341
+ options = configureOptionsWithCallBack(options, snapshot.commits, progressCallback, snapshot.cherryPickedCount);
342
+ }
343
+ const trackedFilesAfter = status.workingDirectory.files.filter(f => f.status.kind !== AppFileStatusKind.Untracked);
344
+ if (trackedFilesAfter.length === 0) {
345
+ console.warn(`[cherryPick] no tracked changes to commit, continuing cherry-pick but skipping this commit`);
346
+ // This commits the empty commit so that the cherry picked commit still
347
+ // shows up in the target branches history.
348
+ const result = await git(['commit', '--allow-empty'], repository.path, 'continueCherryPickSkipCurrentCommit', options);
349
+ return parseCherryPickResult(result);
350
+ }
351
+ const result = await git(['cherry-pick', '--continue'], repository.path, 'continueCherryPick', options);
352
+ return parseCherryPickResult(result);
353
+ }
354
+ /** Abandon the current cherry pick operation */
355
+ export async function abortCherryPick(repository) {
356
+ await git(['cherry-pick', '--abort'], repository.path, 'abortCherryPick');
357
+ }
358
+ /**
359
+ * Check if the `.git/CHERRY_PICK_HEAD` file exists
360
+ */
361
+ export async function isCherryPickHeadFound(repository) {
362
+ try {
363
+ return pathExists(join(repository.resolvedGitDir, 'CHERRY_PICK_HEAD'));
364
+ }
365
+ catch (err) {
366
+ console.warn(`[cherryPick] a problem was encountered reading .git/CHERRY_PICK_HEAD,
367
+ so it is unsafe to continue cherry-picking`, err);
368
+ return false;
369
+ }
370
+ }
371
+ //# sourceMappingURL=cherry-pick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cherry-pick.js","sourceRoot":"","sources":["../../src/git/cherry-pick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EACL,iBAAiB,GAElB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,GAAG,GAIJ,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAG3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,YA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SAAS,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;AAC3E,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,UAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAA;IACxE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV;kDAC4C,EAC5C,GAAG,CACJ,CAAA;QACD,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Repository } from '../models/repository.js';
2
+ /**
3
+ * Clean untracked files from the repository.
4
+ */
5
+ export declare function cleanUntrackedFiles(repository: Repository): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { git } from './core.js';
2
+ /**
3
+ * Clean untracked files from the repository.
4
+ */
5
+ export async function cleanUntrackedFiles(repository) {
6
+ await git(['clean', '-d', '--force'], repository.path, 'cleanUntrackedFiles');
7
+ }
8
+ //# sourceMappingURL=clean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clean.js","sourceRoot":"","sources":["../../src/git/clean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAG/B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,UAAsB;IAC9D,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAA;AAC/E,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { ICloneProgress } from '../models/progress.js';
2
+ import { CloneOptions } from '../models/clone-options.js';
3
+ /**
4
+ * Clones a repository from a given url into to the specified path.
5
+ *
6
+ * @param url - The remote repository URL to clone from
7
+ *
8
+ * @param path - The destination path for the cloned repository. If the
9
+ * path does not exist it will be created. Cloning into an
10
+ * existing directory is only allowed if the directory is
11
+ * empty.
12
+ *
13
+ * @param options - Options specific to the clone operation, see the
14
+ * documentation for CloneOptions for more details.
15
+ *
16
+ * @param progressCallback - An optional function which will be invoked
17
+ * with information about the current progress
18
+ * of the clone operation. When provided this enables
19
+ * the '--progress' command line flag for
20
+ * 'git clone'.
21
+ */
22
+ export declare function clone(url: string, path: string, options: CloneOptions, login: string | null, progressCallback?: (progress: ICloneProgress) => void): Promise<void>;
@@ -0,0 +1,58 @@
1
+ import { git } from './core.js';
2
+ import { CloneProgressParser, executionOptionsWithProgress } from '../lib/progress/index.js';
3
+ import { getDefaultBranch } from '../lib/helpers/default-branch.js';
4
+ import { envForRemoteOperation } from './environment.js';
5
+ /**
6
+ * Clones a repository from a given url into to the specified path.
7
+ *
8
+ * @param url - The remote repository URL to clone from
9
+ *
10
+ * @param path - The destination path for the cloned repository. If the
11
+ * path does not exist it will be created. Cloning into an
12
+ * existing directory is only allowed if the directory is
13
+ * empty.
14
+ *
15
+ * @param options - Options specific to the clone operation, see the
16
+ * documentation for CloneOptions for more details.
17
+ *
18
+ * @param progressCallback - An optional function which will be invoked
19
+ * with information about the current progress
20
+ * of the clone operation. When provided this enables
21
+ * the '--progress' command line flag for
22
+ * 'git clone'.
23
+ */
24
+ export async function clone(url, path, options, login, progressCallback) {
25
+ const env = {
26
+ ...(await envForRemoteOperation(url)),
27
+ GIT_CLONE_PROTECTION_ACTIVE: 'false',
28
+ };
29
+ const remoteUrl = login
30
+ ? url.replace(/^((?:https|http|git+ssh|git|ssh|file)?:\/\/)/i, '$1' + login + '@')
31
+ : url;
32
+ const defaultBranch = options.defaultBranch ?? (await getDefaultBranch());
33
+ const args = [
34
+ '-c',
35
+ `init.defaultBranch=${defaultBranch}`,
36
+ 'clone',
37
+ '--recursive',
38
+ ];
39
+ let opts = { env };
40
+ if (progressCallback) {
41
+ args.push('--progress');
42
+ const title = `Cloning into ${path}`;
43
+ const kind = 'clone';
44
+ opts = await executionOptionsWithProgress({ ...opts, trackLFSProgress: true }, new CloneProgressParser(), progress => {
45
+ const description = progress.kind === 'progress' ? progress.details.text : progress.text;
46
+ const value = progress.percent;
47
+ progressCallback({ kind, title, description, value });
48
+ });
49
+ // Initial progress
50
+ progressCallback({ kind, title, value: 0 });
51
+ }
52
+ if (options.branch) {
53
+ args.push('-b', options.branch);
54
+ }
55
+ args.push('--', remoteUrl, path);
56
+ await git(args, __dirname, 'clone', opts);
57
+ }
58
+ //# sourceMappingURL=clone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.js","sourceRoot":"","sources":["../../src/git/clone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAA8B,MAAM,WAAW,CAAA;AAG3D,OAAO,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,GAAW,EACX,IAAY,EACZ,OAAqB,EACrB,KAAoB,EACpB,gBAAqD;IAErD,MAAM,GAAG,GAAG;QACV,GAAG,CAAC,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;QACrC,2BAA2B,EAAE,OAAO;KACrC,CAAA;IAED,MAAM,SAAS,GAAG,KAAK;QACrB,CAAC,CAAC,GAAG,CAAC,OAAO,CACT,+CAA+C,EAC/C,IAAI,GAAG,KAAK,GAAG,GAAG,CACnB;QACH,CAAC,CAAC,GAAG,CAAA;IAEP,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,CAAC,MAAM,gBAAgB,EAAE,CAAC,CAAA;IAEzE,MAAM,IAAI,GAAG;QACX,IAAI;QACJ,sBAAsB,aAAa,EAAE;QACrC,OAAO;QACP,aAAa;KACd,CAAA;IAED,IAAI,IAAI,GAA+B,EAAE,GAAG,EAAE,CAAA;IAE9C,IAAI,gBAAgB,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAEvB,MAAM,KAAK,GAAG,gBAAgB,IAAI,EAAE,CAAA;QACpC,MAAM,IAAI,GAAG,OAAO,CAAA;QAEpB,IAAI,GAAG,MAAM,4BAA4B,CACvC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,EACnC,IAAI,mBAAmB,EAAE,EACzB,QAAQ,CAAC,EAAE;YACT,MAAM,WAAW,GACf,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAA;YACtE,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAA;YAE9B,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAA;QACvD,CAAC,CACF,CAAA;QAED,mBAAmB;QACnB,gBAAgB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;IAC7C,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACjC,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;IAEhC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;AAC3C,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const coerceToBuffer: (value: string | Buffer, encoding?: BufferEncoding) => Buffer<ArrayBufferLike>;
@@ -0,0 +1,2 @@
1
+ export const coerceToBuffer = (value, encoding = 'utf8') => (Buffer.isBuffer(value) ? value : Buffer.from(value, encoding));
2
+ //# sourceMappingURL=coerce-to-buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-to-buffer.js","sourceRoot":"","sources":["../../src/git/coerce-to-buffer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAsB,EACtB,WAA2B,MAAM,EACjC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const coerceToString: (value: string | Buffer, encoding?: BufferEncoding) => string;
@@ -0,0 +1,2 @@
1
+ export const coerceToString = (value, encoding = 'utf8') => (Buffer.isBuffer(value) ? value.toString(encoding) : value);
2
+ //# sourceMappingURL=coerce-to-string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-to-string.js","sourceRoot":"","sources":["../../src/git/coerce-to-string.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAsB,EACtB,WAA2B,MAAM,EACjC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { HookCallbackOptions } from './core.js';
2
+ import { Repository } from '../models/repository.js';
3
+ import { WorkingDirectoryFileChange } from '../models/status.js';
4
+ import { ManualConflictResolution } from '../models/manual-conflict-resolution.js';
5
+ /**
6
+ * @param repository repository to execute merge in
7
+ * @param message commit message
8
+ * @param files files to commit
9
+ * @returns the commit SHA
10
+ */
11
+ export declare function createCommit(repository: Repository, message: string, files: ReadonlyArray<WorkingDirectoryFileChange>, options?: {
12
+ amend?: boolean;
13
+ noVerify?: boolean;
14
+ signOff?: boolean;
15
+ allowEmpty?: boolean;
16
+ } & HookCallbackOptions): Promise<string>;
17
+ /**
18
+ * Creates a commit to finish an in-progress merge
19
+ * assumes that all conflicts have already been resolved
20
+ * *Warning:* Does _not_ clear staged files before it commits!
21
+ *
22
+ * @param repository repository to execute merge in
23
+ * @param files files to commit
24
+ */
25
+ export declare function createMergeCommit(repository: Repository, files: ReadonlyArray<WorkingDirectoryFileChange>, manualResolutions?: ReadonlyMap<string, ManualConflictResolution>): Promise<string>;
@@ -0,0 +1,99 @@
1
+ import { git, parseCommitSHA } from './core.js';
2
+ import { stageFiles } from './update-index.js';
3
+ import { unstageAll } from './reset.js';
4
+ import { stageManualConflictResolution } from './stage.js';
5
+ /**
6
+ * @param repository repository to execute merge in
7
+ * @param message commit message
8
+ * @param files files to commit
9
+ * @returns the commit SHA
10
+ */
11
+ export async function createCommit(repository, message, files, options) {
12
+ // Clear the staging area, our diffs reflect the difference between the
13
+ // working directory and the last commit (if any) so our commits should
14
+ // do the same thing.
15
+ await unstageAll(repository);
16
+ await stageFiles(repository, files);
17
+ const args = ['-F', '-'];
18
+ if (options?.amend) {
19
+ args.push('--amend');
20
+ }
21
+ if (options?.noVerify) {
22
+ args.push('--no-verify');
23
+ }
24
+ if (options?.signOff) {
25
+ args.push('--signoff');
26
+ }
27
+ if (options?.allowEmpty) {
28
+ args.push('--allow-empty');
29
+ }
30
+ const result = await git(['commit', ...args], repository.path, 'createCommit', {
31
+ stdin: message,
32
+ // https://git-scm.com/docs/githooks/2.46.1
33
+ interceptHooks: [
34
+ 'pre-commit',
35
+ 'prepare-commit-msg',
36
+ 'commit-msg',
37
+ 'post-commit',
38
+ ...(options?.amend ? ['post-rewrite'] : []),
39
+ 'pre-auto-gc',
40
+ ],
41
+ onHookProgress: options?.onHookProgress,
42
+ onHookFailure: options?.onHookFailure,
43
+ onTerminalOutputAvailable: options?.onTerminalOutputAvailable,
44
+ });
45
+ return parseCommitSHA(result);
46
+ }
47
+ /**
48
+ * Creates a commit to finish an in-progress merge
49
+ * assumes that all conflicts have already been resolved
50
+ * *Warning:* Does _not_ clear staged files before it commits!
51
+ *
52
+ * @param repository repository to execute merge in
53
+ * @param files files to commit
54
+ */
55
+ export async function createMergeCommit(repository, files, manualResolutions = new Map()) {
56
+ // apply manual conflict resolutions
57
+ for (const [path, resolution] of manualResolutions) {
58
+ const file = files.find(f => f.path === path);
59
+ if (file !== undefined) {
60
+ await stageManualConflictResolution(repository, file, resolution);
61
+ }
62
+ else {
63
+ console.error(`couldn't find file ${path} even though there's a manual resolution for it`);
64
+ }
65
+ }
66
+ const otherFiles = files.filter(f => !manualResolutions.has(f.path));
67
+ await stageFiles(repository, otherFiles);
68
+ const result = await git([
69
+ 'commit',
70
+ // no-edit here ensures the app does not accidentally invoke the user's editor
71
+ '--no-edit',
72
+ // By default Git merge commits do not contain any commentary (which
73
+ // are lines prefixed with `#`). This works because the Git CLI will
74
+ // prompt the user to edit the file in `.git/COMMIT_MSG` before
75
+ // committing, and then it will run `--cleanup=strip`.
76
+ //
77
+ // This clashes with our use of `--no-edit` above as Git will now change
78
+ // it's behavior to invoke `--cleanup=whitespace` as it did not ask
79
+ // the user to edit the COMMIT_MSG as part of creating a commit.
80
+ //
81
+ // From the docs on git-commit (https://git-scm.com/docs/git-commit) I'll
82
+ // quote the relevant section:
83
+ // --cleanup=<mode>
84
+ // strip
85
+ // Strip leading and trailing empty lines, trailing whitespace,
86
+ // commentary and collapse consecutive empty lines.
87
+ // whitespace
88
+ // Same as `strip` except #commentary is not removed.
89
+ // default
90
+ // Same as `strip` if the message is to be edited. Otherwise `whitespace`.
91
+ //
92
+ // We should emulate the behavior in this situation because we don't
93
+ // let the user view or change the commit message before making the
94
+ // commit.
95
+ '--cleanup=strip',
96
+ ], repository.path, 'createMergeCommit');
97
+ return parseCommitSHA(result);
98
+ }
99
+ //# sourceMappingURL=commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit.js","sourceRoot":"","sources":["../../src/git/commit.ts"],"names":[],"mapp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