git-chopstick-core 0.1.0 → 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 (427) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +324 -32
  3. package/dist/git/add.d.ts +9 -0
  4. package/dist/git/add.js +11 -0
  5. package/dist/git/add.js.map +1 -0
  6. package/dist/git/apply.d.ts +33 -0
  7. package/dist/git/apply.js +103 -0
  8. package/dist/git/apply.js.map +1 -0
  9. package/dist/git/authentication.d.ts +5 -0
  10. package/dist/git/authentication.js +19 -0
  11. package/dist/git/authentication.js.map +1 -0
  12. package/dist/git/branch.d.ts +43 -0
  13. package/dist/git/branch.js +150 -0
  14. package/dist/git/branch.js.map +1 -0
  15. package/dist/git/checkout-index.d.ts +19 -0
  16. package/dist/git/checkout-index.js +29 -0
  17. package/dist/git/checkout-index.js.map +1 -0
  18. package/dist/git/checkout.d.ts +46 -0
  19. package/dist/git/checkout.js +126 -0
  20. package/dist/git/checkout.js.map +1 -0
  21. package/dist/git/cherry-pick.d.ts +82 -0
  22. package/dist/git/cherry-pick.js +371 -0
  23. package/dist/git/cherry-pick.js.map +1 -0
  24. package/dist/git/clean.d.ts +5 -0
  25. package/dist/git/clean.js +8 -0
  26. package/dist/git/clean.js.map +1 -0
  27. package/dist/git/clone.d.ts +22 -0
  28. package/dist/git/clone.js +58 -0
  29. package/dist/git/clone.js.map +1 -0
  30. package/dist/git/coerce-to-buffer.d.ts +1 -0
  31. package/dist/git/coerce-to-buffer.js +2 -0
  32. package/dist/git/coerce-to-buffer.js.map +1 -0
  33. package/dist/git/coerce-to-string.d.ts +1 -0
  34. package/dist/git/coerce-to-string.js +2 -0
  35. package/dist/git/coerce-to-string.js.map +1 -0
  36. package/dist/git/commit.d.ts +25 -0
  37. package/dist/git/commit.js +99 -0
  38. package/dist/git/commit.js.map +1 -0
  39. package/dist/git/config.d.ts +98 -0
  40. package/dist/git/config.js +249 -0
  41. package/dist/git/config.js.map +1 -0
  42. package/dist/git/core.d.ts +167 -0
  43. package/dist/git/core.js +368 -0
  44. package/dist/git/core.js.map +1 -0
  45. package/dist/git/create-tail-stream.d.ts +4 -0
  46. package/dist/git/create-tail-stream.js +30 -0
  47. package/dist/git/create-tail-stream.js.map +1 -0
  48. package/dist/git/credential.d.ts +5 -0
  49. package/dist/git/credential.js +64 -0
  50. package/dist/git/credential.js.map +1 -0
  51. package/dist/git/description.d.ts +5 -0
  52. package/dist/git/description.js +24 -0
  53. package/dist/git/description.js.map +1 -0
  54. package/dist/git/diff-check.d.ts +7 -0
  55. package/dist/git/diff-check.js +17 -0
  56. package/dist/git/diff-check.js.map +1 -0
  57. package/dist/git/diff-index.d.ts +31 -0
  58. package/dist/git/diff-index.js +76 -0
  59. package/dist/git/diff-index.js.map +1 -0
  60. package/dist/git/diff.d.ts +81 -0
  61. package/dist/git/diff.js +611 -0
  62. package/dist/git/diff.js.map +1 -0
  63. package/dist/git/environment.d.ts +51 -0
  64. package/dist/git/environment.js +97 -0
  65. package/dist/git/environment.js.map +1 -0
  66. package/dist/git/exec.d.ts +109 -0
  67. package/dist/git/exec.js +224 -0
  68. package/dist/git/exec.js.map +1 -0
  69. package/dist/git/fetch.d.ts +25 -0
  70. package/dist/git/fetch.js +100 -0
  71. package/dist/git/fetch.js.map +1 -0
  72. package/dist/git/for-each-ref.d.ts +13 -0
  73. package/dist/git/for-each-ref.js +114 -0
  74. package/dist/git/for-each-ref.js.map +1 -0
  75. package/dist/git/format-patch.d.ts +10 -0
  76. package/dist/git/format-patch.js +16 -0
  77. package/dist/git/format-patch.js.map +1 -0
  78. package/dist/git/git-delimiter-parser.d.ts +38 -0
  79. package/dist/git/git-delimiter-parser.js +79 -0
  80. package/dist/git/git-delimiter-parser.js.map +1 -0
  81. package/dist/git/gitignore.d.ts +26 -0
  82. package/dist/git/gitignore.js +124 -0
  83. package/dist/git/gitignore.js.map +1 -0
  84. package/dist/git/index.d.ts +46 -0
  85. package/dist/git/index.js +47 -0
  86. package/dist/git/index.js.map +1 -0
  87. package/dist/git/init.d.ts +2 -0
  88. package/dist/git/init.js +7 -0
  89. package/dist/git/init.js.map +1 -0
  90. package/dist/git/interpret-trailers.d.ts +88 -0
  91. package/dist/git/interpret-trailers.js +130 -0
  92. package/dist/git/interpret-trailers.js.map +1 -0
  93. package/dist/git/lfs.d.ts +25 -0
  94. package/dist/git/lfs.js +73 -0
  95. package/dist/git/lfs.js.map +1 -0
  96. package/dist/git/log.d.ts +56 -0
  97. package/dist/git/log.js +258 -0
  98. package/dist/git/log.js.map +1 -0
  99. package/dist/git/merge-tree.d.ts +13 -0
  100. package/dist/git/merge-tree.js +24 -0
  101. package/dist/git/merge-tree.js.map +1 -0
  102. package/dist/git/merge.d.ts +50 -0
  103. package/dist/git/merge.js +111 -0
  104. package/dist/git/merge.js.map +1 -0
  105. package/dist/git/multi-operation-terminal-output.d.ts +20 -0
  106. package/dist/git/multi-operation-terminal-output.js +56 -0
  107. package/dist/git/multi-operation-terminal-output.js.map +1 -0
  108. package/dist/git/pull.d.ts +24 -0
  109. package/dist/git/pull.js +91 -0
  110. package/dist/git/pull.js.map +1 -0
  111. package/dist/git/push-terminal-chunk.d.ts +19 -0
  112. package/dist/git/push-terminal-chunk.js +36 -0
  113. package/dist/git/push-terminal-chunk.js.map +1 -0
  114. package/dist/git/push.d.ts +42 -0
  115. package/dist/git/push.js +80 -0
  116. package/dist/git/push.js.map +1 -0
  117. package/dist/git/rebase.d.ts +119 -0
  118. package/dist/git/rebase.js +415 -0
  119. package/dist/git/rebase.js.map +1 -0
  120. package/dist/git/reflog.d.ts +14 -0
  121. package/dist/git/reflog.js +88 -0
  122. package/dist/git/reflog.js.map +1 -0
  123. package/dist/git/refs.d.ts +26 -0
  124. package/dist/git/refs.js +53 -0
  125. package/dist/git/refs.js.map +1 -0
  126. package/dist/git/remote.d.ts +31 -0
  127. package/dist/git/remote.js +81 -0
  128. package/dist/git/remote.js.map +1 -0
  129. package/dist/git/reorder.d.ts +23 -0
  130. package/dist/git/reorder.js +111 -0
  131. package/dist/git/reorder.js.map +1 -0
  132. package/dist/git/reset.d.ts +41 -0
  133. package/dist/git/reset.js +86 -0
  134. package/dist/git/reset.js.map +1 -0
  135. package/dist/git/rev-list.d.ts +67 -0
  136. package/dist/git/rev-list.js +157 -0
  137. package/dist/git/rev-list.js.map +1 -0
  138. package/dist/git/rev-parse.d.ts +24 -0
  139. package/dist/git/rev-parse.js +65 -0
  140. package/dist/git/rev-parse.js.map +1 -0
  141. package/dist/git/revert.d.ts +12 -0
  142. package/dist/git/revert.js +30 -0
  143. package/dist/git/revert.js.map +1 -0
  144. package/dist/git/rm.d.ts +12 -0
  145. package/dist/git/rm.js +22 -0
  146. package/dist/git/rm.js.map +1 -0
  147. package/dist/git/show.d.ts +42 -0
  148. package/dist/git/show.js +59 -0
  149. package/dist/git/show.js.map +1 -0
  150. package/dist/git/spawn.d.ts +18 -0
  151. package/dist/git/spawn.js +16 -0
  152. package/dist/git/spawn.js.map +1 -0
  153. package/dist/git/squash.d.ts +28 -0
  154. package/dist/git/squash.js +127 -0
  155. package/dist/git/squash.js.map +1 -0
  156. package/dist/git/stage.d.ts +21 -0
  157. package/dist/git/stage.js +72 -0
  158. package/dist/git/stage.js.map +1 -0
  159. package/dist/git/stash.d.ts +53 -0
  160. package/dist/git/stash.js +204 -0
  161. package/dist/git/stash.js.map +1 -0
  162. package/dist/git/status.d.ts +39 -0
  163. package/dist/git/status.js +293 -0
  164. package/dist/git/status.js.map +1 -0
  165. package/dist/git/submodule.d.ts +20 -0
  166. package/dist/git/submodule.js +153 -0
  167. package/dist/git/submodule.js.map +1 -0
  168. package/dist/git/tag.d.ts +32 -0
  169. package/dist/git/tag.js +101 -0
  170. package/dist/git/tag.js.map +1 -0
  171. package/dist/git/update-index.d.ts +11 -0
  172. package/dist/git/update-index.js +99 -0
  173. package/dist/git/update-index.js.map +1 -0
  174. package/dist/git/update-ref.d.ts +23 -0
  175. package/dist/git/update-ref.js +32 -0
  176. package/dist/git/update-ref.js.map +1 -0
  177. package/dist/git/var.d.ts +18 -0
  178. package/dist/git/var.js +33 -0
  179. package/dist/git/var.js.map +1 -0
  180. package/dist/git/worktree-include.d.ts +42 -0
  181. package/dist/git/worktree-include.js +109 -0
  182. package/dist/git/worktree-include.js.map +1 -0
  183. package/dist/git/worktree.d.ts +25 -0
  184. package/dist/git/worktree.js +139 -0
  185. package/dist/git/worktree.js.map +1 -0
  186. package/dist/index.d.ts +4 -0
  187. package/dist/index.js +7 -0
  188. package/dist/index.js.map +1 -0
  189. package/dist/lib/api.d.ts +2 -0
  190. package/dist/lib/api.js +7 -0
  191. package/dist/lib/api.js.map +1 -0
  192. package/dist/lib/diff-parser.d.ts +20 -0
  193. package/dist/lib/diff-parser.js +184 -0
  194. package/dist/lib/diff-parser.js.map +1 -0
  195. package/dist/lib/directory-exists.d.ts +1 -0
  196. package/dist/lib/directory-exists.js +11 -0
  197. package/dist/lib/directory-exists.js.map +1 -0
  198. package/dist/lib/errno-exception.d.ts +6 -0
  199. package/dist/lib/errno-exception.js +6 -0
  200. package/dist/lib/errno-exception.js.map +1 -0
  201. package/dist/lib/fatal-error.d.ts +4 -0
  202. package/dist/lib/fatal-error.js +18 -0
  203. package/dist/lib/fatal-error.js.map +1 -0
  204. package/dist/lib/feature-flag.d.ts +14 -0
  205. package/dist/lib/feature-flag.js +25 -0
  206. package/dist/lib/feature-flag.js.map +1 -0
  207. package/dist/lib/file-system.d.ts +1 -0
  208. package/dist/lib/file-system.js +7 -0
  209. package/dist/lib/file-system.js.map +1 -0
  210. package/dist/lib/get-old-path.d.ts +2 -0
  211. package/dist/lib/get-old-path.js +9 -0
  212. package/dist/lib/get-old-path.js.map +1 -0
  213. package/dist/lib/git/environment.d.ts +3 -0
  214. package/dist/lib/git/environment.js +7 -0
  215. package/dist/lib/git/environment.js.map +1 -0
  216. package/dist/lib/git-perf.d.ts +1 -0
  217. package/dist/lib/git-perf.js +4 -0
  218. package/dist/lib/git-perf.js.map +1 -0
  219. package/dist/lib/helpers/default-branch.d.ts +1 -0
  220. package/dist/lib/helpers/default-branch.js +4 -0
  221. package/dist/lib/helpers/default-branch.js.map +1 -0
  222. package/dist/lib/helpers/path.d.ts +1 -0
  223. package/dist/lib/helpers/path.js +5 -0
  224. package/dist/lib/helpers/path.js.map +1 -0
  225. package/dist/lib/hooks/with-hooks-env.d.ts +3 -0
  226. package/dist/lib/hooks/with-hooks-env.js +4 -0
  227. package/dist/lib/hooks/with-hooks-env.js.map +1 -0
  228. package/dist/lib/merge.d.ts +1 -0
  229. package/dist/lib/merge.js +4 -0
  230. package/dist/lib/merge.js.map +1 -0
  231. package/dist/lib/noop.d.ts +1 -0
  232. package/dist/lib/noop.js +2 -0
  233. package/dist/lib/noop.js.map +1 -0
  234. package/dist/lib/patch-formatter.d.ts +5 -0
  235. package/dist/lib/patch-formatter.js +7 -0
  236. package/dist/lib/patch-formatter.js.map +1 -0
  237. package/dist/lib/path-exists.d.ts +1 -0
  238. package/dist/lib/path-exists.js +3 -0
  239. package/dist/lib/path-exists.js.map +1 -0
  240. package/dist/lib/progress/from-process.d.ts +2 -0
  241. package/dist/lib/progress/from-process.js +4 -0
  242. package/dist/lib/progress/from-process.js.map +1 -0
  243. package/dist/lib/progress/index.d.ts +49 -0
  244. package/dist/lib/progress/index.js +32 -0
  245. package/dist/lib/progress/index.js.map +1 -0
  246. package/dist/lib/progress/revert.d.ts +8 -0
  247. package/dist/lib/progress/revert.js +15 -0
  248. package/dist/lib/progress/revert.js.map +1 -0
  249. package/dist/lib/rebase.d.ts +1 -0
  250. package/dist/lib/rebase.js +4 -0
  251. package/dist/lib/rebase.js.map +1 -0
  252. package/dist/lib/remove-remote-prefix.d.ts +1 -0
  253. package/dist/lib/remove-remote-prefix.js +5 -0
  254. package/dist/lib/remove-remote-prefix.js.map +1 -0
  255. package/dist/lib/resolve-git-proxy.d.ts +1 -0
  256. package/dist/lib/resolve-git-proxy.js +4 -0
  257. package/dist/lib/resolve-git-proxy.js.map +1 -0
  258. package/dist/lib/round.d.ts +1 -0
  259. package/dist/lib/round.js +5 -0
  260. package/dist/lib/round.js.map +1 -0
  261. package/dist/lib/split-buffer.d.ts +1 -0
  262. package/dist/lib/split-buffer.js +15 -0
  263. package/dist/lib/split-buffer.js.map +1 -0
  264. package/dist/lib/status-parser.d.ts +19 -0
  265. package/dist/lib/status-parser.js +137 -0
  266. package/dist/lib/status-parser.js.map +1 -0
  267. package/dist/lib/stores/helpers/find-default-remote.d.ts +1 -0
  268. package/dist/lib/stores/helpers/find-default-remote.js +4 -0
  269. package/dist/lib/stores/helpers/find-default-remote.js.map +1 -0
  270. package/dist/lib/trampoline/trampoline-environment.d.ts +1 -0
  271. package/dist/lib/trampoline/trampoline-environment.js +4 -0
  272. package/dist/lib/trampoline/trampoline-environment.js.map +1 -0
  273. package/dist/models/branch.d.ts +44 -0
  274. package/dist/models/branch.js +59 -0
  275. package/dist/models/branch.js.map +1 -0
  276. package/dist/models/cherry-pick.d.ts +11 -0
  277. package/dist/models/cherry-pick.js +2 -0
  278. package/dist/models/cherry-pick.js.map +1 -0
  279. package/dist/models/clone-options.d.ts +6 -0
  280. package/dist/models/clone-options.js +2 -0
  281. package/dist/models/clone-options.js.map +1 -0
  282. package/dist/models/commit-identity.d.ts +9 -0
  283. package/dist/models/commit-identity.js +34 -0
  284. package/dist/models/commit-identity.js.map +1 -0
  285. package/dist/models/commit.d.ts +30 -0
  286. package/dist/models/commit.js +32 -0
  287. package/dist/models/commit.js.map +1 -0
  288. package/dist/models/computed-action.d.ts +6 -0
  289. package/dist/models/computed-action.js +8 -0
  290. package/dist/models/computed-action.js.map +1 -0
  291. package/dist/models/diff/diff-data.d.ts +53 -0
  292. package/dist/models/diff/diff-data.js +19 -0
  293. package/dist/models/diff/diff-data.js.map +1 -0
  294. package/dist/models/diff/diff-line.d.ts +18 -0
  295. package/dist/models/diff/diff-line.js +33 -0
  296. package/dist/models/diff/diff-line.js.map +1 -0
  297. package/dist/models/diff/diff-selection.d.ts +22 -0
  298. package/dist/models/diff/diff-selection.js +127 -0
  299. package/dist/models/diff/diff-selection.js.map +1 -0
  300. package/dist/models/diff/image-diff.d.ts +6 -0
  301. package/dist/models/diff/image-diff.js +8 -0
  302. package/dist/models/diff/image-diff.js.map +1 -0
  303. package/dist/models/diff/image.d.ts +7 -0
  304. package/dist/models/diff/image.js +13 -0
  305. package/dist/models/diff/image.js.map +1 -0
  306. package/dist/models/diff/index.d.ts +6 -0
  307. package/dist/models/diff/index.js +7 -0
  308. package/dist/models/diff/index.js.map +1 -0
  309. package/dist/models/diff/raw-diff.d.ts +32 -0
  310. package/dist/models/diff/raw-diff.js +38 -0
  311. package/dist/models/diff/raw-diff.js.map +1 -0
  312. package/dist/models/git-author.d.ts +7 -0
  313. package/dist/models/git-author.js +18 -0
  314. package/dist/models/git-author.js.map +1 -0
  315. package/dist/models/index.d.ts +21 -0
  316. package/dist/models/index.js +20 -0
  317. package/dist/models/index.js.map +1 -0
  318. package/dist/models/manual-conflict-resolution.d.ts +4 -0
  319. package/dist/models/manual-conflict-resolution.js +6 -0
  320. package/dist/models/manual-conflict-resolution.js.map +1 -0
  321. package/dist/models/merge.d.ts +6 -0
  322. package/dist/models/merge.js +2 -0
  323. package/dist/models/merge.js.map +1 -0
  324. package/dist/models/multi-commit-operation.d.ts +6 -0
  325. package/dist/models/multi-commit-operation.js +8 -0
  326. package/dist/models/multi-commit-operation.js.map +1 -0
  327. package/dist/models/progress.d.ts +41 -0
  328. package/dist/models/progress.js +7 -0
  329. package/dist/models/progress.js.map +1 -0
  330. package/dist/models/rebase.d.ts +17 -0
  331. package/dist/models/rebase.js +8 -0
  332. package/dist/models/rebase.js.map +1 -0
  333. package/dist/models/remote.d.ts +5 -0
  334. package/dist/models/remote.js +8 -0
  335. package/dist/models/remote.js.map +1 -0
  336. package/dist/models/repository.d.ts +7 -0
  337. package/dist/models/repository.js +15 -0
  338. package/dist/models/repository.js.map +1 -0
  339. package/dist/models/stash-entry.d.ts +20 -0
  340. package/dist/models/stash-entry.js +7 -0
  341. package/dist/models/stash-entry.js.map +1 -0
  342. package/dist/models/status.d.ts +166 -0
  343. package/dist/models/status.js +135 -0
  344. package/dist/models/status.js.map +1 -0
  345. package/dist/models/submodule.d.ts +12 -0
  346. package/dist/models/submodule.js +2 -0
  347. package/dist/models/submodule.js.map +1 -0
  348. package/dist/models/worktree.d.ts +10 -0
  349. package/dist/models/worktree.js +2 -0
  350. package/dist/models/worktree.js.map +1 -0
  351. package/package.json +17 -2
  352. package/src/git/add.ts +3 -3
  353. package/src/git/apply.ts +8 -8
  354. package/src/git/authentication.ts +3 -2
  355. package/src/git/branch.ts +10 -10
  356. package/src/git/checkout-index.ts +2 -2
  357. package/src/git/checkout.ts +12 -12
  358. package/src/git/cherry-pick.ts +16 -16
  359. package/src/git/clean.ts +2 -2
  360. package/src/git/clone.ts +6 -6
  361. package/src/git/commit.ts +7 -7
  362. package/src/git/config.ts +2 -2
  363. package/src/git/core.ts +8 -8
  364. package/src/git/credential.ts +1 -1
  365. package/src/git/diff-check.ts +1 -1
  366. package/src/git/diff-index.ts +2 -2
  367. package/src/git/diff.ts +18 -18
  368. package/src/git/environment.ts +5 -5
  369. package/src/git/fetch.ts +7 -7
  370. package/src/git/for-each-ref.ts +5 -5
  371. package/src/git/format-patch.ts +3 -3
  372. package/src/git/git-delimiter-parser.ts +1 -1
  373. package/src/git/gitignore.ts +2 -2
  374. package/src/git/index.ts +46 -36
  375. package/src/git/init.ts +2 -2
  376. package/src/git/interpret-trailers.ts +3 -3
  377. package/src/git/lfs.ts +2 -2
  378. package/src/git/log.ts +8 -8
  379. package/src/git/merge-tree.ts +5 -5
  380. package/src/git/merge.ts +5 -5
  381. package/src/git/multi-operation-terminal-output.ts +3 -3
  382. package/src/git/pull.ts +7 -7
  383. package/src/git/push-terminal-chunk.ts +1 -1
  384. package/src/git/push.ts +7 -7
  385. package/src/git/rebase.ts +16 -16
  386. package/src/git/reflog.ts +2 -2
  387. package/src/git/refs.ts +2 -2
  388. package/src/git/remote.ts +6 -6
  389. package/src/git/reorder.ts +7 -7
  390. package/src/git/reset.ts +3 -3
  391. package/src/git/rev-list.ts +5 -5
  392. package/src/git/rev-parse.ts +2 -2
  393. package/src/git/revert.ts +8 -8
  394. package/src/git/rm.ts +3 -3
  395. package/src/git/show.ts +4 -4
  396. package/src/git/spawn.ts +3 -3
  397. package/src/git/squash.ts +7 -7
  398. package/src/git/stage.ts +7 -7
  399. package/src/git/stash.ts +10 -10
  400. package/src/git/status.ts +13 -13
  401. package/src/git/submodule.ts +9 -9
  402. package/src/git/tag.ts +4 -4
  403. package/src/git/update-index.ts +5 -5
  404. package/src/git/update-ref.ts +2 -2
  405. package/src/git/var.ts +3 -3
  406. package/src/git/worktree-include.ts +3 -3
  407. package/src/git/worktree.ts +4 -4
  408. package/src/index.ts +11 -0
  409. package/src/lib/diff-parser.ts +2 -2
  410. package/src/lib/get-old-path.ts +1 -1
  411. package/src/lib/git/environment.ts +1 -1
  412. package/src/lib/patch-formatter.ts +3 -3
  413. package/src/lib/progress/from-process.ts +1 -1
  414. package/src/lib/progress/index.ts +1 -1
  415. package/src/lib/status-parser.ts +2 -2
  416. package/src/models/branch.ts +1 -1
  417. package/src/models/cherry-pick.ts +2 -2
  418. package/src/models/commit.ts +1 -1
  419. package/src/models/diff/diff-data.ts +3 -3
  420. package/src/models/diff/index.ts +6 -6
  421. package/src/models/diff/raw-diff.ts +1 -1
  422. package/src/models/index.ts +36 -0
  423. package/src/models/rebase.ts +2 -2
  424. package/src/models/stash-entry.ts +1 -1
  425. package/src/models/status.ts +1 -1
  426. package/examples/get-status.ts +0 -84
  427. package/tsconfig.json +0 -17
@@ -0,0 +1,150 @@
1
+ import { git, isGitError } from './core.js';
2
+ import { formatAsLocalRef } from './refs.js';
3
+ import { deleteRef } from './update-ref.js';
4
+ import { GitError as DugiteError } from './exec.js';
5
+ import { envForRemoteOperation } from './environment.js';
6
+ import { createForEachRefParser } from './git-delimiter-parser.js';
7
+ import { coerceToString } from './coerce-to-string.js';
8
+ /**
9
+ * Create a new branch from the given start point.
10
+ *
11
+ * @param repository - The repository in which to create the new branch
12
+ * @param name - The name of the new branch
13
+ * @param startPoint - A committish string that the new branch should be based
14
+ * on, or undefined if the branch should be created based
15
+ * off of the current state of HEAD
16
+ */
17
+ export async function createBranch(repository, name, startPoint, noTrack) {
18
+ const args = startPoint !== null ? ['branch', name, startPoint] : ['branch', name];
19
+ // if we're branching directly from a remote branch, we don't want to track it
20
+ // tracking it will make the rest of desktop think we want to push to that
21
+ // remote branch's upstream (which would likely be the upstream of the fork)
22
+ if (noTrack) {
23
+ args.push('--no-track');
24
+ }
25
+ await git(args, repository.path, 'createBranch');
26
+ }
27
+ export const getBranchNames = ({ path }) => {
28
+ const parser = createForEachRefParser({ name: '%(refname:short)' });
29
+ return git(['branch', ...parser.formatArgs], path, 'getBranchNames').then(x => parser.parse(x.stdout).map(b => b.name));
30
+ };
31
+ /** Rename the given branch to a new name. */
32
+ export async function renameBranch(repository, branch, newName, force) {
33
+ try {
34
+ await git(['branch', force ? '-M' : '-m', branch.nameWithoutRemote, newName], repository.path, 'renameBranch');
35
+ }
36
+ catch (error) {
37
+ // If we failed to rename and the branch name only differs by case, we
38
+ // we'll try again with the -M flag to force the rename. See
39
+ // https://github.com/desktop/desktop/issues/21320
40
+ if (
41
+ // Only retry if the caller hasn't explicitly asked us to force the rename
42
+ force === undefined &&
43
+ isGitError(error) &&
44
+ error.result.gitError === DugiteError.BranchAlreadyExists) {
45
+ const stderr = coerceToString(error.result.stderr);
46
+ const m = /fatal: a branch named '(.+?)' already exists/.exec(stderr);
47
+ if (m && m[1].toLowerCase() === newName.toLowerCase()) {
48
+ // At this point we're almost certain that we are dealing with a
49
+ // case-only rename on a case insensitive filesystem, but we can't
50
+ // be 100% sure, NTFS can be configured to be case sensitive and macOS
51
+ // might have case sensitive file systems mounted so we have to list
52
+ // all branches and check the names.
53
+ return (getBranchNames(repository)
54
+ // Throw the original error if we fail to get the branch names
55
+ .catch(() => Promise.reject(error))
56
+ .then(names =>
57
+ // If we find the new name in the list of branches we can't
58
+ // safely assume it's a case-only rename and have to
59
+ // propagate the original error, otherwise try again with -M
60
+ names.includes(newName)
61
+ ? Promise.reject(error)
62
+ : renameBranch(repository, branch, newName, true)));
63
+ }
64
+ }
65
+ throw error;
66
+ }
67
+ }
68
+ /**
69
+ * Delete the branch locally.
70
+ */
71
+ export async function deleteLocalBranch(repository, branchName) {
72
+ await git(['branch', '-D', branchName], repository.path, 'deleteLocalBranch');
73
+ return true;
74
+ }
75
+ /**
76
+ * Deletes a remote branch
77
+ *
78
+ * @param remoteName - the name of the remote to delete the branch from
79
+ * @param remoteBranchName - the name of the branch on the remote
80
+ */
81
+ export async function deleteRemoteBranch(repository, remote, remoteBranchName) {
82
+ const args = ['push', remote.name, `:${remoteBranchName}`];
83
+ // If the user is not authenticated, the push is going to fail
84
+ // Let this propagate and leave it to the caller to handle
85
+ const result = await git(args, repository.path, 'deleteRemoteBranch', {
86
+ env: await envForRemoteOperation(remote.url),
87
+ expectedErrors: new Set([DugiteError.BranchDeletionFailed]),
88
+ });
89
+ // It's possible that the delete failed because the ref has already
90
+ // been deleted on the remote. If we identify that specific
91
+ // error we can safely remove our remote ref which is what would
92
+ // happen if the push didn't fail.
93
+ if (result.gitError === DugiteError.BranchDeletionFailed) {
94
+ const ref = `refs/remotes/${remote.name}/${remoteBranchName}`;
95
+ await deleteRef(repository, ref);
96
+ }
97
+ return true;
98
+ }
99
+ /**
100
+ * Finds branches that have a tip equal to the given committish
101
+ *
102
+ * @param repository within which to execute the command
103
+ * @param commitish a sha, HEAD, etc that the branch(es) tip should be
104
+ * @returns list branch names. null if an error is encountered
105
+ */
106
+ export async function getBranchesPointedAt(repository, commitish) {
107
+ const args = [
108
+ 'branch',
109
+ `--points-at=${commitish}`,
110
+ '--format=%(refname:short)',
111
+ ];
112
+ // this command has an implicit \n delimiter
113
+ const { stdout, exitCode } = await git(args, repository.path, 'branchPointedAt', {
114
+ // - 1 is returned if a common ancestor cannot be resolved
115
+ // - 129 is returned if ref is malformed
116
+ // "warning: ignoring broken ref refs/remotes/origin/main."
117
+ successExitCodes: new Set([0, 1, 129]),
118
+ });
119
+ if (exitCode === 1 || exitCode === 129) {
120
+ return null;
121
+ }
122
+ // split (and remove trailing element cause its always an empty string)
123
+ return stdout.split('\n').slice(0, -1);
124
+ }
125
+ /**
126
+ * Gets all branches that have been merged into the given branch
127
+ *
128
+ * @param repository The repository in which to search
129
+ * @param branchName The to be used as the base branch
130
+ * @returns map of branch canonical refs paired to its sha
131
+ */
132
+ export async function getMergedBranches(repository, branchName) {
133
+ const canonicalBranchRef = formatAsLocalRef(branchName);
134
+ const { formatArgs, parse } = createForEachRefParser({
135
+ sha: '%(objectname)',
136
+ canonicalRef: '%(refname)',
137
+ });
138
+ const args = ['branch', ...formatArgs, '--merged', branchName];
139
+ const mergedBranches = new Map();
140
+ const { stdout } = await git(args, repository.path, 'mergedBranches');
141
+ for (const branch of parse(stdout)) {
142
+ // Don't include the branch we're using to compare against
143
+ // in the list of branches merged into that branch.
144
+ if (branch.canonicalRef !== canonicalBranchRef) {
145
+ mergedBranches.set(branch.canonicalRef, branch.sha);
146
+ }
147
+ }
148
+ return mergedBranches;
149
+ }
150
+ //# sourceMappingURL=branch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/git/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAG3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CA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working directory with information from the index
4
+ * for a given set of files.
5
+ *
6
+ * This method is essentially the same as running `git checkout -- files`
7
+ * except by using `checkout-index` we can pass the files we want updated
8
+ * on stdin, avoiding all issues with too long arguments.
9
+ *
10
+ * Note that this function will not yield errors for paths that don't
11
+ * exist in the index (-q).
12
+ *
13
+ * @param repository The repository in which to update the working directory
14
+ * with information from the index
15
+ *
16
+ * @param paths The relative paths in the working directory to update
17
+ * with information from the index.
18
+ */
19
+ export declare function checkoutIndex(repository: Repository, paths: ReadonlyArray<string>): Promise<void>;
@@ -0,0 +1,29 @@
1
+ import { git } from './core.js';
2
+ /**
3
+ * Forcefully updates the working directory with information from the index
4
+ * for a given set of files.
5
+ *
6
+ * This method is essentially the same as running `git checkout -- files`
7
+ * except by using `checkout-index` we can pass the files we want updated
8
+ * on stdin, avoiding all issues with too long arguments.
9
+ *
10
+ * Note that this function will not yield errors for paths that don't
11
+ * exist in the index (-q).
12
+ *
13
+ * @param repository The repository in which to update the working directory
14
+ * with information from the index
15
+ *
16
+ * @param paths The relative paths in the working directory to update
17
+ * with information from the index.
18
+ */
19
+ export async function checkoutIndex(repository, paths) {
20
+ if (!paths.length) {
21
+ return;
22
+ }
23
+ const options = {
24
+ successExitCodes: new Set([0, 1]),
25
+ stdin: paths.join('\0'),
26
+ };
27
+ await git(['checkout-index', '-f', '-u', '-q', '--stdin', '-z'], repository.path, 'checkoutIndex', options);
28
+ }
29
+ //# sourceMappingURL=checkout-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-index.js","sourceRoot":"","sources":["../../src/git/checkout-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAG/B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAsB,EACtB,KAA4B;IAE5B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,OAAM;IACR,CAAC;IAED,MAAM,OAAO,GAAG;QACd,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;KACxB,CAAA;IAED,MAAM,GAAG,CACP,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,EACrD,UAAU,CAAC,IAAI,EACf,eAAe,EACf,OAAO,CACR,CAAA;AACH,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Repository } from '../models/repository.js';
2
+ import { Branch } from '../models/branch.js';
3
+ import { ICheckoutProgress } from '../models/progress.js';
4
+ import { WorkingDirectoryFileChange } from '../models/status.js';
5
+ import { ManualConflictResolution } from '../models/manual-conflict-resolution.js';
6
+ import { CommitOneLine } from '../models/commit.js';
7
+ import { IRemote } from '../models/remote.js';
8
+ export type ProgressCallback = (progress: ICheckoutProgress) => void;
9
+ /**
10
+ * Check out the given branch.
11
+ *
12
+ * @param repository - The repository in which the branch checkout should
13
+ * take place
14
+ *
15
+ * @param branch - The branch name that should be checked out
16
+ *
17
+ * @param progressCallback - An optional function which will be invoked
18
+ * with information about the current progress
19
+ * of the checkout operation. When provided this
20
+ * enables the '--progress' command line flag for
21
+ * 'git checkout'.
22
+ */
23
+ export declare function checkoutBranch(repository: Repository, branch: Branch, currentRemote: IRemote | null, progressCallback?: ProgressCallback, allowFileProtocol?: boolean): Promise<true>;
24
+ /**
25
+ * Check out the given commit.
26
+ * Literally invokes `git checkout <commit SHA>`.
27
+ *
28
+ * @param repository - The repository in which the branch checkout should
29
+ * take place
30
+ *
31
+ * @param commit - The commit that should be checked out
32
+ *
33
+ * @param progressCallback - An optional function which will be invoked
34
+ * with information about the current progress
35
+ * of the checkout operation. When provided this
36
+ * enables the '--progress' command line flag for
37
+ * 'git checkout'.
38
+ */
39
+ export declare function checkoutCommit(repository: Repository, commit: CommitOneLine, currentRemote: IRemote | null, progressCallback?: ProgressCallback, allowFileProtocol?: boolean): Promise<true>;
40
+ /** Check out the paths at HEAD. */
41
+ export declare function checkoutPaths(repository: Repository, paths: ReadonlyArray<string>): Promise<void>;
42
+ /**
43
+ * Check out either stage #2 (ours) or #3 (theirs) for a conflicted
44
+ * file.
45
+ */
46
+ export declare function checkoutConflictedFile(repository: Repository, file: WorkingDirectoryFileChange, resolution: ManualConflictResolution): Promise<void>;
@@ -0,0 +1,126 @@
1
+ import { git } from './core.js';
2
+ import { BranchType } from '../models/branch.js';
3
+ import { clampProgress } from '../models/progress.js';
4
+ import { CheckoutProgressParser, executionOptionsWithProgress, } from '../lib/progress/index.js';
5
+ import { AuthenticationErrors } from './authentication.js';
6
+ import { envForRemoteOperation, getFallbackUrlForProxyResolve, } from './environment.js';
7
+ import { shortenSHA } from '../models/commit.js';
8
+ import { updateSubmodulesAfterOperation } from './submodule.js';
9
+ const CheckoutStepWeight = 0.9;
10
+ function getCheckoutArgs(progressCallback) {
11
+ return ['checkout', ...(progressCallback ? ['--progress'] : [])];
12
+ }
13
+ async function getBranchCheckoutArgs(branch) {
14
+ return [
15
+ branch.name,
16
+ ...(branch.type === BranchType.Remote
17
+ ? ['-b', branch.nameWithoutRemote]
18
+ : []),
19
+ '--',
20
+ ];
21
+ }
22
+ async function getCheckoutOpts(repository, title, target, currentRemote, progressCallback, initialDescription) {
23
+ const opts = {
24
+ env: await envForRemoteOperation(getFallbackUrlForProxyResolve(repository, currentRemote)),
25
+ expectedErrors: AuthenticationErrors,
26
+ };
27
+ if (!progressCallback) {
28
+ return opts;
29
+ }
30
+ const kind = 'checkout';
31
+ // Initial progress
32
+ progressCallback({
33
+ kind,
34
+ title,
35
+ description: initialDescription ?? title,
36
+ value: 0,
37
+ target,
38
+ });
39
+ return await executionOptionsWithProgress({ ...opts, trackLFSProgress: true }, new CheckoutProgressParser(), progress => {
40
+ if (progress.kind === 'progress') {
41
+ const description = progress.details.text;
42
+ const value = progress.percent;
43
+ progressCallback({
44
+ kind,
45
+ title,
46
+ description,
47
+ value,
48
+ target,
49
+ });
50
+ }
51
+ });
52
+ }
53
+ /**
54
+ * Check out the given branch.
55
+ *
56
+ * @param repository - The repository in which the branch checkout should
57
+ * take place
58
+ *
59
+ * @param branch - The branch name that should be checked out
60
+ *
61
+ * @param progressCallback - An optional function which will be invoked
62
+ * with information about the current progress
63
+ * of the checkout operation. When provided this
64
+ * enables the '--progress' command line flag for
65
+ * 'git checkout'.
66
+ */
67
+ export async function checkoutBranch(repository, branch, currentRemote, progressCallback, allowFileProtocol = false) {
68
+ const title = `Checking out branch ${branch.name}`;
69
+ const opts = await getCheckoutOpts(repository, title, branch.name, currentRemote, progressCallback
70
+ ? clampProgress(0, CheckoutStepWeight, progressCallback)
71
+ : undefined, `Switching to branch`);
72
+ const baseArgs = getCheckoutArgs(progressCallback);
73
+ const args = [...baseArgs, ...(await getBranchCheckoutArgs(branch))];
74
+ await git(args, repository.path, 'checkoutBranch', opts);
75
+ // Update submodules after checkout
76
+ await updateSubmodulesAfterOperation(repository, currentRemote, progressCallback
77
+ ? clampProgress(CheckoutStepWeight, 1, progressCallback)
78
+ : undefined, 'checkout', title, branch.name, allowFileProtocol);
79
+ // we return `true` here so `GitStore.performFailableGitOperation`
80
+ // will return _something_ differentiable from `undefined` if this succeeds
81
+ return true;
82
+ }
83
+ /**
84
+ * Check out the given commit.
85
+ * Literally invokes `git checkout <commit SHA>`.
86
+ *
87
+ * @param repository - The repository in which the branch checkout should
88
+ * take place
89
+ *
90
+ * @param commit - The commit that should be checked out
91
+ *
92
+ * @param progressCallback - An optional function which will be invoked
93
+ * with information about the current progress
94
+ * of the checkout operation. When provided this
95
+ * enables the '--progress' command line flag for
96
+ * 'git checkout'.
97
+ */
98
+ export async function checkoutCommit(repository, commit, currentRemote, progressCallback, allowFileProtocol = false) {
99
+ const title = `Checking out commit`;
100
+ const target = shortenSHA(commit.sha);
101
+ const opts = await getCheckoutOpts(repository, title, target, currentRemote, progressCallback
102
+ ? clampProgress(0, CheckoutStepWeight, progressCallback)
103
+ : undefined);
104
+ const baseArgs = getCheckoutArgs(progressCallback);
105
+ const args = [...baseArgs, commit.sha];
106
+ await git(args, repository.path, 'checkoutCommit', opts);
107
+ // Update submodules after checkout
108
+ await updateSubmodulesAfterOperation(repository, currentRemote, progressCallback
109
+ ? clampProgress(CheckoutStepWeight, 1, progressCallback)
110
+ : undefined, 'checkout', title, target, allowFileProtocol);
111
+ // we return `true` here so `GitStore.performFailableGitOperation`
112
+ // will return _something_ differentiable from `undefined` if this succeeds
113
+ return true;
114
+ }
115
+ /** Check out the paths at HEAD. */
116
+ export async function checkoutPaths(repository, paths) {
117
+ await git(['checkout', 'HEAD', '--', ...paths], repository.path, 'checkoutPaths');
118
+ }
119
+ /**
120
+ * Check out either stage #2 (ours) or #3 (theirs) for a conflicted
121
+ * file.
122
+ */
123
+ export async function checkoutConflictedFile(repository, file, resolution) {
124
+ await git(['checkout', `--${resolution}`, '--', file.path], repository.path, 'checkoutConflictedFile');
125
+ }
126
+ //# sourceMappingURL=checkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/git/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAA8B,MAAM,WAAW,CAAA;AAE3D,OAAO,EAAU,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAqB,MAAM,uBAAuB,CAAA;AACxE,OAAO,EACL,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EACL,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAiB,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAA;AAI/D,MAAM,kBAAkB,GAAG,GAAG,CAAA;AAE9B,SAAS,e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C,IAAI,CAAC,EAChD,UAAU,CAAC,IAAI,EACf,wBAAwB,CACzB,CAAA;AACH,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { Repository } from '../models/repository.js';
2
+ import { WorkingDirectoryFileChange } from '../models/status.js';
3
+ import { CommitOneLine } from '../models/commit.js';
4
+ import { ICherryPickSnapshot } from '../models/cherry-pick.js';
5
+ import { ManualConflictResolution } from '../models/manual-conflict-resolution.js';
6
+ import { IMultiCommitOperationProgress } from '../models/progress.js';
7
+ /** The app-specific results from attempting to cherry pick commits*/
8
+ export declare enum CherryPickResult {
9
+ /**
10
+ * Git completed the cherry pick without reporting any errors, and the caller can
11
+ * signal success to the user.
12
+ */
13
+ CompletedWithoutError = "CompletedWithoutError",
14
+ /**
15
+ * The cherry pick encountered conflicts while attempting to cherry pick and
16
+ * need to be resolved before the user can continue.
17
+ */
18
+ ConflictsEncountered = "ConflictsEncountered",
19
+ /**
20
+ * The cherry pick was not able to continue as tracked files were not staged in
21
+ * the index.
22
+ */
23
+ OutstandingFilesNotStaged = "OutstandingFilesNotStaged",
24
+ /**
25
+ * The cherry pick was not attempted:
26
+ * - it could not check the status of the repository.
27
+ * - there was an invalid revision range provided.
28
+ * - there were uncommitted changes present.
29
+ * - there were errors in checkout the target branch
30
+ */
31
+ UnableToStart = "UnableToStart",
32
+ /**
33
+ * An unexpected error as part of the cherry pick flow was caught and handled.
34
+ *
35
+ * Check the logs to find the relevant Git details.
36
+ */
37
+ Error = "Error"
38
+ }
39
+ /**
40
+ * A function to initiate cherry picking in the app.
41
+ *
42
+ * @param commits - array of commits to cherry-pick
43
+ * For a cherry-pick operation, it does not matter what order the commits
44
+ * appear. But, it is best practice to send them in ascending order to prevent
45
+ * conflicts. First one on the array is first to be cherry-picked.
46
+ */
47
+ export declare function cherryPick(repository: Repository, commits: ReadonlyArray<CommitOneLine>, progressCallback?: (progress: IMultiCommitOperationProgress) => void): Promise<CherryPickResult>;
48
+ /**
49
+ * Inspect the `.git/sequencer` folder and convert the current cherry pick
50
+ * state into am `ICherryPickProgress` instance as well as return an array of
51
+ * remaining commits queued for cherry picking.
52
+ * - Progress instance required to display progress to user.
53
+ * - Commits required to track progress after a conflict has been resolved.
54
+ *
55
+ * This is required when Desktop is not responsible for initiating the cherry
56
+ * pick and when continuing a cherry pick after conflicts are resolved:
57
+ *
58
+ * It returns null if it cannot parse an ongoing cherry pick. This happens when,
59
+ * - There isn't a cherry pick in progress (expected null outcome).
60
+ * - Runs into errors parsing cherry pick files. This is expected if cherry
61
+ * pick is aborted or finished during parsing. It could also occur if cherry
62
+ * pick sequencer files are corrupted.
63
+ */
64
+ export declare function getCherryPickSnapshot(repository: Repository): Promise<ICherryPickSnapshot | null>;
65
+ /**
66
+ * Proceed with the current cherry pick operation and report back on whether it completed
67
+ *
68
+ * It is expected that the index has staged files which are cleanly cherry
69
+ * picked onto the base branch, and the remaining unstaged files are those which
70
+ * need manual resolution or were changed by the user to address inline
71
+ * conflicts.
72
+ *
73
+ * @param files - The working directory of files. These are the files that are
74
+ * detected to have changes that we want to stage for the cherry pick.
75
+ */
76
+ export declare function continueCherryPick(repository: Repository, files: ReadonlyArray<WorkingDirectoryFileChange>, manualResolutions?: ReadonlyMap<string, ManualConflictResolution>, progressCallback?: (progress: IMultiCommitOperationProgress) => void): Promise<CherryPickResult>;
77
+ /** Abandon the current cherry pick operation */
78
+ export declare function abortCherryPick(repository: Repository): Promise<void>;
79
+ /**
80
+ * Check if the `.git/CHERRY_PICK_HEAD` file exists
81
+ */
82
+ export declare function isCherryPickHeadFound(repository: Repository): Promise<boolean>;