git-chopstick-core 0.1.1 → 0.1.3

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 (461) 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/{src/git/checkout-index.ts → dist/git/checkout-index.js} +11 -22
  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/{src/git/interpret-trailers.ts → dist/git/interpret-trailers.d.ts} +9 -97
  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/{src/git/push-terminal-chunk.ts → dist/git/push-terminal-chunk.d.ts} +1 -23
  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/{src/git/show.ts → dist/git/show.js} +17 -46
  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/{src/git/update-ref.ts → dist/git/update-ref.js} +10 -28
  175. package/dist/git/update-ref.js.map +1 -0
  176. package/dist/git/var.d.ts +18 -0
  177. package/{src/git/var.ts → dist/git/var.js} +16 -25
  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 +125 -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 +44 -5
  351. package/examples/get-status.ts +0 -84
  352. package/src/git/add.ts +0 -16
  353. package/src/git/apply.ts +0 -154
  354. package/src/git/authentication.ts +0 -19
  355. package/src/git/branch.ts +0 -206
  356. package/src/git/checkout.ts +0 -235
  357. package/src/git/cherry-pick.ts +0 -504
  358. package/src/git/clean.ts +0 -9
  359. package/src/git/clone.ts +0 -86
  360. package/src/git/coerce-to-buffer.ts +0 -4
  361. package/src/git/coerce-to-string.ts +0 -4
  362. package/src/git/commit.ts +0 -136
  363. package/src/git/config.ts +0 -392
  364. package/src/git/core.ts +0 -625
  365. package/src/git/create-tail-stream.ts +0 -36
  366. package/src/git/credential.ts +0 -83
  367. package/src/git/description.ts +0 -33
  368. package/src/git/diff-check.ts +0 -27
  369. package/src/git/diff-index.ts +0 -116
  370. package/src/git/diff.ts +0 -880
  371. package/src/git/environment.ts +0 -116
  372. package/src/git/exec.ts +0 -285
  373. package/src/git/fetch.ts +0 -141
  374. package/src/git/for-each-ref.ts +0 -160
  375. package/src/git/format-patch.ts +0 -17
  376. package/src/git/git-delimiter-parser.ts +0 -95
  377. package/src/git/gitignore.ts +0 -157
  378. package/src/git/index.ts +0 -36
  379. package/src/git/init.ts +0 -11
  380. package/src/git/lfs.ts +0 -100
  381. package/src/git/log.ts +0 -376
  382. package/src/git/merge-tree.ts +0 -42
  383. package/src/git/merge.ts +0 -154
  384. package/src/git/multi-operation-terminal-output.ts +0 -68
  385. package/src/git/pull.ts +0 -130
  386. package/src/git/push.ts +0 -119
  387. package/src/git/rebase.ts +0 -627
  388. package/src/git/reflog.ts +0 -127
  389. package/src/git/refs.ts +0 -63
  390. package/src/git/remote.ts +0 -143
  391. package/src/git/reorder.ts +0 -153
  392. package/src/git/reset.ts +0 -101
  393. package/src/git/rev-list.ts +0 -201
  394. package/src/git/rev-parse.ts +0 -92
  395. package/src/git/revert.ts +0 -55
  396. package/src/git/rm.ts +0 -31
  397. package/src/git/spawn.ts +0 -38
  398. package/src/git/squash.ts +0 -173
  399. package/src/git/stage.ts +0 -97
  400. package/src/git/stash.ts +0 -302
  401. package/src/git/status.ts +0 -502
  402. package/src/git/submodule.ts +0 -212
  403. package/src/git/tag.ts +0 -134
  404. package/src/git/update-index.ts +0 -169
  405. package/src/git/worktree-include.ts +0 -146
  406. package/src/git/worktree.ts +0 -219
  407. package/src/index.ts +0 -23
  408. package/src/lib/api.ts +0 -7
  409. package/src/lib/diff-parser.ts +0 -249
  410. package/src/lib/directory-exists.ts +0 -10
  411. package/src/lib/errno-exception.ts +0 -12
  412. package/src/lib/fatal-error.ts +0 -23
  413. package/src/lib/feature-flag.ts +0 -29
  414. package/src/lib/file-system.ts +0 -7
  415. package/src/lib/get-old-path.ts +0 -11
  416. package/src/lib/git/environment.ts +0 -14
  417. package/src/lib/git-perf.ts +0 -3
  418. package/src/lib/helpers/default-branch.ts +0 -3
  419. package/src/lib/helpers/path.ts +0 -5
  420. package/src/lib/hooks/with-hooks-env.ts +0 -7
  421. package/src/lib/merge.ts +0 -3
  422. package/src/lib/noop.ts +0 -1
  423. package/src/lib/patch-formatter.ts +0 -18
  424. package/src/lib/path-exists.ts +0 -7
  425. package/src/lib/progress/from-process.ts +0 -10
  426. package/src/lib/progress/index.ts +0 -43
  427. package/src/lib/progress/revert.ts +0 -17
  428. package/src/lib/rebase.ts +0 -3
  429. package/src/lib/remove-remote-prefix.ts +0 -4
  430. package/src/lib/resolve-git-proxy.ts +0 -3
  431. package/src/lib/round.ts +0 -4
  432. package/src/lib/split-buffer.ts +0 -14
  433. package/src/lib/status-parser.ts +0 -188
  434. package/src/lib/stores/helpers/find-default-remote.ts +0 -3
  435. package/src/lib/trampoline/trampoline-environment.ts +0 -8
  436. package/src/models/branch.ts +0 -78
  437. package/src/models/cherry-pick.ts +0 -12
  438. package/src/models/clone-options.ts +0 -6
  439. package/src/models/commit-identity.ts +0 -35
  440. package/src/models/commit.ts +0 -44
  441. package/src/models/computed-action.ts +0 -6
  442. package/src/models/diff/diff-data.ts +0 -78
  443. package/src/models/diff/diff-line.ts +0 -36
  444. package/src/models/diff/diff-selection.ts +0 -165
  445. package/src/models/diff/image-diff.ts +0 -6
  446. package/src/models/diff/image.ts +0 -8
  447. package/src/models/diff/index.ts +0 -6
  448. package/src/models/diff/raw-diff.ts +0 -41
  449. package/src/models/git-author.ts +0 -16
  450. package/src/models/manual-conflict-resolution.ts +0 -4
  451. package/src/models/merge.ts +0 -6
  452. package/src/models/multi-commit-operation.ts +0 -6
  453. package/src/models/progress.ts +0 -67
  454. package/src/models/rebase.ts +0 -20
  455. package/src/models/remote.ts +0 -10
  456. package/src/models/repository.ts +0 -16
  457. package/src/models/stash-entry.ts +0 -25
  458. package/src/models/status.ts +0 -275
  459. package/src/models/submodule.ts +0 -13
  460. package/src/models/worktree.ts +0 -11
  461. package/tsconfig.json +0 -17
@@ -1,201 +0,0 @@
1
- import { GitError } from './exec'
2
- import { git } from './core'
3
- import { Repository } from '../models/repository'
4
- import { Branch, BranchType, IAheadBehind } from '../models/branch'
5
- import { CommitOneLine } from '../models/commit'
6
-
7
- /**
8
- * Convert two refs into the Git range syntax representing the set of commits
9
- * that are reachable from `to` but excluding those that are reachable from
10
- * `from`. This will not be inclusive to the `from` ref, see
11
- * `revRangeInclusive`.
12
- *
13
- * Each parameter can be the commit SHA or a ref name, or specify an empty
14
- * string to represent HEAD.
15
- *
16
- * @param from The start of the range
17
- * @param to The end of the range
18
- */
19
- export function revRange(from: string, to: string) {
20
- return `${from}..${to}`
21
- }
22
-
23
- /**
24
- * Convert two refs into the Git range syntax representing the set of commits
25
- * that are reachable from `to` but excluding those that are reachable from
26
- * `from`. However as opposed to `revRange`, this will also include `from` ref.
27
- *
28
- * Each parameter can be the commit SHA or a ref name, or specify an empty
29
- * string to represent HEAD.
30
- *
31
- * @param from The start of the range
32
- * @param to The end of the range
33
- */
34
- export function revRangeInclusive(from: string, to: string) {
35
- return `${from}^..${to}`
36
- }
37
-
38
- /**
39
- * Convert two refs into the Git symmetric difference syntax, which represents
40
- * the set of commits that are reachable from either `from` or `to` but not
41
- * from both.
42
- *
43
- * Each parameter can be the commit SHA or a ref name, or you can use an empty
44
- * string to represent HEAD.
45
- *
46
- * @param from The start of the range
47
- * @param to The end of the range
48
- */
49
- export function revSymmetricDifference(from: string, to: string) {
50
- return `${from}...${to}`
51
- }
52
-
53
- /** Calculate the number of commits the range is ahead and behind. */
54
- export async function getAheadBehind(
55
- repository: Repository,
56
- range: string
57
- ): Promise<IAheadBehind | null> {
58
- // `--left-right` annotates the list of commits in the range with which side
59
- // they're coming from. When used with `--count`, it tells us how many
60
- // commits we have from the two different sides of the range.
61
- const args = ['rev-list', '--left-right', '--count', range, '--']
62
- const result = await git(args, repository.path, 'getAheadBehind', {
63
- expectedErrors: new Set([GitError.BadRevision]),
64
- })
65
-
66
- // This means one of the refs (most likely the upstream branch) no longer
67
- // exists. In that case we can't be ahead/behind at all.
68
- if (result.gitError === GitError.BadRevision) {
69
- return null
70
- }
71
-
72
- const stdout = result.stdout
73
- const pieces = stdout.split('\t')
74
- if (pieces.length !== 2) {
75
- return null
76
- }
77
-
78
- const ahead = parseInt(pieces[0], 10)
79
- if (isNaN(ahead)) {
80
- return null
81
- }
82
-
83
- const behind = parseInt(pieces[1], 10)
84
- if (isNaN(behind)) {
85
- return null
86
- }
87
-
88
- return { ahead, behind }
89
- }
90
-
91
- /** Calculate the number of commits `branch` is ahead/behind its upstream. */
92
- export async function getBranchAheadBehind(
93
- repository: Repository,
94
- branch: Branch
95
- ): Promise<IAheadBehind | null> {
96
- if (branch.type === BranchType.Remote) {
97
- return null
98
- }
99
-
100
- const upstream = branch.upstream
101
- if (!upstream) {
102
- return null
103
- }
104
-
105
- // NB: The three dot form means we'll go all the way back to the merge base
106
- // of the branch and its upstream. Practically this is important for seeing
107
- // "through" merges.
108
- const range = revSymmetricDifference(branch.name, upstream)
109
- return getAheadBehind(repository, range)
110
- }
111
-
112
- /**
113
- * Get a list of commits from the target branch that do not exist on the base
114
- * branch, ordered how they will be applied to the base branch.
115
- * Therefore, this will not include the baseBranchSha commit.
116
- *
117
- * This emulates how `git rebase` initially determines what will be applied to
118
- * the repository.
119
- *
120
- * Returns `null` when the rebase is not possible to perform, because of a
121
- * missing commit ID
122
- */
123
- export async function getCommitsBetweenCommits(
124
- repository: Repository,
125
- baseBranchSha: string,
126
- targetBranchSha: string
127
- ): Promise<ReadonlyArray<CommitOneLine> | null> {
128
- const range = revRange(baseBranchSha, targetBranchSha)
129
-
130
- return getCommitsInRange(repository, range)
131
- }
132
-
133
- /**
134
- * Get a list of commits inside the provided range.
135
- *
136
- * Returns `null` when it is not possible to perform because of a bad range.
137
- */
138
- export async function getCommitsInRange(
139
- repository: Repository,
140
- range: string
141
- ): Promise<ReadonlyArray<CommitOneLine> | null> {
142
- const args = [
143
- 'rev-list',
144
- range,
145
- '--reverse',
146
- // the combination of these two arguments means each line of the stdout
147
- // will contain the full commit sha and a commit summary
148
- `--oneline`,
149
- `--no-abbrev-commit`,
150
- '--',
151
- ]
152
-
153
- const options = {
154
- expectedErrors: new Set<GitError>([GitError.BadRevision]),
155
- }
156
-
157
- const result = await git(args, repository.path, 'getCommitsInRange', options)
158
-
159
- if (result.gitError === GitError.BadRevision) {
160
- return null
161
- }
162
-
163
- const lines = result.stdout.split('\n')
164
-
165
- const commits = new Array<CommitOneLine>()
166
-
167
- const commitSummaryRe = /^([a-z0-9]{40}) (.*)$/
168
-
169
- for (const line of lines) {
170
- const match = commitSummaryRe.exec(line)
171
-
172
- if (match !== null && match.length === 3) {
173
- const sha = match[1]
174
- const summary = match[2]
175
-
176
- commits.push({
177
- sha,
178
- summary,
179
- })
180
- }
181
- }
182
-
183
- return commits
184
- }
185
-
186
- /**
187
- * Determine if merge commits exist in history after given commit
188
- * If commitRef is null, goes back to HEAD of branch.
189
- */
190
- export async function doMergeCommitsExistAfterCommit(
191
- repository: Repository,
192
- commitRef: string | null
193
- ): Promise<boolean> {
194
- const revision = commitRef === null ? 'HEAD' : revRange(commitRef, 'HEAD')
195
- const args = ['rev-list', '-1', '--merges', revision, '--']
196
-
197
- return git(args, repository.path, 'doMergeCommitsExistAfterCommit', {
198
- // 128 here means there's no HEAD, i.e we're on an unborn branch
199
- successExitCodes: new Set([0, 128]),
200
- }).then(x => x.stdout.length > 0)
201
- }
@@ -1,92 +0,0 @@
1
- import { git } from './core'
2
- import { directoryExists } from '../lib/directory-exists'
3
- import { resolve } from 'path'
4
-
5
- export type RepositoryType =
6
- | { kind: 'bare' }
7
- | { kind: 'regular'; topLevelWorkingDirectory: string; gitDir: string }
8
- | { kind: 'missing' }
9
- | { kind: 'unsafe'; path: string }
10
-
11
- /**
12
- * Attempts to fulfill the work of isGitRepository and isBareRepository while
13
- * requiring only one Git process to be spawned.
14
- *
15
- * Returns 'bare', 'regular', or 'missing' if the repository couldn't be
16
- * found.
17
- */
18
- export async function getRepositoryType(path: string): Promise<RepositoryType> {
19
- if (!(await directoryExists(path))) {
20
- return { kind: 'missing' }
21
- }
22
-
23
- try {
24
- const result = await git(
25
- ['rev-parse', '--is-bare-repository', '--show-cdup', '--git-dir'],
26
- path,
27
- 'getRepositoryType',
28
- { successExitCodes: new Set([0, 128]) }
29
- )
30
-
31
- if (result.exitCode === 0) {
32
- // Bare repositories will not include gitdir so we handle that separately
33
- if (result.stdout.startsWith('true\n')) {
34
- return { kind: 'bare' }
35
- }
36
-
37
- // --is-bare-repository and --show-cdup each produce a single line but
38
- // --git-dir could theoretically contain newlines so we parse the known
39
- // fields first and treat the remainder as the git dir. We use [\s\S]*
40
- // instead of .* for the git dir capture group because .* doesn't match
41
- // newlines whereas [\s\S]* matches any character including newlines.
42
- const match = result.stdout.match(/^(true|false)\n(.*)\n([\s\S]*)\n$/)
43
-
44
- if (match) {
45
- const [, isBare, cdup, gitDir] = match
46
-
47
- return isBare === 'true'
48
- ? { kind: 'bare' }
49
- : {
50
- kind: 'regular',
51
- topLevelWorkingDirectory: resolve(path, cdup),
52
- gitDir: resolve(path, gitDir),
53
- }
54
- }
55
- }
56
-
57
- const unsafeMatch =
58
- /fatal: detected dubious ownership in repository at '(.+)'/.exec(
59
- result.stderr
60
- )
61
- if (unsafeMatch) {
62
- return { kind: 'unsafe', path: unsafeMatch[1] }
63
- }
64
-
65
- return { kind: 'missing' }
66
- } catch (err: any) {
67
- if (err?.code === 'ENOENT') {
68
- return { kind: 'missing' }
69
- }
70
- throw err
71
- }
72
- }
73
-
74
- export async function getUpstreamRefForRef(path: string, ref?: string) {
75
- const rev = (ref ?? '') + '@{upstream}'
76
- const args = ['rev-parse', '--symbolic-full-name', rev]
77
- const opts = { successExitCodes: new Set([0, 128]) }
78
- const result = await git(args, path, 'getUpstreamRefForRef', opts)
79
-
80
- return result.exitCode === 0 ? result.stdout.trim() : null
81
- }
82
-
83
- export async function getUpstreamRemoteNameForRef(path: string, ref?: string) {
84
- const remoteRef = await getUpstreamRefForRef(path, ref)
85
- return remoteRef?.match(/^refs\/remotes\/([^/]+)\//)?.[1] ?? null
86
- }
87
-
88
- export const getCurrentUpstreamRef = (path: string) =>
89
- getUpstreamRefForRef(path)
90
-
91
- export const getCurrentUpstreamRemoteName = (path: string) =>
92
- getUpstreamRemoteNameForRef(path)
package/src/git/revert.ts DELETED
@@ -1,55 +0,0 @@
1
- import { git, IGitStringExecutionOptions } from './core'
2
-
3
- import { Repository } from '../models/repository'
4
- import { Commit } from '../models/commit'
5
- import { IRevertProgress } from '../models/progress'
6
-
7
- import { executionOptionsWithProgress } from '../lib/progress/from-process'
8
- import { RevertProgressParser } from '../lib/progress/revert'
9
- import {
10
- envForRemoteOperation,
11
- getFallbackUrlForProxyResolve,
12
- } from './environment'
13
- import { IRemote } from '../models/remote'
14
-
15
- /**
16
- * Creates a new commit that reverts the changes of a previous commit
17
- *
18
- * @param repository - The repository to update
19
- *
20
- * @param commit - The SHA of the commit to be reverted
21
- */
22
- export async function revertCommit(
23
- repository: Repository,
24
- commit: Commit,
25
- currentRemote: IRemote | null,
26
- progressCallback?: (progress: IRevertProgress) => void
27
- ) {
28
- const args = ['revert']
29
- if (commit.parentSHAs.length > 1) {
30
- args.push('-m', '1')
31
- }
32
-
33
- args.push(commit.sha)
34
-
35
- let opts: IGitStringExecutionOptions = {}
36
- if (progressCallback) {
37
- const env = await envForRemoteOperation(
38
- getFallbackUrlForProxyResolve(repository, currentRemote)
39
- )
40
- opts = await executionOptionsWithProgress(
41
- { env, trackLFSProgress: true },
42
- new RevertProgressParser(),
43
- progress => {
44
- const description =
45
- progress.kind === 'progress' ? progress.details.text : progress.text
46
- const title = progress.kind === 'progress' ? progress.details.title : ''
47
- const value = progress.percent
48
-
49
- progressCallback({ kind: 'revert', description, value, title })
50
- }
51
- )
52
- }
53
-
54
- await git(args, repository.path, 'revert', opts)
55
- }
package/src/git/rm.ts DELETED
@@ -1,31 +0,0 @@
1
- import { git } from './core'
2
- import { Repository } from '../models/repository'
3
- import { WorkingDirectoryFileChange } from '../models/status'
4
-
5
- /**
6
- * Remove all files from the index
7
- *
8
- * @param repository the repository to update
9
- */
10
- export async function unstageAllFiles(repository: Repository): Promise<void> {
11
- await git(
12
- // these flags are important:
13
- // --cached to only remove files from the index
14
- // -r to recursively remove files, in case files are in folders
15
- // -f to ignore differences between working directory and index
16
- // which will block this
17
- ['rm', '--cached', '-r', '-f', '.'],
18
- repository.path,
19
- 'unstageAllFiles'
20
- )
21
- }
22
-
23
- /**
24
- * Remove conflicted file from working tree and index
25
- */
26
- export async function removeConflictedFile(
27
- repository: Repository,
28
- file: WorkingDirectoryFileChange
29
- ) {
30
- await git(['rm', '--', file.path], repository.path, 'removeConflictedFile')
31
- }
package/src/git/spawn.ts DELETED
@@ -1,38 +0,0 @@
1
- import { spawnGit as spawn, IGitSpawnOptions } from './exec'
2
- import * as GitPerf from '../lib/git-perf'
3
- import { withTrampolineEnv } from '../lib/trampoline/trampoline-environment'
4
-
5
- type SpawnOptions = IGitSpawnOptions & {
6
- /**
7
- * Whether the command about to run is part of a background task or not.
8
- * This affects error handling and UI such as credential prompts.
9
- */
10
- readonly isBackgroundTask?: boolean
11
- }
12
-
13
- /**
14
- * Spawn a Git process, deferring all processing work to the caller.
15
- *
16
- * @param args Array of strings to pass to the Git executable.
17
- * @param path The path to execute the command from.
18
- * @param name The name of the operation - for tracing purposes.
19
- * @param successExitCodes An optional array of exit codes that indicate success.
20
- */
21
- export const spawnGit = (
22
- args: string[],
23
- path: string,
24
- name: string,
25
- options?: SpawnOptions
26
- ) =>
27
- withTrampolineEnv(
28
- trampolineEnv =>
29
- GitPerf.measure(`${name}: git ${args.join(' ')}`, async () =>
30
- spawn(args, path, {
31
- ...options,
32
- env: { ...options?.env, ...trampolineEnv },
33
- })
34
- ),
35
- path,
36
- options?.isBackgroundTask ?? false,
37
- options?.env
38
- )
package/src/git/squash.ts DELETED
@@ -1,173 +0,0 @@
1
- import { appendFile, rm, writeFile } from 'fs/promises'
2
- import { getCommits, revRange } from '.'
3
- import { Commit } from '../models/commit'
4
- import { MultiCommitOperationKind } from '../models/multi-commit-operation'
5
- import { IMultiCommitOperationProgress } from '../models/progress'
6
- import { Repository } from '../models/repository'
7
- import { getTempFilePath } from '../lib/file-system'
8
- import { rebaseInteractive, RebaseResult } from './rebase'
9
-
10
- /**
11
- * Squashes provided commits by calling interactive rebase.
12
- *
13
- * Goal is to replay the commits in order from oldest to newest to reduce
14
- * conflicts with toSquash commits placed in the log at the location of the
15
- * squashOnto commit.
16
- *
17
- * Example: A user's history from oldest to newest is A, B, C, D, E and they
18
- * want to squash A and E (toSquash) onto C. Our goal: B, A-C-E, D. Thus,
19
- * maintaining that A came before C and E came after C, placed in history at the
20
- * the squashOnto of C.
21
- *
22
- * Also means if the last 2 commits in history are A, B, whether user squashes A
23
- * onto B or B onto A. It will always perform based on log history, thus, B onto
24
- * A.
25
- *
26
- * @param toSquash - commits to squash onto another commit and does not contain the squashOnto commit
27
- * @param squashOnto - commit to squash the `toSquash` commits onto
28
- * @param lastRetainedCommitRef - sha of commit before commits in squash or null
29
- * if commit to be squash is the root (first in history) of the branch
30
- * @param commitMessage - the first line of the string provided will be the
31
- * summary and rest the body (similar to commit implementation)
32
- */
33
- export async function squash(
34
- repository: Repository,
35
- toSquash: ReadonlyArray<Commit>,
36
- squashOnto: Commit,
37
- lastRetainedCommitRef: string | null,
38
- commitMessage: string,
39
- progressCallback?: (progress: IMultiCommitOperationProgress) => void
40
- ): Promise<RebaseResult> {
41
- let messagePath, todoPath
42
- let result: RebaseResult
43
-
44
- try {
45
- if (toSquash.length === 0) {
46
- throw new Error('[squash] No commits provided to squash.')
47
- }
48
-
49
- const toSquashShas = new Set(toSquash.map(c => c.sha))
50
- if (toSquashShas.has(squashOnto.sha)) {
51
- throw new Error(
52
- '[squash] The commits to squash cannot contain the commit to squash onto.'
53
- )
54
- }
55
-
56
- const commits = await getCommits(
57
- repository,
58
- lastRetainedCommitRef === null
59
- ? undefined
60
- : revRange(lastRetainedCommitRef, 'HEAD')
61
- )
62
-
63
- if (commits.length === 0) {
64
- throw new Error(
65
- '[squash] Could not find commits in log for last retained commit ref.'
66
- )
67
- }
68
-
69
- todoPath = await getTempFilePath('squashTodo')
70
- let foundSquashOntoCommitInLog = false
71
- const toReplayAtSquash = []
72
- const toReplayAfterSquash = []
73
- // Traversed in reverse so we do oldest to newest (replay commits)
74
- for (let i = commits.length - 1; i >= 0; i--) {
75
- const commit = commits[i]
76
- if (toSquashShas.has(commit.sha)) {
77
- // If it is toSquash commit and we have found the squashOnto commit, we
78
- // can go ahead and squash them (as we will hold any picks till after)
79
- if (foundSquashOntoCommitInLog) {
80
- await appendFile(todoPath, `squash ${commit.sha} ${commit.summary}\n`)
81
- } else {
82
- // However, if we have not found the squashOnto commit yet we want to
83
- // keep track of them in the order of the log. Thus, we use a new
84
- // `toReplayAtSquash` array and not trust that what was sent is in the
85
- // order of the log.
86
- toReplayAtSquash.push(commit)
87
- }
88
-
89
- continue
90
- }
91
-
92
- // If it's the squashOnto commit, replay to the toSquash in the order they
93
- // appeared on the log to reduce potential conflicts.
94
- if (commit.sha === squashOnto.sha) {
95
- foundSquashOntoCommitInLog = true
96
- toReplayAtSquash.push(commit)
97
-
98
- for (let j = 0; j < toReplayAtSquash.length; j++) {
99
- const action = j === 0 ? 'pick' : 'squash'
100
- await appendFile(
101
- todoPath,
102
- `${action} ${toReplayAtSquash[j].sha} ${toReplayAtSquash[j].summary}\n`
103
- )
104
- }
105
-
106
- continue
107
- }
108
-
109
- // We can't just replay a pick in case there is a commit from the toSquash
110
- // commits further up in history that need to be replayed with the
111
- // squashes. Thus, we will keep track of these and replay after traversing
112
- // the remainder of the log.
113
- if (foundSquashOntoCommitInLog) {
114
- toReplayAfterSquash.push(commit)
115
- continue
116
- }
117
-
118
- // If it is not one toSquash nor the squashOnto and have not found the
119
- // squashOnto commit, we simply record it is an unchanged pick (before the
120
- // squash)
121
- await appendFile(todoPath, `pick ${commit.sha} ${commit.summary}\n`)
122
- }
123
-
124
- if (toReplayAfterSquash.length > 0) {
125
- for (let i = 0; i < toReplayAfterSquash.length; i++) {
126
- await appendFile(
127
- todoPath,
128
- `pick ${toReplayAfterSquash[i].sha} ${toReplayAfterSquash[i].summary}\n`
129
- )
130
- }
131
- }
132
-
133
- if (!foundSquashOntoCommitInLog) {
134
- throw new Error(
135
- '[squash] The commit to squash onto was not in the log. Continuing would result in dropping the commits in the toSquash array.'
136
- )
137
- }
138
-
139
- if (commitMessage.trim() !== '') {
140
- messagePath = await getTempFilePath('squashCommitMessage')
141
- await writeFile(messagePath, commitMessage)
142
- }
143
-
144
- // if no commit message provided, accept default editor
145
- const gitEditor =
146
- messagePath !== undefined ? `cat "${messagePath}" >` : undefined
147
-
148
- result = await rebaseInteractive(
149
- repository,
150
- todoPath,
151
- lastRetainedCommitRef,
152
- {
153
- action: MultiCommitOperationKind.Squash,
154
- gitEditor,
155
- progressCallback,
156
- commits: [...toSquash, squashOnto],
157
- }
158
- )
159
- } catch (e) {
160
- console.error(e)
161
- return RebaseResult.Error
162
- } finally {
163
- if (todoPath !== undefined) {
164
- await rm(todoPath, { recursive: true, force: true })
165
- }
166
-
167
- if (messagePath !== undefined) {
168
- await rm(messagePath, { recursive: true, force: true })
169
- }
170
- }
171
-
172
- return result
173
- }
package/src/git/stage.ts DELETED
@@ -1,97 +0,0 @@
1
- import { Repository } from '../models/repository'
2
- import {
3
- WorkingDirectoryFileChange,
4
- isConflictedFileStatus,
5
- GitStatusEntry,
6
- isConflictWithMarkers,
7
- } from '../models/status'
8
- import { ManualConflictResolution } from '../models/manual-conflict-resolution'
9
- import { assertNever } from '../lib/fatal-error'
10
- import { removeConflictedFile } from './rm'
11
- import { checkoutConflictedFile } from './checkout'
12
- import { addConflictedFile } from './add'
13
-
14
- /**
15
- * Stages a file with the given manual resolution method. Useful for resolving binary conflicts at commit-time.
16
- *
17
- * @param repository
18
- * @param file conflicted file to stage
19
- * @param manualResolution method to resolve the conflict of file
20
- * @returns true if successful, false if something went wrong
21
- */
22
- export async function stageManualConflictResolution(
23
- repository: Repository,
24
- file: WorkingDirectoryFileChange,
25
- manualResolution: ManualConflictResolution
26
- ): Promise<void> {
27
- const { status } = file
28
- // if somehow the file isn't in a conflicted state
29
- if (!isConflictedFileStatus(status)) {
30
- console.error(`tried to manually resolve unconflicted file (${file.path})`)
31
- return
32
- }
33
-
34
- if (isConflictWithMarkers(status) && status.conflictMarkerCount === 0) {
35
- // If somehow the user used the Desktop UI to solve the conflict via ours/theirs
36
- // but afterwards resolved manually the conflicts via an editor, used the manually
37
- // resolved file.
38
- return
39
- }
40
-
41
- const chosen =
42
- manualResolution === ManualConflictResolution.theirs
43
- ? status.entry.them
44
- : status.entry.us
45
-
46
- const addedInBoth =
47
- status.entry.us === GitStatusEntry.Added &&
48
- status.entry.them === GitStatusEntry.Added
49
-
50
- if (chosen === GitStatusEntry.UpdatedButUnmerged || addedInBoth) {
51
- await checkoutConflictedFile(repository, file, manualResolution)
52
- }
53
-
54
- switch (chosen) {
55
- case GitStatusEntry.Deleted:
56
- return removeConflictedFile(repository, file)
57
- case GitStatusEntry.Added:
58
- case GitStatusEntry.UpdatedButUnmerged:
59
- return addConflictedFile(repository, file)
60
- default:
61
- assertNever(chosen, 'unaccounted for git status entry possibility')
62
- }
63
- }
64
-
65
- /**
66
- * Stages all resolved conflict files before a checkout operation to prevent
67
- * "error: you need to resolve your current index first" from git.
68
- *
69
- * Handles two kinds of resolved conflicts:
70
- * - Text conflicts resolved in an external editor (conflictMarkerCount === 0)
71
- * - Manual conflicts where the user chose ours/theirs in the Desktop UI
72
- */
73
- export async function stageResolvedConflictFiles(
74
- repository: Repository,
75
- files: ReadonlyArray<WorkingDirectoryFileChange>,
76
- manualResolutions: ReadonlyMap<string, ManualConflictResolution>
77
- ): Promise<void> {
78
- for (const file of files) {
79
- const { status } = file
80
- if (!isConflictedFileStatus(status)) {
81
- continue
82
- }
83
-
84
- const manualResolution = manualResolutions.get(file.path)
85
-
86
- if (manualResolution !== undefined) {
87
- // Binary/manual conflict resolved via Desktop UI — stage it
88
- await stageManualConflictResolution(repository, file, manualResolution)
89
- } else if (
90
- isConflictWithMarkers(status) &&
91
- status.conflictMarkerCount === 0
92
- ) {
93
- // Text conflict resolved in external editor — stage it
94
- await addConflictedFile(repository, file)
95
- }
96
- }
97
- }