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,65 @@
1
+ import { git } from './core.js';
2
+ import { directoryExists } from '../lib/directory-exists.js';
3
+ import { resolve } from 'path';
4
+ /**
5
+ * Attempts to fulfill the work of isGitRepository and isBareRepository while
6
+ * requiring only one Git process to be spawned.
7
+ *
8
+ * Returns 'bare', 'regular', or 'missing' if the repository couldn't be
9
+ * found.
10
+ */
11
+ export async function getRepositoryType(path) {
12
+ if (!(await directoryExists(path))) {
13
+ return { kind: 'missing' };
14
+ }
15
+ try {
16
+ const result = await git(['rev-parse', '--is-bare-repository', '--show-cdup', '--git-dir'], path, 'getRepositoryType', { successExitCodes: new Set([0, 128]) });
17
+ if (result.exitCode === 0) {
18
+ // Bare repositories will not include gitdir so we handle that separately
19
+ if (result.stdout.startsWith('true\n')) {
20
+ return { kind: 'bare' };
21
+ }
22
+ // --is-bare-repository and --show-cdup each produce a single line but
23
+ // --git-dir could theoretically contain newlines so we parse the known
24
+ // fields first and treat the remainder as the git dir. We use [\s\S]*
25
+ // instead of .* for the git dir capture group because .* doesn't match
26
+ // newlines whereas [\s\S]* matches any character including newlines.
27
+ const match = result.stdout.match(/^(true|false)\n(.*)\n([\s\S]*)\n$/);
28
+ if (match) {
29
+ const [, isBare, cdup, gitDir] = match;
30
+ return isBare === 'true'
31
+ ? { kind: 'bare' }
32
+ : {
33
+ kind: 'regular',
34
+ topLevelWorkingDirectory: resolve(path, cdup),
35
+ gitDir: resolve(path, gitDir),
36
+ };
37
+ }
38
+ }
39
+ const unsafeMatch = /fatal: detected dubious ownership in repository at '(.+)'/.exec(result.stderr);
40
+ if (unsafeMatch) {
41
+ return { kind: 'unsafe', path: unsafeMatch[1] };
42
+ }
43
+ return { kind: 'missing' };
44
+ }
45
+ catch (err) {
46
+ if (err?.code === 'ENOENT') {
47
+ return { kind: 'missing' };
48
+ }
49
+ throw err;
50
+ }
51
+ }
52
+ export async function getUpstreamRefForRef(path, ref) {
53
+ const rev = (ref ?? '') + '@{upstream}';
54
+ const args = ['rev-parse', '--symbolic-full-name', rev];
55
+ const opts = { successExitCodes: new Set([0, 128]) };
56
+ const result = await git(args, path, 'getUpstreamRefForRef', opts);
57
+ return result.exitCode === 0 ? result.stdout.trim() : null;
58
+ }
59
+ export async function getUpstreamRemoteNameForRef(path, ref) {
60
+ const remoteRef = await getUpstreamRefForRef(path, ref);
61
+ return remoteRef?.match(/^refs\/remotes\/([^/]+)\//)?.[1] ?? null;
62
+ }
63
+ export const getCurrentUpstreamRef = (path) => getUpstreamRefForRef(path);
64
+ export const getCurrentUpstreamRemoteName = (path) => getUpstreamRemoteNameForRef(path);
65
+ //# sourceMappingURL=rev-parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rev-parse.js","sourceRoot":"","sources":["../../src/git/rev-parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAQ9B;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY;IAClD,IAAI,CAAC,CAAC,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IAC5B,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,GAAG,CACtB,CAAC,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,CAAC,EACjE,IAAI,EACJ,mBAAmB,EACnB,EAAE,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CACxC,CAAA;QAED,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YAC1B,yEAAyE;YACzE,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACvC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;YACzB,CAAC;YAED,sEAAsE;YACtE,uEAAuE;YACvE,sEAAsE;YACtE,uEAAuE;YACvE,qEAAqE;YACrE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAA;YAEtE,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B,EAAE,IAAI,CAAC,CAAA;IAElE,OAAO,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,IAAY,EAAE,GAAY;IAC1E,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACvD,OAAO,SAAS,EAAE,KAAK,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;AACnE,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,EAAE,CACpD,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3D,2BAA2B,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { Repository } from '../models/repository.js';
2
+ import { Commit } from '../models/commit.js';
3
+ import { IRevertProgress } from '../models/progress.js';
4
+ import { IRemote } from '../models/remote.js';
5
+ /**
6
+ * Creates a new commit that reverts the changes of a previous commit
7
+ *
8
+ * @param repository - The repository to update
9
+ *
10
+ * @param commit - The SHA of the commit to be reverted
11
+ */
12
+ export declare function revertCommit(repository: Repository, commit: Commit, currentRemote: IRemote | null, progressCallback?: (progress: IRevertProgress) => void): Promise<void>;
@@ -0,0 +1,30 @@
1
+ import { git } from './core.js';
2
+ import { executionOptionsWithProgress } from '../lib/progress/from-process.js';
3
+ import { RevertProgressParser } from '../lib/progress/revert.js';
4
+ import { envForRemoteOperation, getFallbackUrlForProxyResolve, } from './environment.js';
5
+ /**
6
+ * Creates a new commit that reverts the changes of a previous commit
7
+ *
8
+ * @param repository - The repository to update
9
+ *
10
+ * @param commit - The SHA of the commit to be reverted
11
+ */
12
+ export async function revertCommit(repository, commit, currentRemote, progressCallback) {
13
+ const args = ['revert'];
14
+ if (commit.parentSHAs.length > 1) {
15
+ args.push('-m', '1');
16
+ }
17
+ args.push(commit.sha);
18
+ let opts = {};
19
+ if (progressCallback) {
20
+ const env = await envForRemoteOperation(getFallbackUrlForProxyResolve(repository, currentRemote));
21
+ opts = await executionOptionsWithProgress({ env, trackLFSProgress: true }, new RevertProgressParser(), progress => {
22
+ const description = progress.kind === 'progress' ? progress.details.text : progress.text;
23
+ const title = progress.kind === 'progress' ? progress.details.title : '';
24
+ const value = progress.percent;
25
+ progressCallback({ kind: 'revert', description, value, title });
26
+ });
27
+ }
28
+ await git(args, repository.path, 'revert', opts);
29
+ }
30
+ //# sourceMappingURL=revert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revert.js","sourceRoot":"","sources":["../../src/git/revert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAA8B,MAAM,WAAW,CAAA;AAM3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAA;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EACL,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,kBAAkB,CAAA;AAGzB;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,UAAsB,EACtB,MAAc,EACd,aAA6B,EAC7B,gBAAsD;IAEtD,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAA;IACvB,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACtB,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAErB,IAAI,IAAI,GAA+B,EAAE,CAAA;IACzC,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,MAAM,qBAAqB,CACrC,6BAA6B,CAAC,UAAU,EAAE,aAAa,CAAC,CACzD,CAAA;QACD,IAAI,GAAG,MAAM,4BAA4B,CACvC,EAAE,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAC/B,IAAI,oBAAoB,EAAE,EAC1B,QAAQ,CAAC,EAAE;YACT,MAAM,WAAW,GACf,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAA;YACtE,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;YACxE,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAA;YAE9B,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QACjE,CAAC,CACF,CAAA;IACH,CAAC;IAED,MAAM,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;AAClD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Repository } from '../models/repository.js';
2
+ import { WorkingDirectoryFileChange } from '../models/status.js';
3
+ /**
4
+ * Remove all files from the index
5
+ *
6
+ * @param repository the repository to update
7
+ */
8
+ export declare function unstageAllFiles(repository: Repository): Promise<void>;
9
+ /**
10
+ * Remove conflicted file from working tree and index
11
+ */
12
+ export declare function removeConflictedFile(repository: Repository, file: WorkingDirectoryFileChange): Promise<void>;
package/dist/git/rm.js ADDED
@@ -0,0 +1,22 @@
1
+ import { git } from './core.js';
2
+ /**
3
+ * Remove all files from the index
4
+ *
5
+ * @param repository the repository to update
6
+ */
7
+ export async function unstageAllFiles(repository) {
8
+ await git(
9
+ // these flags are important:
10
+ // --cached to only remove files from the index
11
+ // -r to recursively remove files, in case files are in folders
12
+ // -f to ignore differences between working directory and index
13
+ // which will block this
14
+ ['rm', '--cached', '-r', '-f', '.'], repository.path, 'unstageAllFiles');
15
+ }
16
+ /**
17
+ * Remove conflicted file from working tree and index
18
+ */
19
+ export async function removeConflictedFile(repository, file) {
20
+ await git(['rm', '--', file.path], repository.path, 'removeConflictedFile');
21
+ }
22
+ //# sourceMappingURL=rm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rm.js","sourceRoot":"","sources":["../../src/git/rm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAI/B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,UAAsB;IAC1D,MAAM,GAAG;IACP,6BAA6B;IAC7B,+CAA+C;IAC/C,qEAAqE;IACrE,qEAAqE;IACrE,iCAAiC;IACjC,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,EACnC,UAAU,CAAC,IAAI,EACf,iBAAiB,CAClB,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,UAAsB,EACtB,IAAgC;IAEhC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAA;AAC7E,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { Repository } from '../models/repository.js';
2
+ /**
3
+ * Retrieve the binary contents of a blob from the repository at a given
4
+ * reference, commit, or tree.
5
+ *
6
+ * Returns a promise that will produce a Buffer instance containing
7
+ * the binary contents of the blob or an error if the file doesn't
8
+ * exists in the given revision.
9
+ *
10
+ * @param repository - The repository from where to read the blob
11
+ *
12
+ * @param commitish - A commit SHA or some other identifier that
13
+ * ultimately dereferences to a commit/tree.
14
+ *
15
+ * @param path - The file path, relative to the repository
16
+ * root from where to read the blob contents
17
+ */
18
+ export declare const getBlobContents: (repository: Repository, commitish: string, path: string) => Promise<Buffer<ArrayBufferLike>>;
19
+ /**
20
+ * Retrieve some or all binary contents of a blob from the repository
21
+ * at a given reference, commit, or tree. This is almost identical
22
+ * to the getBlobContents method except that it supports only reading
23
+ * a maximum number of bytes.
24
+ *
25
+ * Returns a promise that will produce a Buffer instance containing
26
+ * the binary contents of the blob or an error if the file doesn't
27
+ * exists in the given revision.
28
+ *
29
+ * @param repository - The repository from where to read the blob
30
+ *
31
+ * @param commitish - A commit SHA or some other identifier that
32
+ * ultimately dereferences to a commit/tree.
33
+ *
34
+ * @param path - The file path, relative to the repository
35
+ * root from where to read the blob contents
36
+ *
37
+ * @param length - The maximum number of bytes to read from
38
+ * the blob. Note that the number of bytes
39
+ * returned may always be less than this number.
40
+ */
41
+ export declare function getPartialBlobContents(repository: Repository, commitish: string, path: string, length: number): Promise<Buffer | null>;
42
+ export declare function getPartialBlobContentsCatchPathNotInRef(repository: Repository, commitish: string, path: string, length: number): Promise<Buffer | null>;
@@ -0,0 +1,59 @@
1
+ import { git, isMaxBufferExceededError } from './core.js';
2
+ import { GitError } from './exec.js';
3
+ import { coerceToBuffer } from './coerce-to-buffer.js';
4
+ /**
5
+ * Retrieve the binary contents of a blob from the repository at a given
6
+ * reference, commit, or tree.
7
+ *
8
+ * Returns a promise that will produce a Buffer instance containing
9
+ * the binary contents of the blob or an error if the file doesn't
10
+ * exists in the given revision.
11
+ *
12
+ * @param repository - The repository from where to read the blob
13
+ *
14
+ * @param commitish - A commit SHA or some other identifier that
15
+ * ultimately dereferences to a commit/tree.
16
+ *
17
+ * @param path - The file path, relative to the repository
18
+ * root from where to read the blob contents
19
+ */
20
+ export const getBlobContents = (repository, commitish, path) => git(['show', `${commitish}:${path}`], repository.path, 'getBlobContents', {
21
+ successExitCodes: new Set([0, 1]),
22
+ encoding: 'buffer',
23
+ }).then(r => r.stdout);
24
+ /**
25
+ * Retrieve some or all binary contents of a blob from the repository
26
+ * at a given reference, commit, or tree. This is almost identical
27
+ * to the getBlobContents method except that it supports only reading
28
+ * a maximum number of bytes.
29
+ *
30
+ * Returns a promise that will produce a Buffer instance containing
31
+ * the binary contents of the blob or an error if the file doesn't
32
+ * exists in the given revision.
33
+ *
34
+ * @param repository - The repository from where to read the blob
35
+ *
36
+ * @param commitish - A commit SHA or some other identifier that
37
+ * ultimately dereferences to a commit/tree.
38
+ *
39
+ * @param path - The file path, relative to the repository
40
+ * root from where to read the blob contents
41
+ *
42
+ * @param length - The maximum number of bytes to read from
43
+ * the blob. Note that the number of bytes
44
+ * returned may always be less than this number.
45
+ */
46
+ export async function getPartialBlobContents(repository, commitish, path, length) {
47
+ return getPartialBlobContentsCatchPathNotInRef(repository, commitish, path, length);
48
+ }
49
+ export async function getPartialBlobContentsCatchPathNotInRef(repository, commitish, path, length) {
50
+ const args = ['show', `${commitish}:${path}`];
51
+ return git(args, repository.path, 'getPartialBlobContentsCatchPathNotInRef', {
52
+ maxBuffer: length,
53
+ expectedErrors: new Set([GitError.PathExistsButNotInRef]),
54
+ encoding: 'buffer',
55
+ })
56
+ .then(r => r.gitError === GitError.PathExistsButNotInRef ? null : r.stdout)
57
+ .catch(e => isMaxBufferExceededError(e) ? coerceToBuffer(e.stdout) : Promise.reject(e));
58
+ }
59
+ //# sourceMappingURL=show.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.js","sourceRoot":"","sources":["../../src/git/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAGzD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,UAAsB,EACtB,SAAiB,EACjB,IAAY,EACZ,EAAE,CACF,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,SAAS,IAAI,IA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itSpawnOptions } from './exec.js';
2
+ type SpawnOptions = IGitSpawnOptions & {
3
+ /**
4
+ * Whether the command about to run is part of a background task or not.
5
+ * This affects error handling and UI such as credential prompts.
6
+ */
7
+ readonly isBackgroundTask?: boolean;
8
+ };
9
+ /**
10
+ * Spawn a Git process, deferring all processing work to the caller.
11
+ *
12
+ * @param args Array of strings to pass to the Git executable.
13
+ * @param path The path to execute the command from.
14
+ * @param name The name of the operation - for tracing purposes.
15
+ * @param successExitCodes An optional array of exit codes that indicate success.
16
+ */
17
+ export declare const spawnGit: (args: string[], path: string, name: string, options?: SpawnOptions) => Promise<import("child_process").ChildProcess>;
18
+ export {};
@@ -0,0 +1,16 @@
1
+ import { spawnGit as spawn } from './exec.js';
2
+ import * as GitPerf from '../lib/git-perf.js';
3
+ import { withTrampolineEnv } from '../lib/trampoline/trampoline-environment.js';
4
+ /**
5
+ * Spawn a Git process, deferring all processing work to the caller.
6
+ *
7
+ * @param args Array of strings to pass to the Git executable.
8
+ * @param path The path to execute the command from.
9
+ * @param name The name of the operation - for tracing purposes.
10
+ * @param successExitCodes An optional array of exit codes that indicate success.
11
+ */
12
+ export const spawnGit = (args, path, name, options) => withTrampolineEnv(trampolineEnv => GitPerf.measure(`${name}: git ${args.join(' ')}`, async () => spawn(args, path, {
13
+ ...options,
14
+ env: { ...options?.env, ...trampolineEnv },
15
+ })), path, options?.isBackgroundTask ?? false, options?.env);
16
+ //# sourceMappingURL=spawn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../src/git/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,KAAK,EAAoB,MAAM,WAAW,CAAA;AAC/D,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAA;AAU/E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAc,EACd,IAAY,EACZ,IAAY,EACZ,OAAsB,EACtB,EAAE,CACF,iBAAiB,CACf,aAAa,CAAC,EAAE,CACd,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE,CAC3D,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE;IAChB,GAAG,OAAO;IACV,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,GAAG,aAAa,EAAE;CAC3C,CAAC,CACH,EACH,IAAI,EACJ,OAAO,EAAE,gBAAgB,IAAI,KAAK,EAClC,OAAO,EAAE,GAAG,CACb,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { Commit } from '../models/commit.js';
2
+ import { IMultiCommitOperationProgress } from '../models/progress.js';
3
+ import { Repository } from '../models/repository.js';
4
+ import { RebaseResult } from './rebase.js';
5
+ /**
6
+ * Squashes provided commits by calling interactive rebase.
7
+ *
8
+ * Goal is to replay the commits in order from oldest to newest to reduce
9
+ * conflicts with toSquash commits placed in the log at the location of the
10
+ * squashOnto commit.
11
+ *
12
+ * Example: A user's history from oldest to newest is A, B, C, D, E and they
13
+ * want to squash A and E (toSquash) onto C. Our goal: B, A-C-E, D. Thus,
14
+ * maintaining that A came before C and E came after C, placed in history at the
15
+ * the squashOnto of C.
16
+ *
17
+ * Also means if the last 2 commits in history are A, B, whether user squashes A
18
+ * onto B or B onto A. It will always perform based on log history, thus, B onto
19
+ * A.
20
+ *
21
+ * @param toSquash - commits to squash onto another commit and does not contain the squashOnto commit
22
+ * @param squashOnto - commit to squash the `toSquash` commits onto
23
+ * @param lastRetainedCommitRef - sha of commit before commits in squash or null
24
+ * if commit to be squash is the root (first in history) of the branch
25
+ * @param commitMessage - the first line of the string provided will be the
26
+ * summary and rest the body (similar to commit implementation)
27
+ */
28
+ export declare function squash(repository: Repository, toSquash: ReadonlyArray<Commit>, squashOnto: Commit, lastRetainedCommitRef: string | null, commitMessage: string, progressCallback?: (progress: IMultiCommitOperationProgress) => void): Promise<RebaseResult>;
@@ -0,0 +1,127 @@
1
+ import { appendFile, rm, writeFile } from 'fs/promises';
2
+ import { getCommits, revRange } from './index.js';
3
+ import { MultiCommitOperationKind } from '../models/multi-commit-operation.js';
4
+ import { getTempFilePath } from '../lib/file-system.js';
5
+ import { rebaseInteractive, RebaseResult } from './rebase.js';
6
+ /**
7
+ * Squashes provided commits by calling interactive rebase.
8
+ *
9
+ * Goal is to replay the commits in order from oldest to newest to reduce
10
+ * conflicts with toSquash commits placed in the log at the location of the
11
+ * squashOnto commit.
12
+ *
13
+ * Example: A user's history from oldest to newest is A, B, C, D, E and they
14
+ * want to squash A and E (toSquash) onto C. Our goal: B, A-C-E, D. Thus,
15
+ * maintaining that A came before C and E came after C, placed in history at the
16
+ * the squashOnto of C.
17
+ *
18
+ * Also means if the last 2 commits in history are A, B, whether user squashes A
19
+ * onto B or B onto A. It will always perform based on log history, thus, B onto
20
+ * A.
21
+ *
22
+ * @param toSquash - commits to squash onto another commit and does not contain the squashOnto commit
23
+ * @param squashOnto - commit to squash the `toSquash` commits onto
24
+ * @param lastRetainedCommitRef - sha of commit before commits in squash or null
25
+ * if commit to be squash is the root (first in history) of the branch
26
+ * @param commitMessage - the first line of the string provided will be the
27
+ * summary and rest the body (similar to commit implementation)
28
+ */
29
+ export async function squash(repository, toSquash, squashOnto, lastRetainedCommitRef, commitMessage, progressCallback) {
30
+ let messagePath, todoPath;
31
+ let result;
32
+ try {
33
+ if (toSquash.length === 0) {
34
+ throw new Error('[squash] No commits provided to squash.');
35
+ }
36
+ const toSquashShas = new Set(toSquash.map(c => c.sha));
37
+ if (toSquashShas.has(squashOnto.sha)) {
38
+ throw new Error('[squash] The commits to squash cannot contain the commit to squash onto.');
39
+ }
40
+ const commits = await getCommits(repository, lastRetainedCommitRef === null
41
+ ? undefined
42
+ : revRange(lastRetainedCommitRef, 'HEAD'));
43
+ if (commits.length === 0) {
44
+ throw new Error('[squash] Could not find commits in log for last retained commit ref.');
45
+ }
46
+ todoPath = await getTempFilePath('squashTodo');
47
+ let foundSquashOntoCommitInLog = false;
48
+ const toReplayAtSquash = [];
49
+ const toReplayAfterSquash = [];
50
+ // Traversed in reverse so we do oldest to newest (replay commits)
51
+ for (let i = commits.length - 1; i >= 0; i--) {
52
+ const commit = commits[i];
53
+ if (toSquashShas.has(commit.sha)) {
54
+ // If it is toSquash commit and we have found the squashOnto commit, we
55
+ // can go ahead and squash them (as we will hold any picks till after)
56
+ if (foundSquashOntoCommitInLog) {
57
+ await appendFile(todoPath, `squash ${commit.sha} ${commit.summary}\n`);
58
+ }
59
+ else {
60
+ // However, if we have not found the squashOnto commit yet we want to
61
+ // keep track of them in the order of the log. Thus, we use a new
62
+ // `toReplayAtSquash` array and not trust that what was sent is in the
63
+ // order of the log.
64
+ toReplayAtSquash.push(commit);
65
+ }
66
+ continue;
67
+ }
68
+ // If it's the squashOnto commit, replay to the toSquash in the order they
69
+ // appeared on the log to reduce potential conflicts.
70
+ if (commit.sha === squashOnto.sha) {
71
+ foundSquashOntoCommitInLog = true;
72
+ toReplayAtSquash.push(commit);
73
+ for (let j = 0; j < toReplayAtSquash.length; j++) {
74
+ const action = j === 0 ? 'pick' : 'squash';
75
+ await appendFile(todoPath, `${action} ${toReplayAtSquash[j].sha} ${toReplayAtSquash[j].summary}\n`);
76
+ }
77
+ continue;
78
+ }
79
+ // We can't just replay a pick in case there is a commit from the toSquash
80
+ // commits further up in history that need to be replayed with the
81
+ // squashes. Thus, we will keep track of these and replay after traversing
82
+ // the remainder of the log.
83
+ if (foundSquashOntoCommitInLog) {
84
+ toReplayAfterSquash.push(commit);
85
+ continue;
86
+ }
87
+ // If it is not one toSquash nor the squashOnto and have not found the
88
+ // squashOnto commit, we simply record it is an unchanged pick (before the
89
+ // squash)
90
+ await appendFile(todoPath, `pick ${commit.sha} ${commit.summary}\n`);
91
+ }
92
+ if (toReplayAfterSquash.length > 0) {
93
+ for (let i = 0; i < toReplayAfterSquash.length; i++) {
94
+ await appendFile(todoPath, `pick ${toReplayAfterSquash[i].sha} ${toReplayAfterSquash[i].summary}\n`);
95
+ }
96
+ }
97
+ if (!foundSquashOntoCommitInLog) {
98
+ throw new Error('[squash] The commit to squash onto was not in the log. Continuing would result in dropping the commits in the toSquash array.');
99
+ }
100
+ if (commitMessage.trim() !== '') {
101
+ messagePath = await getTempFilePath('squashCommitMessage');
102
+ await writeFile(messagePath, commitMessage);
103
+ }
104
+ // if no commit message provided, accept default editor
105
+ const gitEditor = messagePath !== undefined ? `cat "${messagePath}" >` : undefined;
106
+ result = await rebaseInteractive(repository, todoPath, lastRetainedCommitRef, {
107
+ action: MultiCommitOperationKind.Squash,
108
+ gitEditor,
109
+ progressCallback,
110
+ commits: [...toSquash, squashOnto],
111
+ });
112
+ }
113
+ catch (e) {
114
+ console.error(e);
115
+ return RebaseResult.Error;
116
+ }
117
+ finally {
118
+ if (todoPath !== undefined) {
119
+ await rm(todoPath, { recursive: true, force: true });
120
+ }
121
+ if (messagePath !== undefined) {
122
+ await rm(messagePath, { recursive: true, force: true });
123
+ }
124
+ }
125
+ return result;
126
+ }
127
+ //# sourceMappingURL=squash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"squash.js","sourceRoot":"","sources":["../../src/git/squash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAG9E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,UAAsB,EACtB,QAA+B,EAC/B,UAAkB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AAC,CAAA;QACtD,CAAC;QAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Repository } from '../models/repository.js';
2
+ import { WorkingDirectoryFileChange } from '../models/status.js';
3
+ import { ManualConflictResolution } from '../models/manual-conflict-resolution.js';
4
+ /**
5
+ * Stages a file with the given manual resolution method. Useful for resolving binary conflicts at commit-time.
6
+ *
7
+ * @param repository
8
+ * @param file conflicted file to stage
9
+ * @param manualResolution method to resolve the conflict of file
10
+ * @returns true if successful, false if something went wrong
11
+ */
12
+ export declare function stageManualConflictResolution(repository: Repository, file: WorkingDirectoryFileChange, manualResolution: ManualConflictResolution): Promise<void>;
13
+ /**
14
+ * Stages all resolved conflict files before a checkout operation to prevent
15
+ * "error: you need to resolve your current index first" from git.
16
+ *
17
+ * Handles two kinds of resolved conflicts:
18
+ * - Text conflicts resolved in an external editor (conflictMarkerCount === 0)
19
+ * - Manual conflicts where the user chose ours/theirs in the Desktop UI
20
+ */
21
+ export declare function stageResolvedConflictFiles(repository: Repository, files: ReadonlyArray<WorkingDirectoryFileChange>, manualResolutions: ReadonlyMap<string, ManualConflictResolution>): Promise<void>;
@@ -0,0 +1,72 @@
1
+ import { isConflictedFileStatus, GitStatusEntry, isConflictWithMarkers, } from '../models/status.js';
2
+ import { ManualConflictResolution } from '../models/manual-conflict-resolution.js';
3
+ import { assertNever } from '../lib/fatal-error.js';
4
+ import { removeConflictedFile } from './rm.js';
5
+ import { checkoutConflictedFile } from './checkout.js';
6
+ import { addConflictedFile } from './add.js';
7
+ /**
8
+ * Stages a file with the given manual resolution method. Useful for resolving binary conflicts at commit-time.
9
+ *
10
+ * @param repository
11
+ * @param file conflicted file to stage
12
+ * @param manualResolution method to resolve the conflict of file
13
+ * @returns true if successful, false if something went wrong
14
+ */
15
+ export async function stageManualConflictResolution(repository, file, manualResolution) {
16
+ const { status } = file;
17
+ // if somehow the file isn't in a conflicted state
18
+ if (!isConflictedFileStatus(status)) {
19
+ console.error(`tried to manually resolve unconflicted file (${file.path})`);
20
+ return;
21
+ }
22
+ if (isConflictWithMarkers(status) && status.conflictMarkerCount === 0) {
23
+ // If somehow the user used the Desktop UI to solve the conflict via ours/theirs
24
+ // but afterwards resolved manually the conflicts via an editor, used the manually
25
+ // resolved file.
26
+ return;
27
+ }
28
+ const chosen = manualResolution === ManualConflictResolution.theirs
29
+ ? status.entry.them
30
+ : status.entry.us;
31
+ const addedInBoth = status.entry.us === GitStatusEntry.Added &&
32
+ status.entry.them === GitStatusEntry.Added;
33
+ if (chosen === GitStatusEntry.UpdatedButUnmerged || addedInBoth) {
34
+ await checkoutConflictedFile(repository, file, manualResolution);
35
+ }
36
+ switch (chosen) {
37
+ case GitStatusEntry.Deleted:
38
+ return removeConflictedFile(repository, file);
39
+ case GitStatusEntry.Added:
40
+ case GitStatusEntry.UpdatedButUnmerged:
41
+ return addConflictedFile(repository, file);
42
+ default:
43
+ assertNever(chosen, 'unaccounted for git status entry possibility');
44
+ }
45
+ }
46
+ /**
47
+ * Stages all resolved conflict files before a checkout operation to prevent
48
+ * "error: you need to resolve your current index first" from git.
49
+ *
50
+ * Handles two kinds of resolved conflicts:
51
+ * - Text conflicts resolved in an external editor (conflictMarkerCount === 0)
52
+ * - Manual conflicts where the user chose ours/theirs in the Desktop UI
53
+ */
54
+ export async function stageResolvedConflictFiles(repository, files, manualResolutions) {
55
+ for (const file of files) {
56
+ const { status } = file;
57
+ if (!isConflictedFileStatus(status)) {
58
+ continue;
59
+ }
60
+ const manualResolution = manualResolutions.get(file.path);
61
+ if (manualResolution !== undefined) {
62
+ // Binary/manual conflict resolved via Desktop UI — stage it
63
+ await stageManualConflictResolution(repository, file, manualResolution);
64
+ }
65
+ else if (isConflictWithMarkers(status) &&
66
+ status.conflictMarkerCount === 0) {
67
+ // Text conflict resolved in external editor — stage it
68
+ await addConflictedFile(repository, file);
69
+ }
70
+ }
71
+ }
72
+ //# sourceMappingURL=stage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stage.js","sourceRoot":"","sources":["../../src/git/stage.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,EACtB,cAAc,EACd,qBAAqB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE5C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,UAAsB,EACtB,IAAgC,EAChC,gBAA0C;IAE1C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACvB,kDAAkD;IAClD,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,gDAAgD,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;QAC3E,OAAM;IACR,CAAC;IAED,IAAI,qBAAqB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,mBAAmB,KAAK,CAAC,EAAE,CAAC;QACtE,gFAAgF;QAChF,kFAAkF;QAClF,iBAAiB;QACjB,OAAM;IACR,CAAC;IAED,MAAM,MAAM,GACV,gBAAgB,KAAK,wBAAwB,CAAC,MAAM;QAClD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI;QACnB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;IAErB,MAAM,WAAW,GACf,MAAM,CAAC,KAAK,CAAC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;QAC3C,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { Repository } from '../models/repository.js';
2
+ import { IStashEntry } from '../models/stash-entry.js';
3
+ import { WorkingDirectoryFileChange, CommittedFileChange } from '../models/status.js';
4
+ import { Branch } from '../models/branch.js';
5
+ export declare const DesktopStashEntryMarker = "!!GitHub_Desktop";
6
+ type StashResult = {
7
+ /** The stash entries created by Desktop */
8
+ readonly desktopEntries: ReadonlyArray<IStashEntry>;
9
+ /**
10
+ * The total amount of stash entries,
11
+ * i.e. stash entries created both by Desktop and outside of Desktop
12
+ */
13
+ readonly stashEntryCount: number;
14
+ };
15
+ /**
16
+ * Get the list of stash entries created by Desktop in the current repository
17
+ * using the default ordering of refs (which is LIFO ordering),
18
+ * as well as the total amount of stash entries.
19
+ */
20
+ export declare function getStashes(repository: Repository): Promise<StashResult>;
21
+ /**
22
+ * Moves a stash entry to a different branch by means of creating
23
+ * a new stash entry associated with the new branch and dropping the old
24
+ * stash entry.
25
+ */
26
+ export declare function moveStashEntry(repository: Repository, { stashSha, parents, tree }: IStashEntry, branchName: string): Promise<void>;
27
+ /**
28
+ * Returns the last Desktop created stash entry for the given branch
29
+ */
30
+ export declare function getLastDesktopStashEntryForBranch(repository: Repository, branch: Branch | string): Promise<IStashEntry | null>;
31
+ /** Creates a stash entry message that indicates the entry was created by Desktop */
32
+ export declare function createDesktopStashMessage(branchName: string): string;
33
+ /**
34
+ * Stash the working directory changes for the current branch
35
+ */
36
+ export declare function createDesktopStashEntry(repository: Repository, branch: Branch | string, untrackedFilesToStage: ReadonlyArray<WorkingDirectoryFileChange>, selectedFiles: ReadonlyArray<string> | null): Promise<boolean>;
37
+ /**
38
+ * Removes the given stash entry if it exists
39
+ *
40
+ * @param stashSha the SHA that identifies the stash entry
41
+ */
42
+ export declare function dropDesktopStashEntry(repository: Repository, stashSha: string): Promise<void>;
43
+ /**
44
+ * Pops the stash entry identified by matching `stashSha` to its commit hash.
45
+ *
46
+ * To see the commit hash of stash entry, run
47
+ * `git log -g refs/stash --pretty="%nentry: %gd%nsubject: %gs%nhash: %H%n"`
48
+ * in a repo with some stash entries.
49
+ */
50
+ export declare function popStashEntry(repository: Repository, stashSha: string): Promise<void>;
51
+ /** Get the files that were changed in the given stash commit */
52
+ export declare function getStashedFiles(repository: Repository, stashSha: string): Promise<ReadonlyArray<CommittedFileChange>>;
53
+ export {};