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,81 @@
1
+ import { git } from './core.js';
2
+ import { GitError } from './exec.js';
3
+ import { envForRemoteOperation } from './environment.js';
4
+ import { getSymbolicRef } from './refs.js';
5
+ import memoizeOne from 'memoize-one';
6
+ /**
7
+ * List the remotes, sorted alphabetically by `name`, for a repository.
8
+ */
9
+ export async function getRemotes(repository) {
10
+ return memoizedGetRemotesFromPath(repository.path);
11
+ }
12
+ /**
13
+ * List the remotes, sorted alphabetically by `name`, for a repository path.
14
+ */
15
+ export async function getRemotesFromPath(path) {
16
+ const result = await git(['remote', '-v'], path, 'getRemotes', {
17
+ expectedErrors: new Set([GitError.NotAGitRepository]),
18
+ });
19
+ if (result.gitError === GitError.NotAGitRepository) {
20
+ return [];
21
+ }
22
+ return [...result.stdout.matchAll(/^(.+)\t(.+)\s\(fetch\)/gm)].map(([, name, url]) => ({ name, url }));
23
+ }
24
+ export const memoizedGetRemotesFromPath = memoizeOne(getRemotesFromPath);
25
+ /** Add a new remote with the given URL. */
26
+ export async function addRemote(repository, name, url) {
27
+ await git(['remote', 'add', name, url], repository.path, 'addRemote');
28
+ return { url, name };
29
+ }
30
+ /** Removes an existing remote, or silently errors if it doesn't exist */
31
+ export async function removeRemote(repository, name) {
32
+ const options = {
33
+ successExitCodes: new Set([0, 2, 128]),
34
+ };
35
+ await git(['remote', 'remove', name], repository.path, 'removeRemote', options);
36
+ }
37
+ /** Changes the URL for the remote that matches the given name */
38
+ export async function setRemoteURL(repository, name, url) {
39
+ await git(['remote', 'set-url', name, url], repository.path, 'setRemoteURL');
40
+ return true;
41
+ }
42
+ /**
43
+ * Get the URL for the remote that matches the given name.
44
+ *
45
+ * Returns null if the remote could not be found
46
+ */
47
+ export async function getRemoteURL(repository, name) {
48
+ const result = await git(['remote', 'get-url', name], repository.path, 'getRemoteURL', { successExitCodes: new Set([0, 2, 128]) });
49
+ if (result.exitCode !== 0) {
50
+ return null;
51
+ }
52
+ return result.stdout;
53
+ }
54
+ /**
55
+ * Update the HEAD ref of the remote, which is the default branch.
56
+ *
57
+ * @param isBackgroundTask Whether the fetch is being performed as a
58
+ * background task as opposed to being user initiated
59
+ */
60
+ export async function updateRemoteHEAD(repository, remote, isBackgroundTask) {
61
+ const options = {
62
+ successExitCodes: new Set([0, 1, 128]),
63
+ env: await envForRemoteOperation(remote.url),
64
+ isBackgroundTask,
65
+ };
66
+ await git(['remote', 'set-head', '-a', remote.name], repository.path, 'updateRemoteHEAD', options);
67
+ }
68
+ export async function getRemoteHEAD(repository, remote) {
69
+ const remoteNamespace = `refs/remotes/${remote}/`;
70
+ const match = await getSymbolicRef(repository, `${remoteNamespace}HEAD`);
71
+ if (match != null &&
72
+ match.length > remoteNamespace.length &&
73
+ match.startsWith(remoteNamespace)) {
74
+ // strip out everything related to the remote because this
75
+ // is likely to be a tracked branch locally
76
+ // e.g. `main`, `develop`, etc
77
+ return match.substring(remoteNamespace.length);
78
+ }
79
+ return null;
80
+ }
81
+ //# sourceMappingURL=remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.js","sourceRoot":"","sources":["../../src/git/remote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,UAAU,MAAM,aAAa,CAAA;AAEpC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAAsB;IAEtB,OAAO,0BAA0B,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAY;IAEZ,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE;QAC7D,cAAc,EAAE,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;KACtD,CAAC,CAAA;IAEF,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QACnD,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,CA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AAC,CAAA;IAChD,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,23 @@
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
+ * Reorders 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 toMove commits placed in the log at the location of the
10
+ * prior to the base commit.
11
+ *
12
+ * Example: A user's history from oldest to newest is A, B, C, D, E and they
13
+ * want to move A and E (toMove) before C. Our goal: B, A, E, C, D. Thus,
14
+ * maintaining that A came before E, placed in history before the the base
15
+ * commit C.
16
+ *
17
+ * @param toMove - commits to move
18
+ * @param beforeCommit - commits will be moved right before this commit. If it's
19
+ * null, the commits will be moved to the end of the history.
20
+ * @param lastRetainedCommitRef - sha of commit before commits to reorder or null
21
+ * if base commit for reordering is the root (first in history) of the branch
22
+ */
23
+ export declare function reorder(repository: Repository, toMove: ReadonlyArray<Commit>, beforeCommit: Commit | null, lastRetainedCommitRef: string | null, progressCallback?: (progress: IMultiCommitOperationProgress) => void): Promise<RebaseResult>;
@@ -0,0 +1,111 @@
1
+ import { appendFile, rm } 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
+ * Reorders 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 toMove commits placed in the log at the location of the
11
+ * prior to the base commit.
12
+ *
13
+ * Example: A user's history from oldest to newest is A, B, C, D, E and they
14
+ * want to move A and E (toMove) before C. Our goal: B, A, E, C, D. Thus,
15
+ * maintaining that A came before E, placed in history before the the base
16
+ * commit C.
17
+ *
18
+ * @param toMove - commits to move
19
+ * @param beforeCommit - commits will be moved right before this commit. If it's
20
+ * null, the commits will be moved to the end of the history.
21
+ * @param lastRetainedCommitRef - sha of commit before commits to reorder or null
22
+ * if base commit for reordering is the root (first in history) of the branch
23
+ */
24
+ export async function reorder(repository, toMove, beforeCommit, lastRetainedCommitRef, progressCallback) {
25
+ let todoPath;
26
+ let result;
27
+ try {
28
+ if (toMove.length === 0) {
29
+ throw new Error('[reorder] No commits provided to reorder.');
30
+ }
31
+ const toMoveShas = new Set(toMove.map(c => c.sha));
32
+ const commits = await getCommits(repository, lastRetainedCommitRef === null
33
+ ? undefined
34
+ : revRange(lastRetainedCommitRef, 'HEAD'));
35
+ if (commits.length === 0) {
36
+ throw new Error('[reorder] Could not find commits in log for last retained commit ref.');
37
+ }
38
+ todoPath = await getTempFilePath('reorderTodo');
39
+ let foundBaseCommitInLog = false;
40
+ const toReplayBeforeBaseCommit = [];
41
+ const toReplayAfterReorder = [];
42
+ // Traversed in reverse so we do oldest to newest (replay commits)
43
+ for (let i = commits.length - 1; i >= 0; i--) {
44
+ const commit = commits[i];
45
+ if (toMoveShas.has(commit.sha)) {
46
+ // If it is toMove commit and we have found the base commit, we
47
+ // can go ahead and insert them (as we will hold any picks till after)
48
+ if (foundBaseCommitInLog) {
49
+ await appendFile(todoPath, `pick ${commit.sha} ${commit.summary}\n`);
50
+ }
51
+ else {
52
+ // However, if we have not found the base commit yet we want to
53
+ // keep track of them in the order of the log. Thus, we use a new
54
+ // `toReplayBeforeBaseCommit` array and not trust that what was sent is in the
55
+ // order of the log.
56
+ toReplayBeforeBaseCommit.push(commit);
57
+ }
58
+ continue;
59
+ }
60
+ // If it's the base commit, replay to the toMove in the order they
61
+ // appeared on the log to reduce potential conflicts.
62
+ if (beforeCommit !== null && commit.sha === beforeCommit.sha) {
63
+ foundBaseCommitInLog = true;
64
+ toReplayAfterReorder.push(commit);
65
+ for (let j = 0; j < toReplayBeforeBaseCommit.length; j++) {
66
+ await appendFile(todoPath, `pick ${toReplayBeforeBaseCommit[j].sha} ${toReplayBeforeBaseCommit[j].summary}\n`);
67
+ }
68
+ continue;
69
+ }
70
+ // We can't just replay a pick in case there is a commit from the toMove
71
+ // commits further up in history that need to be moved. Thus, we will keep
72
+ // track of these and replay after traversing the remainder of the log.
73
+ if (foundBaseCommitInLog) {
74
+ toReplayAfterReorder.push(commit);
75
+ continue;
76
+ }
77
+ // If it is not one toMove nor the base commit and have not found the base
78
+ // commit, we simply record it is an unchanged pick (before the base commit)
79
+ await appendFile(todoPath, `pick ${commit.sha} ${commit.summary}\n`);
80
+ }
81
+ if (toReplayAfterReorder.length > 0) {
82
+ for (let i = 0; i < toReplayAfterReorder.length; i++) {
83
+ await appendFile(todoPath, `pick ${toReplayAfterReorder[i].sha} ${toReplayAfterReorder[i].summary}\n`);
84
+ }
85
+ }
86
+ if (beforeCommit === null) {
87
+ for (let i = 0; i < toReplayBeforeBaseCommit.length; i++) {
88
+ await appendFile(todoPath, `pick ${toReplayBeforeBaseCommit[i].sha} ${toReplayBeforeBaseCommit[i].summary}\n`);
89
+ }
90
+ }
91
+ else if (!foundBaseCommitInLog) {
92
+ throw new Error('[reorder] The base commit onto was not in the log. Continuing would result in dropping the commits in the toMove array.');
93
+ }
94
+ result = await rebaseInteractive(repository, todoPath, lastRetainedCommitRef, {
95
+ action: MultiCommitOperationKind.Reorder,
96
+ progressCallback,
97
+ commits,
98
+ });
99
+ }
100
+ catch (e) {
101
+ console.error(e);
102
+ return RebaseResult.Error;
103
+ }
104
+ finally {
105
+ if (todoPath !== undefined) {
106
+ await rm(todoPath, { recursive: true, force: true });
107
+ }
108
+ }
109
+ return result;
110
+ }
111
+ //# sourceMappingURL=reorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.js","sourceRoot":"","sources":["../../src/git/reorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAA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ACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { Repository } from '../models/repository.js';
2
+ /** The reset modes which are supported. */
3
+ export declare const enum GitResetMode {
4
+ /**
5
+ * Resets the index and working tree. Any changes to tracked files in the
6
+ * working tree since <commit> are discarded.
7
+ */
8
+ Hard = 0,
9
+ /**
10
+ * Does not touch the index file or the working tree at all (but resets the
11
+ * head to <commit>, just like all modes do). This leaves all your changed
12
+ * files "Changes to be committed", as git status would put it.
13
+ */
14
+ Soft = 1,
15
+ /**
16
+ * Resets the index but not the working tree (i.e., the changed files are
17
+ * preserved but not marked for commit) and reports what has not been updated.
18
+ * This is the default action for git reset.
19
+ */
20
+ Mixed = 2
21
+ }
22
+ /** Reset with the mode to the ref. */
23
+ export declare function reset(repository: Repository, mode: GitResetMode, ref: string): Promise<true>;
24
+ /**
25
+ * Updates the index with information from a particular tree for a given
26
+ * set of paths.
27
+ *
28
+ * @param repository The repository in which to reset the index.
29
+ *
30
+ * @param mode Which mode to use when resetting, see the GitResetMode
31
+ * enum for more information.
32
+ *
33
+ * @param ref A string which resolves to a tree, for example 'HEAD' or a
34
+ * commit sha.
35
+ *
36
+ * @param paths The paths that should be updated in the index with information
37
+ * from the given tree
38
+ */
39
+ export declare function resetPaths(repository: Repository, mode: GitResetMode, ref: string, paths: ReadonlyArray<string>): Promise<void>;
40
+ /** Unstage all paths. */
41
+ export declare function unstageAll(repository: Repository): Promise<true>;
@@ -0,0 +1,86 @@
1
+ import { git } from './core.js';
2
+ import { assertNever } from '../lib/fatal-error.js';
3
+ /** The reset modes which are supported. */
4
+ export var GitResetMode;
5
+ (function (GitResetMode) {
6
+ /**
7
+ * Resets the index and working tree. Any changes to tracked files in the
8
+ * working tree since <commit> are discarded.
9
+ */
10
+ GitResetMode[GitResetMode["Hard"] = 0] = "Hard";
11
+ /**
12
+ * Does not touch the index file or the working tree at all (but resets the
13
+ * head to <commit>, just like all modes do). This leaves all your changed
14
+ * files "Changes to be committed", as git status would put it.
15
+ */
16
+ GitResetMode[GitResetMode["Soft"] = 1] = "Soft";
17
+ /**
18
+ * Resets the index but not the working tree (i.e., the changed files are
19
+ * preserved but not marked for commit) and reports what has not been updated.
20
+ * This is the default action for git reset.
21
+ */
22
+ GitResetMode[GitResetMode["Mixed"] = 2] = "Mixed";
23
+ })(GitResetMode || (GitResetMode = {}));
24
+ function resetModeToArgs(mode, ref) {
25
+ switch (mode) {
26
+ case GitResetMode.Hard:
27
+ return ['reset', '--hard', ref];
28
+ case GitResetMode.Mixed:
29
+ return ['reset', ref];
30
+ case GitResetMode.Soft:
31
+ return ['reset', '--soft', ref];
32
+ default:
33
+ return assertNever(mode, `Unknown reset mode: ${mode}`);
34
+ }
35
+ }
36
+ /** Reset with the mode to the ref. */
37
+ export async function reset(repository, mode, ref) {
38
+ const args = resetModeToArgs(mode, ref);
39
+ await git(args, repository.path, 'reset');
40
+ return true;
41
+ }
42
+ /**
43
+ * Updates the index with information from a particular tree for a given
44
+ * set of paths.
45
+ *
46
+ * @param repository The repository in which to reset the index.
47
+ *
48
+ * @param mode Which mode to use when resetting, see the GitResetMode
49
+ * enum for more information.
50
+ *
51
+ * @param ref A string which resolves to a tree, for example 'HEAD' or a
52
+ * commit sha.
53
+ *
54
+ * @param paths The paths that should be updated in the index with information
55
+ * from the given tree
56
+ */
57
+ export async function resetPaths(repository, mode, ref, paths) {
58
+ if (!paths.length) {
59
+ return;
60
+ }
61
+ const baseArgs = resetModeToArgs(mode, ref);
62
+ if (process.platform === 'win32' && mode === GitResetMode.Mixed) {
63
+ // Git for Windows has experimental support for reading paths to reset
64
+ // from standard input. This is helpful in situations where your file
65
+ // paths are greater than 32KB in length, because of shell limitations.
66
+ //
67
+ // This hasn't made it to Git core, so we fallback to the default behaviour
68
+ // as macOS and Linux don't have this same shell limitation. See
69
+ // https://github.com/desktop/desktop/issues/2833#issuecomment-331352952
70
+ // for more context.
71
+ const args = [...baseArgs, '--stdin', '-z', '--'];
72
+ await git(args, repository.path, 'resetPaths', {
73
+ stdin: paths.join('\0'),
74
+ });
75
+ }
76
+ else {
77
+ const args = [...baseArgs, '--', ...paths];
78
+ await git(args, repository.path, 'resetPaths');
79
+ }
80
+ }
81
+ /** Unstage all paths. */
82
+ export async function unstageAll(repository) {
83
+ await git(['reset', '--', '.'], repository.path, 'unstageAll');
84
+ return true;
85
+ }
86
+ //# sourceMappingURL=reset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.js","sourceRoot":"","sources":["../../src/git/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,2CAA2C;AAC3C,MAAM,CAAN,IAAkB,YAmBjB;AAnBD,WAAkB,YAAY;IAC5B;;;OAGG;IACH,+CAAQ,CAAA;IACR;;;;OAIG;IACH,+CAAI,CAAA;IAEJ;;;;OAIG;IACH,iDAAK,CAAA;AACP,CAAC,EAnBiB,YAAY,KAAZ,YAAY,QAmB7B;AAED,SAAS,eAAe,CAAC,IAAkB,EAAE,GAAW;IACtD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;QACjC,KAAK,YAAY,CAAC,KAAK;YACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACvB,KAAK,YAAY,CAAC,IAAI;YACpB,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;QACjC;YACE,OAAO,WAAW,CAAC,IAAI,EAAE,uBAAuB,IAAI,EAAE,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC;AAED,sCAAsC;AACtC,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,UAAsB,EACtB,IAAkB,EAClB,GAAW;IAEX,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,EA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AI,CAAA;AACb,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { Repository } from '../models/repository.js';
2
+ import { Branch, IAheadBehind } from '../models/branch.js';
3
+ import { CommitOneLine } from '../models/commit.js';
4
+ /**
5
+ * Convert two refs into the Git range syntax representing the set of commits
6
+ * that are reachable from `to` but excluding those that are reachable from
7
+ * `from`. This will not be inclusive to the `from` ref, see
8
+ * `revRangeInclusive`.
9
+ *
10
+ * Each parameter can be the commit SHA or a ref name, or specify an empty
11
+ * string to represent HEAD.
12
+ *
13
+ * @param from The start of the range
14
+ * @param to The end of the range
15
+ */
16
+ export declare function revRange(from: string, to: string): string;
17
+ /**
18
+ * Convert two refs into the Git range syntax representing the set of commits
19
+ * that are reachable from `to` but excluding those that are reachable from
20
+ * `from`. However as opposed to `revRange`, this will also include `from` ref.
21
+ *
22
+ * Each parameter can be the commit SHA or a ref name, or specify an empty
23
+ * string to represent HEAD.
24
+ *
25
+ * @param from The start of the range
26
+ * @param to The end of the range
27
+ */
28
+ export declare function revRangeInclusive(from: string, to: string): string;
29
+ /**
30
+ * Convert two refs into the Git symmetric difference syntax, which represents
31
+ * the set of commits that are reachable from either `from` or `to` but not
32
+ * from both.
33
+ *
34
+ * Each parameter can be the commit SHA or a ref name, or you can use an empty
35
+ * string to represent HEAD.
36
+ *
37
+ * @param from The start of the range
38
+ * @param to The end of the range
39
+ */
40
+ export declare function revSymmetricDifference(from: string, to: string): string;
41
+ /** Calculate the number of commits the range is ahead and behind. */
42
+ export declare function getAheadBehind(repository: Repository, range: string): Promise<IAheadBehind | null>;
43
+ /** Calculate the number of commits `branch` is ahead/behind its upstream. */
44
+ export declare function getBranchAheadBehind(repository: Repository, branch: Branch): Promise<IAheadBehind | null>;
45
+ /**
46
+ * Get a list of commits from the target branch that do not exist on the base
47
+ * branch, ordered how they will be applied to the base branch.
48
+ * Therefore, this will not include the baseBranchSha commit.
49
+ *
50
+ * This emulates how `git rebase` initially determines what will be applied to
51
+ * the repository.
52
+ *
53
+ * Returns `null` when the rebase is not possible to perform, because of a
54
+ * missing commit ID
55
+ */
56
+ export declare function getCommitsBetweenCommits(repository: Repository, baseBranchSha: string, targetBranchSha: string): Promise<ReadonlyArray<CommitOneLine> | null>;
57
+ /**
58
+ * Get a list of commits inside the provided range.
59
+ *
60
+ * Returns `null` when it is not possible to perform because of a bad range.
61
+ */
62
+ export declare function getCommitsInRange(repository: Repository, range: string): Promise<ReadonlyArray<CommitOneLine> | null>;
63
+ /**
64
+ * Determine if merge commits exist in history after given commit
65
+ * If commitRef is null, goes back to HEAD of branch.
66
+ */
67
+ export declare function doMergeCommitsExistAfterCommit(repository: Repository, commitRef: string | null): Promise<boolean>;
@@ -0,0 +1,157 @@
1
+ import { GitError } from './exec.js';
2
+ import { git } from './core.js';
3
+ import { BranchType } from '../models/branch.js';
4
+ /**
5
+ * Convert two refs into the Git range syntax representing the set of commits
6
+ * that are reachable from `to` but excluding those that are reachable from
7
+ * `from`. This will not be inclusive to the `from` ref, see
8
+ * `revRangeInclusive`.
9
+ *
10
+ * Each parameter can be the commit SHA or a ref name, or specify an empty
11
+ * string to represent HEAD.
12
+ *
13
+ * @param from The start of the range
14
+ * @param to The end of the range
15
+ */
16
+ export function revRange(from, to) {
17
+ return `${from}..${to}`;
18
+ }
19
+ /**
20
+ * Convert two refs into the Git range syntax representing the set of commits
21
+ * that are reachable from `to` but excluding those that are reachable from
22
+ * `from`. However as opposed to `revRange`, this will also include `from` ref.
23
+ *
24
+ * Each parameter can be the commit SHA or a ref name, or specify an empty
25
+ * string to represent HEAD.
26
+ *
27
+ * @param from The start of the range
28
+ * @param to The end of the range
29
+ */
30
+ export function revRangeInclusive(from, to) {
31
+ return `${from}^..${to}`;
32
+ }
33
+ /**
34
+ * Convert two refs into the Git symmetric difference syntax, which represents
35
+ * the set of commits that are reachable from either `from` or `to` but not
36
+ * from both.
37
+ *
38
+ * Each parameter can be the commit SHA or a ref name, or you can use an empty
39
+ * string to represent HEAD.
40
+ *
41
+ * @param from The start of the range
42
+ * @param to The end of the range
43
+ */
44
+ export function revSymmetricDifference(from, to) {
45
+ return `${from}...${to}`;
46
+ }
47
+ /** Calculate the number of commits the range is ahead and behind. */
48
+ export async function getAheadBehind(repository, range) {
49
+ // `--left-right` annotates the list of commits in the range with which side
50
+ // they're coming from. When used with `--count`, it tells us how many
51
+ // commits we have from the two different sides of the range.
52
+ const args = ['rev-list', '--left-right', '--count', range, '--'];
53
+ const result = await git(args, repository.path, 'getAheadBehind', {
54
+ expectedErrors: new Set([GitError.BadRevision]),
55
+ });
56
+ // This means one of the refs (most likely the upstream branch) no longer
57
+ // exists. In that case we can't be ahead/behind at all.
58
+ if (result.gitError === GitError.BadRevision) {
59
+ return null;
60
+ }
61
+ const stdout = result.stdout;
62
+ const pieces = stdout.split('\t');
63
+ if (pieces.length !== 2) {
64
+ return null;
65
+ }
66
+ const ahead = parseInt(pieces[0], 10);
67
+ if (isNaN(ahead)) {
68
+ return null;
69
+ }
70
+ const behind = parseInt(pieces[1], 10);
71
+ if (isNaN(behind)) {
72
+ return null;
73
+ }
74
+ return { ahead, behind };
75
+ }
76
+ /** Calculate the number of commits `branch` is ahead/behind its upstream. */
77
+ export async function getBranchAheadBehind(repository, branch) {
78
+ if (branch.type === BranchType.Remote) {
79
+ return null;
80
+ }
81
+ const upstream = branch.upstream;
82
+ if (!upstream) {
83
+ return null;
84
+ }
85
+ // NB: The three dot form means we'll go all the way back to the merge base
86
+ // of the branch and its upstream. Practically this is important for seeing
87
+ // "through" merges.
88
+ const range = revSymmetricDifference(branch.name, upstream);
89
+ return getAheadBehind(repository, range);
90
+ }
91
+ /**
92
+ * Get a list of commits from the target branch that do not exist on the base
93
+ * branch, ordered how they will be applied to the base branch.
94
+ * Therefore, this will not include the baseBranchSha commit.
95
+ *
96
+ * This emulates how `git rebase` initially determines what will be applied to
97
+ * the repository.
98
+ *
99
+ * Returns `null` when the rebase is not possible to perform, because of a
100
+ * missing commit ID
101
+ */
102
+ export async function getCommitsBetweenCommits(repository, baseBranchSha, targetBranchSha) {
103
+ const range = revRange(baseBranchSha, targetBranchSha);
104
+ return getCommitsInRange(repository, range);
105
+ }
106
+ /**
107
+ * Get a list of commits inside the provided range.
108
+ *
109
+ * Returns `null` when it is not possible to perform because of a bad range.
110
+ */
111
+ export async function getCommitsInRange(repository, range) {
112
+ const args = [
113
+ 'rev-list',
114
+ range,
115
+ '--reverse',
116
+ // the combination of these two arguments means each line of the stdout
117
+ // will contain the full commit sha and a commit summary
118
+ `--oneline`,
119
+ `--no-abbrev-commit`,
120
+ '--',
121
+ ];
122
+ const options = {
123
+ expectedErrors: new Set([GitError.BadRevision]),
124
+ };
125
+ const result = await git(args, repository.path, 'getCommitsInRange', options);
126
+ if (result.gitError === GitError.BadRevision) {
127
+ return null;
128
+ }
129
+ const lines = result.stdout.split('\n');
130
+ const commits = new Array();
131
+ const commitSummaryRe = /^([a-z0-9]{40}) (.*)$/;
132
+ for (const line of lines) {
133
+ const match = commitSummaryRe.exec(line);
134
+ if (match !== null && match.length === 3) {
135
+ const sha = match[1];
136
+ const summary = match[2];
137
+ commits.push({
138
+ sha,
139
+ summary,
140
+ });
141
+ }
142
+ }
143
+ return commits;
144
+ }
145
+ /**
146
+ * Determine if merge commits exist in history after given commit
147
+ * If commitRef is null, goes back to HEAD of branch.
148
+ */
149
+ export async function doMergeCommitsExistAfterCommit(repository, commitRef) {
150
+ const revision = commitRef === null ? 'HEAD' : revRange(commitRef, 'HEAD');
151
+ const args = ['rev-list', '-1', '--merges', revision, '--'];
152
+ return git(args, repository.path, 'doMergeCommitsExistAfterCommit', {
153
+ // 128 here means there's no HEAD, i.e we're on an unborn branch
154
+ successExitCodes: new Set([0, 128]),
155
+ }).then(x => x.stdout.length > 0);
156
+ }
157
+ //# sourceMappingURL=rev-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rev-list.js","sourceRoot":"","sources":["../../src/git/rev-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,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E,MAAM,CAAC,CAAA;IAC1E,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;IAE3D,OAAO,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,gCAAgC,EAAE;QAClE,gEAAgE;QAChE,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;KACpC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACnC,CAAC"}
@@ -0,0 +1,24 @@
1
+ export type RepositoryType = {
2
+ kind: 'bare';
3
+ } | {
4
+ kind: 'regular';
5
+ topLevelWorkingDirectory: string;
6
+ gitDir: string;
7
+ } | {
8
+ kind: 'missing';
9
+ } | {
10
+ kind: 'unsafe';
11
+ path: string;
12
+ };
13
+ /**
14
+ * Attempts to fulfill the work of isGitRepository and isBareRepository while
15
+ * requiring only one Git process to be spawned.
16
+ *
17
+ * Returns 'bare', 'regular', or 'missing' if the repository couldn't be
18
+ * found.
19
+ */
20
+ export declare function getRepositoryType(path: string): Promise<RepositoryType>;
21
+ export declare function getUpstreamRefForRef(path: string, ref?: string): Promise<string | null>;
22
+ export declare function getUpstreamRemoteNameForRef(path: string, ref?: string): Promise<string | null>;
23
+ export declare const getCurrentUpstreamRef: (path: string) => Promise<string | null>;
24
+ export declare const getCurrentUpstreamRemoteName: (path: string) => Promise<string | null>;