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,111 @@
1
+ import { join } from 'path';
2
+ import { git } from './core.js';
3
+ import { GitError } from './exec.js';
4
+ import { pathExists } from '../lib/path-exists.js';
5
+ import { createMultiOperationTerminalOutputCallback } from './multi-operation-terminal-output.js';
6
+ export var MergeResult;
7
+ (function (MergeResult) {
8
+ /** The merge completed successfully */
9
+ MergeResult[MergeResult["Success"] = 0] = "Success";
10
+ /**
11
+ * The merge was a noop since the current branch
12
+ * was already up to date with the target branch.
13
+ */
14
+ MergeResult[MergeResult["AlreadyUpToDate"] = 1] = "AlreadyUpToDate";
15
+ /**
16
+ * The merge failed, likely due to conflicts.
17
+ */
18
+ MergeResult[MergeResult["Failed"] = 2] = "Failed";
19
+ })(MergeResult || (MergeResult = {}));
20
+ /** Merge the named branch into the current branch. */
21
+ export async function merge(repository, branch, options) {
22
+ const onTerminalOutputAvailable = options?.onTerminalOutputAvailable
23
+ ? createMultiOperationTerminalOutputCallback(options?.onTerminalOutputAvailable)
24
+ : undefined;
25
+ const args = ['merge'];
26
+ if (options?.squash) {
27
+ args.push('--squash');
28
+ }
29
+ if (options?.noVerify) {
30
+ args.push('--no-verify');
31
+ }
32
+ args.push(branch);
33
+ const { exitCode, stdout } = await git(args, repository.path, 'merge', {
34
+ expectedErrors: new Set([GitError.MergeConflicts]),
35
+ interceptHooks: ['pre-merge-commit', 'post-merge', 'commit-msg'],
36
+ onHookProgress: options?.onHookProgress,
37
+ onHookFailure: options?.onHookFailure,
38
+ onTerminalOutputAvailable,
39
+ });
40
+ if (exitCode !== 0) {
41
+ return MergeResult.Failed;
42
+ }
43
+ if (options?.squash) {
44
+ const { exitCode } = await git(['commit', '--no-edit'], repository.path, 'createSquashMergeCommit', {
45
+ interceptHooks: [
46
+ 'pre-merge-commit',
47
+ 'prepare-commit-msg',
48
+ 'commit-msg',
49
+ 'post-commit',
50
+ 'pre-auto-gc',
51
+ ],
52
+ onHookProgress: options?.onHookProgress,
53
+ onHookFailure: options?.onHookFailure,
54
+ onTerminalOutputAvailable,
55
+ });
56
+ if (exitCode !== 0) {
57
+ return MergeResult.Failed;
58
+ }
59
+ }
60
+ return stdout === noopMergeMessage
61
+ ? MergeResult.AlreadyUpToDate
62
+ : MergeResult.Success;
63
+ }
64
+ const noopMergeMessage = 'Already up to date.\n';
65
+ /**
66
+ * Find the base commit between two commit-ish identifiers
67
+ *
68
+ * @returns the commit id of the merge base, or null if the two commit-ish
69
+ * identifiers do not have a common base
70
+ */
71
+ export async function getMergeBase(repository, firstCommitish, secondCommitish) {
72
+ const process = await git(['merge-base', firstCommitish, secondCommitish], repository.path, 'merge-base', {
73
+ // - 1 is returned if a common ancestor cannot be resolved
74
+ // - 128 is returned if a ref cannot be found
75
+ // "warning: ignoring broken ref refs/remotes/origin/main."
76
+ successExitCodes: new Set([0, 1, 128]),
77
+ });
78
+ if (process.exitCode === 1 || process.exitCode === 128) {
79
+ return null;
80
+ }
81
+ return process.stdout.trim();
82
+ }
83
+ /**
84
+ * Abort a mid-flight (conflicted) merge
85
+ *
86
+ * @param repository where to abort the merge
87
+ */
88
+ export async function abortMerge(repository) {
89
+ await git(['merge', '--abort'], repository.path, 'abortMerge');
90
+ }
91
+ /**
92
+ * Check the `.git/MERGE_HEAD` file exists in a repository to confirm
93
+ * that it is in a conflicted state.
94
+ */
95
+ export async function isMergeHeadSet(repository) {
96
+ const path = join(repository.resolvedGitDir, 'MERGE_HEAD');
97
+ return await pathExists(path);
98
+ }
99
+ /**
100
+ * Check the `.git/SQUASH_MSG` file exists in a repository
101
+ * This would indicate we did a merge --squash and have not committed.. indicating
102
+ * we have detected a conflict.
103
+ *
104
+ * Note: If we abort the merge, this doesn't get cleared automatically which
105
+ * could lead to this being erroneously available in a non merge --squashing scenario.
106
+ */
107
+ export async function isSquashMsgSet(repository) {
108
+ const path = join(repository.resolvedGitDir, 'SQUASH_MSG');
109
+ return await pathExists(path);
110
+ }
111
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/git/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,GAAG,EAAuB,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EA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AAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAsB;IACrD,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAAsB;IACzD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;IAC1D,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAAsB;IACzD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;IAC1D,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { TerminalOutputCallback } from './core.js';
2
+ /**
3
+ * Creates a callback that aggregates terminal output from multiple Git
4
+ * operations into a single stream.
5
+ *
6
+ * This function is useful when running multiple Git operations sequentially
7
+ * where you want to present a unified terminal output view. It buffers output
8
+ * from all operations and forwards them to upstream subscribers when requested.
9
+ *
10
+ * The callback maintains an internal buffer (default 256KB) and subscribes to
11
+ * each Git operation's terminal output. When an upstream consumer requests the
12
+ * output, it receives all previously buffered chunks followed by any new chunks
13
+ * as they arrive.
14
+ *
15
+ * @param onTerminalOutputAvailable - The user provided callback which will
16
+ * receive the aggregated terminal output.
17
+ * @returns A callback that can be passed to individual Git operations as the
18
+ * onTerminalOutputAvailable callback to capture their terminal output
19
+ */
20
+ export declare const createMultiOperationTerminalOutputCallback: (onTerminalOutputAvailable: TerminalOutputCallback, capacity?: number) => TerminalOutputCallback;
@@ -0,0 +1,56 @@
1
+ import noop from '../lib/noop.js';
2
+ import { pushTerminalChunk } from './push-terminal-chunk.js';
3
+ /**
4
+ * Creates a callback that aggregates terminal output from multiple Git
5
+ * operations into a single stream.
6
+ *
7
+ * This function is useful when running multiple Git operations sequentially
8
+ * where you want to present a unified terminal output view. It buffers output
9
+ * from all operations and forwards them to upstream subscribers when requested.
10
+ *
11
+ * The callback maintains an internal buffer (default 256KB) and subscribes to
12
+ * each Git operation's terminal output. When an upstream consumer requests the
13
+ * output, it receives all previously buffered chunks followed by any new chunks
14
+ * as they arrive.
15
+ *
16
+ * @param onTerminalOutputAvailable - The user provided callback which will
17
+ * receive the aggregated terminal output.
18
+ * @returns A callback that can be passed to individual Git operations as the
19
+ * onTerminalOutputAvailable callback to capture their terminal output
20
+ */
21
+ export const createMultiOperationTerminalOutputCallback = (onTerminalOutputAvailable, capacity = 256 * 1024) => {
22
+ let outputStarted = false;
23
+ const chunks = [];
24
+ const upstreamSubscribers = new Set();
25
+ const push = (chunk) => {
26
+ if (!outputStarted) {
27
+ onTerminalOutputAvailable(function (cb) {
28
+ upstreamSubscribers.add(cb);
29
+ chunks.forEach(c => cb(c));
30
+ return { unsubscribe: () => upstreamSubscribers.delete(cb) };
31
+ });
32
+ outputStarted = true;
33
+ }
34
+ pushTerminalChunk(chunks, capacity, chunk);
35
+ upstreamSubscribers.forEach(cb => cb(chunk));
36
+ };
37
+ // Called by each Git operation when terminal output is available. We'll
38
+ // subscribe immediately to capture output from all operations and then
39
+ // forward it to upstream callbacks if/when requested.
40
+ const cb = function (subscribe) {
41
+ subscribe(c => {
42
+ if (Array.isArray(c)) {
43
+ chunks.forEach(push);
44
+ }
45
+ else {
46
+ push(c);
47
+ }
48
+ });
49
+ // We can't unsubscribe because the user might request terminal output in
50
+ // the future and we need to buffer the output from all operations to
51
+ // ensure we can present the entire output.
52
+ return { unsubscribe: noop };
53
+ };
54
+ return cb;
55
+ };
56
+ //# sourceMappingURL=multi-operation-terminal-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-operation-terminal-output.js","sourceRoot":"","sources":["../../src/git/multi-operation-terminal-output.ts"],"names":[],"mappings":"A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CAAC,CAAA;YACT,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,yEAAyE;QACzE,qEAAqE;QACrE,2CAA2C;QAC3C,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAA;IAC9B,CAAC,CAAA;IAED,OAAO,EAAE,CAAA;AACX,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { HookProgress, TerminalOutput, TerminalOutputCallback } from './core.js';
2
+ import { Repository } from '../models/repository.js';
3
+ import { IPullProgress } from '../models/progress.js';
4
+ import { IRemote } from '../models/remote.js';
5
+ /**
6
+ * Pull from the specified remote.
7
+ *
8
+ * @param repository - The repository in which the pull should take place
9
+ *
10
+ * @param remote - The name of the remote that should be pulled from
11
+ *
12
+ * @param progressCallback - An optional function which will be invoked
13
+ * with information about the current progress
14
+ * of the pull operation. When provided this enables
15
+ * the '--progress' command line flag for
16
+ * 'git pull'.
17
+ */
18
+ export declare function pull(repository: Repository, remote: IRemote, options?: {
19
+ progressCallback?: (progress: IPullProgress) => void;
20
+ onHookProgress?: (progress: HookProgress) => void;
21
+ onHookFailure?: (hookName: string, terminalOutput: TerminalOutput) => Promise<'abort' | 'ignore'>;
22
+ onTerminalOutputAvailable?: TerminalOutputCallback;
23
+ noVerify?: boolean;
24
+ }): Promise<void>;
@@ -0,0 +1,91 @@
1
+ import { git, gitRebaseArguments, } from './core.js';
2
+ import { PullProgressParser, executionOptionsWithProgress } from '../lib/progress/index.js';
3
+ import { envForRemoteOperation } from './environment.js';
4
+ import { getConfigValue } from './config.js';
5
+ /**
6
+ * Pull from the specified remote.
7
+ *
8
+ * @param repository - The repository in which the pull should take place
9
+ *
10
+ * @param remote - The name of the remote that should be pulled from
11
+ *
12
+ * @param progressCallback - An optional function which will be invoked
13
+ * with information about the current progress
14
+ * of the pull operation. When provided this enables
15
+ * the '--progress' command line flag for
16
+ * 'git pull'.
17
+ */
18
+ export async function pull(repository, remote, options) {
19
+ let opts = {
20
+ env: await envForRemoteOperation(remote.url),
21
+ // git pull triggers merge or rebase hooks depending on config, instead of
22
+ // trying to check pull.rebase and friends we'll just intercept all possible
23
+ // hooks that could be run as part of a pull operation.
24
+ interceptHooks: [
25
+ 'pre-merge-commit',
26
+ 'prepare-commit-msg',
27
+ 'commit-msg',
28
+ 'post-merge',
29
+ 'pre-rebase',
30
+ 'pre-commit',
31
+ 'post-rewrite',
32
+ ],
33
+ };
34
+ if (options?.progressCallback) {
35
+ const title = `Pulling ${remote.name}`;
36
+ const kind = 'pull';
37
+ opts = await executionOptionsWithProgress({ ...opts, trackLFSProgress: true }, new PullProgressParser(), progress => {
38
+ // In addition to progress output from the remote end and from
39
+ // git itself, the stderr output from pull contains information
40
+ // about ref updates. We don't need to bring those into the progress
41
+ // stream so we'll just punt on anything we don't know about for now.
42
+ if (progress.kind === 'context') {
43
+ if (!progress.text.startsWith('remote: Counting objects')) {
44
+ return;
45
+ }
46
+ }
47
+ const description = progress.kind === 'progress' ? progress.details.text : progress.text;
48
+ const value = progress.percent;
49
+ options?.progressCallback?.({
50
+ kind,
51
+ title,
52
+ description,
53
+ value,
54
+ remote: remote.name,
55
+ });
56
+ });
57
+ // Initial progress
58
+ options.progressCallback({ kind, title, value: 0, remote: remote.name });
59
+ }
60
+ const args = [
61
+ ...gitRebaseArguments(),
62
+ 'pull',
63
+ ...(await getDefaultPullDivergentBranchArguments(repository)),
64
+ '--recurse-submodules',
65
+ ...(options?.progressCallback ? ['--progress'] : []),
66
+ ...(options?.noVerify ? ['--no-verify'] : []),
67
+ remote.name,
68
+ ];
69
+ await git(args, repository.path, 'pull', opts);
70
+ }
71
+ /**
72
+ * Defaults the pull default for divergent paths to try to fast forward and if
73
+ * not perform a merge. Aka uses the flag --ff
74
+ *
75
+ * It checks whether the user has a config set for this already, if so, no need for
76
+ * default.
77
+ */
78
+ async function getDefaultPullDivergentBranchArguments(repository) {
79
+ try {
80
+ const pullFF = await getConfigValue(repository, 'pull.ff');
81
+ return pullFF !== null ? [] : ['--ff'];
82
+ }
83
+ catch (e) {
84
+ console.error("Couldn't read 'pull.ff' config", e);
85
+ }
86
+ // If there is a failure in checking the config, we still want to use any
87
+ // config and not overwrite the user's set config behavior. This will show the
88
+ // git error if no config is set.
89
+ return [];
90
+ }
91
+ //# sourceMappingURL=pull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/git/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,kBAAkB,GAKnB,MAAM,WAAW,CAAA;AAGlB,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAE3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,UAAsB,EACtB,MAAe,EACf,OASC;IAED,IAAI,IAAI,GAA+B;QACrC,GAAG,EAAE,MAAM,qBAAqB,CAAC,MAAM,CAAC,GAAG,CAAC;QAC5C,0EAA0E;QAC1E,4EAA4E;QAC5E,uDAAuD;QACvD,cAAc,EAAE;YACd,kBAAkB;YAClB,oBAAoB;YACpB,YAAY;YACZ,YAAY;YACZ,YAAY;YACZ,YAAY;YACZ,cAAc;SACf;KACF,CAAA;IAED,IAAI,OAAO,EAAE,gBAAgB,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,WAAW,MAAM,CAAC,IAAI,EAAE,CAAA;QACtC,MAAM,IAAI,GAAG,MAAM,CAAA;QAEnB,IAAI,GAAG,MAAM,4BAA4B,CACvC,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,EACnC,IAAI,kBAAkB,EAAE,EACxB,QAAQ,CAAC,EAAE;YACT,8DAA8D;YAC9D,+DAA+D;YAC/D,oEAAoE;YACpE,qEAAqE;YACrE,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;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,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;QAC1D,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,yEAAyE;IACzE,8EAA8E;IAC9E,iCAAiC;IACjC,OAAO,EAAE,CAAA;AACX,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Appends a chunk of terminal output to a buffer while maintaining a maximum capacity.
3
+ *
4
+ * This function manages a rolling buffer of terminal output (combined stdout and stderr)
5
+ * by pushing new chunks and trimming from the beginning when the total character count
6
+ * exceeds the specified capacity. This ensures memory-bounded storage of terminal output
7
+ * for git operations.
8
+ *
9
+ * @param chunks - The array of string chunks representing the terminal output buffer.
10
+ * This array is mutated in place.
11
+ * @param capacity - The maximum number of characters to retain in the buffer.
12
+ * Note: this is character count, not byte count.
13
+ * @param chunk - The new chunk of terminal output to append, either as a Buffer or string.
14
+ *
15
+ * Intended to be used by git operations in core.ts to capture and limit terminal output.
16
+ * When the buffer exceeds capacity, chunks are removed from the beginning (oldest first),
17
+ * and partial chunks may be trimmed to fit exactly within the capacity limit.
18
+ */
19
+ export declare const pushTerminalChunk: (chunks: string[], capacity: number, chunk: Buffer | string) => void;
@@ -0,0 +1,36 @@
1
+ import { coerceToString } from './coerce-to-string.js';
2
+ /**
3
+ * Appends a chunk of terminal output to a buffer while maintaining a maximum capacity.
4
+ *
5
+ * This function manages a rolling buffer of terminal output (combined stdout and stderr)
6
+ * by pushing new chunks and trimming from the beginning when the total character count
7
+ * exceeds the specified capacity. This ensures memory-bounded storage of terminal output
8
+ * for git operations.
9
+ *
10
+ * @param chunks - The array of string chunks representing the terminal output buffer.
11
+ * This array is mutated in place.
12
+ * @param capacity - The maximum number of characters to retain in the buffer.
13
+ * Note: this is character count, not byte count.
14
+ * @param chunk - The new chunk of terminal output to append, either as a Buffer or string.
15
+ *
16
+ * Intended to be used by git operations in core.ts to capture and limit terminal output.
17
+ * When the buffer exceeds capacity, chunks are removed from the beginning (oldest first),
18
+ * and partial chunks may be trimmed to fit exactly within the capacity limit.
19
+ */
20
+ export const pushTerminalChunk = (chunks, capacity, chunk) => {
21
+ chunks.push(coerceToString(chunk));
22
+ let terminalOutputLength = chunks.reduce((acc, cur) => acc + cur.length, 0);
23
+ while (terminalOutputLength > capacity) {
24
+ const firstChunk = chunks[0];
25
+ const overrun = terminalOutputLength - capacity;
26
+ if (overrun >= firstChunk.length) {
27
+ chunks.shift();
28
+ terminalOutputLength -= firstChunk.length;
29
+ }
30
+ else {
31
+ chunks[0] = firstChunk.substring(overrun);
32
+ terminalOutputLength -= overrun;
33
+ }
34
+ }
35
+ };
36
+ //# sourceMappingURL=push-terminal-chunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-terminal-chunk.js","sourceRoot":"","sources":["../../src/git/push-terminal-chunk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,MAAgB,EAChB,QAAgB,EAChB,KAAsB,EACtB,EAAE;IACF,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;IAClC,IAAI,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAE3E,OAAO,oBAAoB,GAAG,QAAQ,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QAC5B,MAAM,OAAO,GAAG,oBAAoB,GAAG,QAAQ,CAAA;QAE/C,IAAI,OAAO,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACjC,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,oBAAoB,IAAI,UAAU,CAAC,MAAM,CAAA;QAC3C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;YACzC,oBAAoB,IAAI,OAAO,CAAA;QACjC,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { HookCallbackOptions } from './core.js';
2
+ import { Repository } from '../models/repository.js';
3
+ import { IPushProgress } from '../models/progress.js';
4
+ import { IRemote } from '../models/remote.js';
5
+ import { Branch } from '../models/branch.js';
6
+ export type PushOptions = {
7
+ /**
8
+ * Force-push the branch without losing changes in the remote that
9
+ * haven't been fetched.
10
+ *
11
+ * See https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-force-with-lease
12
+ */
13
+ readonly forceWithLease?: boolean;
14
+ /** A branch to push instead of the current branch */
15
+ readonly branch?: Branch;
16
+ readonly noVerify?: boolean;
17
+ } & HookCallbackOptions;
18
+ /**
19
+ * Push from the remote to the branch, optionally setting the upstream.
20
+ *
21
+ * @param repository - The repository from which to push
22
+ *
23
+ * @param account - The account to use when authenticating with the remote
24
+ *
25
+ * @param remote - The remote to push the specified branch to
26
+ *
27
+ * @param localBranch - The local branch to push
28
+ *
29
+ * @param remoteBranch - The remote branch to push to
30
+ *
31
+ * @param tagsToPush - The tags to push along with the branch.
32
+ *
33
+ * @param options - Optional customizations for the push execution.
34
+ * see PushOptions for more information.
35
+ *
36
+ * @param progressCallback - An optional function which will be invoked
37
+ * with information about the current progress
38
+ * of the push operation. When provided this enables
39
+ * the '--progress' command line flag for
40
+ * 'git push'.
41
+ */
42
+ export declare function push(repository: Repository, remote: IRemote, localBranch: string, remoteBranch: string | null, tagsToPush: ReadonlyArray<string> | null, options?: PushOptions, progressCallback?: (progress: IPushProgress) => void): Promise<void>;
@@ -0,0 +1,80 @@
1
+ import { git } from './core.js';
2
+ import { PushProgressParser, executionOptionsWithProgress } from '../lib/progress/index.js';
3
+ import { envForRemoteOperation } from './environment.js';
4
+ /**
5
+ * Push from the remote to the branch, optionally setting the upstream.
6
+ *
7
+ * @param repository - The repository from which to push
8
+ *
9
+ * @param account - The account to use when authenticating with the remote
10
+ *
11
+ * @param remote - The remote to push the specified branch to
12
+ *
13
+ * @param localBranch - The local branch to push
14
+ *
15
+ * @param remoteBranch - The remote branch to push to
16
+ *
17
+ * @param tagsToPush - The tags to push along with the branch.
18
+ *
19
+ * @param options - Optional customizations for the push execution.
20
+ * see PushOptions for more information.
21
+ *
22
+ * @param progressCallback - An optional function which will be invoked
23
+ * with information about the current progress
24
+ * of the push operation. When provided this enables
25
+ * the '--progress' command line flag for
26
+ * 'git push'.
27
+ */
28
+ export async function push(repository, remote, localBranch, remoteBranch, tagsToPush, options, progressCallback) {
29
+ const args = [
30
+ 'push',
31
+ remote.name,
32
+ remoteBranch ? `${localBranch}:${remoteBranch}` : localBranch,
33
+ ];
34
+ if (tagsToPush !== null) {
35
+ args.push(...tagsToPush);
36
+ }
37
+ if (!remoteBranch) {
38
+ args.push('--set-upstream');
39
+ }
40
+ else if (options?.forceWithLease) {
41
+ args.push('--force-with-lease');
42
+ }
43
+ if (options?.noVerify) {
44
+ args.push('--no-verify');
45
+ }
46
+ let opts = {
47
+ env: await envForRemoteOperation(remote.url),
48
+ interceptHooks: ['pre-push'],
49
+ onHookProgress: options?.onHookProgress,
50
+ onHookFailure: options?.onHookFailure,
51
+ onTerminalOutputAvailable: options?.onTerminalOutputAvailable,
52
+ };
53
+ if (progressCallback) {
54
+ args.push('--progress');
55
+ const title = `Pushing to ${remote.name}`;
56
+ const kind = 'push';
57
+ opts = await executionOptionsWithProgress({ ...opts, trackLFSProgress: true }, new PushProgressParser(), progress => {
58
+ const description = progress.kind === 'progress' ? progress.details.text : progress.text;
59
+ const value = progress.percent;
60
+ progressCallback({
61
+ kind,
62
+ title,
63
+ description,
64
+ value,
65
+ remote: remote.name,
66
+ branch: localBranch,
67
+ });
68
+ });
69
+ // Initial progress
70
+ progressCallback({
71
+ kind: 'push',
72
+ title,
73
+ value: 0,
74
+ remote: remote.name,
75
+ branch: localBranch,
76
+ });
77
+ }
78
+ await git(args, repository.path, 'push', opts);
79
+ }
80
+ //# sourceMappingURL=push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push.js","sourceRoot":"","sources":["../../src/git/push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAmD,MAAM,WAAW,CAAA;AAGhF,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAA;AAE3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAkBxD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,UAAsB,EACtB,MAAe,EACf,WAAmB,EACnB,YAA2B,EAC3B,UAAwC,EACxC,OAAqB,EACrB,gBAAoD;IAEpD,MAAM,IAAI,GAAG;QACX,MAAM;QACN,MAAM,CAAC,IAAI;QACX,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,WAAW;KAC9D,CAAA;IAED,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAA;IAC1B,CAAC;IACD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;IAC7B,CAAC;SAAM,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;IACjC,CAAC;IAED,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAC1B,CAAC;IAED,IA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
1
+ import { Repository } from '../models/repository.js';
2
+ import { RebaseInternalState } from '../models/rebase.js';
3
+ import { IMultiCommitOperationProgress } from '../models/progress.js';
4
+ import { WorkingDirectoryFileChange } from '../models/status.js';
5
+ import { ManualConflictResolution } from '../models/manual-conflict-resolution.js';
6
+ import { Commit, CommitOneLine } from '../models/commit.js';
7
+ import { HookCallbackOptions } from './core.js';
8
+ import { Branch } from '../models/branch.js';
9
+ /** The app-specific results from attempting to rebase a repository */
10
+ export declare enum RebaseResult {
11
+ /**
12
+ * Git completed the rebase without reporting any errors, and the caller can
13
+ * signal success to the user.
14
+ */
15
+ CompletedWithoutError = "CompletedWithoutError",
16
+ /**
17
+ * Git completed the rebase without reporting any errors, but the branch was
18
+ * already up to date and there was nothing to do.
19
+ */
20
+ AlreadyUpToDate = "AlreadyUpToDate",
21
+ /**
22
+ * The rebase encountered conflicts while attempting to rebase, and these
23
+ * need to be resolved by the user before the rebase can continue.
24
+ */
25
+ ConflictsEncountered = "ConflictsEncountered",
26
+ /**
27
+ * The rebase was not able to continue as tracked files were not staged in
28
+ * the index.
29
+ */
30
+ OutstandingFilesNotStaged = "OutstandingFilesNotStaged",
31
+ /**
32
+ * The rebase was not attempted because it could not check the status of the
33
+ * repository. The caller needs to confirm the repository is in a usable
34
+ * state.
35
+ */
36
+ Aborted = "Aborted",
37
+ /**
38
+ * An unexpected error as part of the rebase flow was caught and handled.
39
+ *
40
+ * Check the logs to find the relevant Git details.
41
+ */
42
+ Error = "Error"
43
+ }
44
+ /**
45
+ * Get the internal state about the rebase being performed on a repository. This
46
+ * information is required to help Desktop display information to the user
47
+ * about the current action as well as the options available.
48
+ *
49
+ * Returns `null` if no rebase is detected, or if the expected information
50
+ * cannot be found in the repository.
51
+ */
52
+ export declare function getRebaseInternalState(repository: Repository): Promise<RebaseInternalState | null>;
53
+ /**
54
+ * Inspect the `.git/rebase-merge` folder and convert the current rebase state
55
+ * into data that can be provided to the rebase flow to update the application
56
+ * state.
57
+ *
58
+ * This is required when Desktop is not responsible for initiating the rebase:
59
+ *
60
+ * - when a rebase outside Desktop encounters conflicts
61
+ * - when a `git pull --rebase` was run and encounters conflicts
62
+ *
63
+ */
64
+ export declare function getRebaseSnapshot(repository: Repository): Promise<{
65
+ progress: IMultiCommitOperationProgress;
66
+ commits: ReadonlyArray<CommitOneLine>;
67
+ } | null>;
68
+ /**
69
+ * A stub function to use for initiating rebase in the app.
70
+ *
71
+ * If the rebase fails, the repository will be in an indeterminate state where
72
+ * the rebase is stuck.
73
+ *
74
+ * If the rebase completes without error, `featureBranch` will be checked out
75
+ * and it will probably have a different commit history.
76
+ *
77
+ * @param baseBranch the ref to start the rebase from
78
+ * @param targetBranch the ref to rebase onto `baseBranch`
79
+ */
80
+ export declare function rebase(repository: Repository, baseBranch: Branch, targetBranch: Branch, progressCallback?: (progress: IMultiCommitOperationProgress) => void): Promise<RebaseResult>;
81
+ /** Abandon the current rebase operation */
82
+ export declare function abortRebase(repository: Repository): Promise<void>;
83
+ /**
84
+ * Proceed with the current rebase operation and report back on whether it completed
85
+ *
86
+ * It is expected that the index has staged files which are cleanly rebased onto
87
+ * the base branch, and the remaining unstaged files are those which need manual
88
+ * resolution or were changed by the user to address inline conflicts.
89
+ *
90
+ */
91
+ export declare function continueRebase(repository: Repository, files: ReadonlyArray<WorkingDirectoryFileChange>, manualResolutions?: ReadonlyMap<string, ManualConflictResolution>, opts?: RebaseInteractiveOptions): Promise<RebaseResult>;
92
+ export type RebaseInteractiveOptions = {
93
+ /**
94
+ * a description of the action to be displayed in the progress dialog - i.e. Squash, Amend, etc..
95
+ */
96
+ action?: string;
97
+ /**
98
+ * the GIT_EDITOR environment variable to use during the interactive rebase,
99
+ * defaults to ':' which is a no-op command
100
+ */
101
+ gitEditor?: string;
102
+ progressCallback?: (progress: IMultiCommitOperationProgress) => void;
103
+ commits?: ReadonlyArray<Commit>;
104
+ noVerify?: boolean;
105
+ } & HookCallbackOptions;
106
+ /**
107
+ * Method for initiating interactive rebase in the app.
108
+ *
109
+ * In order to modify the interactive todo list during interactive rebase, we
110
+ * create a temporary todo list of our own. Pass that file's path into our
111
+ * interactive rebase and using the sequence.editor to cat replace the
112
+ * interactive todo list with the contents of our generated one.
113
+ *
114
+ * @param pathOfGeneratedTodo path to generated todo list for interactive rebase
115
+ * @param lastRetainedCommitRef the commit before the earliest commit to be
116
+ * changed during the interactive rebase or null if commit is root (first commit
117
+ * in history) of branch
118
+ */
119
+ export declare function rebaseInteractive(repository: Repository, pathOfGeneratedTodo: string, lastRetainedCommitRef: string | null, opts?: RebaseInteractiveOptions): Promise<RebaseResult>;