git-chopstick-core 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (461) hide show
  1. package/README.md +324 -32
  2. package/dist/git/add.d.ts +9 -0
  3. package/dist/git/add.js +11 -0
  4. package/dist/git/add.js.map +1 -0
  5. package/dist/git/apply.d.ts +33 -0
  6. package/dist/git/apply.js +103 -0
  7. package/dist/git/apply.js.map +1 -0
  8. package/dist/git/authentication.d.ts +5 -0
  9. package/dist/git/authentication.js +19 -0
  10. package/dist/git/authentication.js.map +1 -0
  11. package/dist/git/branch.d.ts +43 -0
  12. package/dist/git/branch.js +150 -0
  13. package/dist/git/branch.js.map +1 -0
  14. package/dist/git/checkout-index.d.ts +19 -0
  15. package/{src/git/checkout-index.ts → dist/git/checkout-index.js} +11 -22
  16. package/dist/git/checkout-index.js.map +1 -0
  17. package/dist/git/checkout.d.ts +46 -0
  18. package/dist/git/checkout.js +126 -0
  19. package/dist/git/checkout.js.map +1 -0
  20. package/dist/git/cherry-pick.d.ts +82 -0
  21. package/dist/git/cherry-pick.js +371 -0
  22. package/dist/git/cherry-pick.js.map +1 -0
  23. package/dist/git/clean.d.ts +5 -0
  24. package/dist/git/clean.js +8 -0
  25. package/dist/git/clean.js.map +1 -0
  26. package/dist/git/clone.d.ts +22 -0
  27. package/dist/git/clone.js +58 -0
  28. package/dist/git/clone.js.map +1 -0
  29. package/dist/git/coerce-to-buffer.d.ts +1 -0
  30. package/dist/git/coerce-to-buffer.js +2 -0
  31. package/dist/git/coerce-to-buffer.js.map +1 -0
  32. package/dist/git/coerce-to-string.d.ts +1 -0
  33. package/dist/git/coerce-to-string.js +2 -0
  34. package/dist/git/coerce-to-string.js.map +1 -0
  35. package/dist/git/commit.d.ts +25 -0
  36. package/dist/git/commit.js +99 -0
  37. package/dist/git/commit.js.map +1 -0
  38. package/dist/git/config.d.ts +98 -0
  39. package/dist/git/config.js +249 -0
  40. package/dist/git/config.js.map +1 -0
  41. package/dist/git/core.d.ts +167 -0
  42. package/dist/git/core.js +368 -0
  43. package/dist/git/core.js.map +1 -0
  44. package/dist/git/create-tail-stream.d.ts +4 -0
  45. package/dist/git/create-tail-stream.js +30 -0
  46. package/dist/git/create-tail-stream.js.map +1 -0
  47. package/dist/git/credential.d.ts +5 -0
  48. package/dist/git/credential.js +64 -0
  49. package/dist/git/credential.js.map +1 -0
  50. package/dist/git/description.d.ts +5 -0
  51. package/dist/git/description.js +24 -0
  52. package/dist/git/description.js.map +1 -0
  53. package/dist/git/diff-check.d.ts +7 -0
  54. package/dist/git/diff-check.js +17 -0
  55. package/dist/git/diff-check.js.map +1 -0
  56. package/dist/git/diff-index.d.ts +31 -0
  57. package/dist/git/diff-index.js +76 -0
  58. package/dist/git/diff-index.js.map +1 -0
  59. package/dist/git/diff.d.ts +81 -0
  60. package/dist/git/diff.js +611 -0
  61. package/dist/git/diff.js.map +1 -0
  62. package/dist/git/environment.d.ts +51 -0
  63. package/dist/git/environment.js +97 -0
  64. package/dist/git/environment.js.map +1 -0
  65. package/dist/git/exec.d.ts +109 -0
  66. package/dist/git/exec.js +224 -0
  67. package/dist/git/exec.js.map +1 -0
  68. package/dist/git/fetch.d.ts +25 -0
  69. package/dist/git/fetch.js +100 -0
  70. package/dist/git/fetch.js.map +1 -0
  71. package/dist/git/for-each-ref.d.ts +13 -0
  72. package/dist/git/for-each-ref.js +114 -0
  73. package/dist/git/for-each-ref.js.map +1 -0
  74. package/dist/git/format-patch.d.ts +10 -0
  75. package/dist/git/format-patch.js +16 -0
  76. package/dist/git/format-patch.js.map +1 -0
  77. package/dist/git/git-delimiter-parser.d.ts +38 -0
  78. package/dist/git/git-delimiter-parser.js +79 -0
  79. package/dist/git/git-delimiter-parser.js.map +1 -0
  80. package/dist/git/gitignore.d.ts +26 -0
  81. package/dist/git/gitignore.js +124 -0
  82. package/dist/git/gitignore.js.map +1 -0
  83. package/dist/git/index.d.ts +46 -0
  84. package/dist/git/index.js +47 -0
  85. package/dist/git/index.js.map +1 -0
  86. package/dist/git/init.d.ts +2 -0
  87. package/dist/git/init.js +7 -0
  88. package/dist/git/init.js.map +1 -0
  89. package/{src/git/interpret-trailers.ts → dist/git/interpret-trailers.d.ts} +9 -97
  90. package/dist/git/interpret-trailers.js +130 -0
  91. package/dist/git/interpret-trailers.js.map +1 -0
  92. package/dist/git/lfs.d.ts +25 -0
  93. package/dist/git/lfs.js +73 -0
  94. package/dist/git/lfs.js.map +1 -0
  95. package/dist/git/log.d.ts +56 -0
  96. package/dist/git/log.js +258 -0
  97. package/dist/git/log.js.map +1 -0
  98. package/dist/git/merge-tree.d.ts +13 -0
  99. package/dist/git/merge-tree.js +24 -0
  100. package/dist/git/merge-tree.js.map +1 -0
  101. package/dist/git/merge.d.ts +50 -0
  102. package/dist/git/merge.js +111 -0
  103. package/dist/git/merge.js.map +1 -0
  104. package/dist/git/multi-operation-terminal-output.d.ts +20 -0
  105. package/dist/git/multi-operation-terminal-output.js +56 -0
  106. package/dist/git/multi-operation-terminal-output.js.map +1 -0
  107. package/dist/git/pull.d.ts +24 -0
  108. package/dist/git/pull.js +91 -0
  109. package/dist/git/pull.js.map +1 -0
  110. package/{src/git/push-terminal-chunk.ts → dist/git/push-terminal-chunk.d.ts} +1 -23
  111. package/dist/git/push-terminal-chunk.js +36 -0
  112. package/dist/git/push-terminal-chunk.js.map +1 -0
  113. package/dist/git/push.d.ts +42 -0
  114. package/dist/git/push.js +80 -0
  115. package/dist/git/push.js.map +1 -0
  116. package/dist/git/rebase.d.ts +119 -0
  117. package/dist/git/rebase.js +415 -0
  118. package/dist/git/rebase.js.map +1 -0
  119. package/dist/git/reflog.d.ts +14 -0
  120. package/dist/git/reflog.js +88 -0
  121. package/dist/git/reflog.js.map +1 -0
  122. package/dist/git/refs.d.ts +26 -0
  123. package/dist/git/refs.js +53 -0
  124. package/dist/git/refs.js.map +1 -0
  125. package/dist/git/remote.d.ts +31 -0
  126. package/dist/git/remote.js +81 -0
  127. package/dist/git/remote.js.map +1 -0
  128. package/dist/git/reorder.d.ts +23 -0
  129. package/dist/git/reorder.js +111 -0
  130. package/dist/git/reorder.js.map +1 -0
  131. package/dist/git/reset.d.ts +41 -0
  132. package/dist/git/reset.js +86 -0
  133. package/dist/git/reset.js.map +1 -0
  134. package/dist/git/rev-list.d.ts +67 -0
  135. package/dist/git/rev-list.js +157 -0
  136. package/dist/git/rev-list.js.map +1 -0
  137. package/dist/git/rev-parse.d.ts +24 -0
  138. package/dist/git/rev-parse.js +65 -0
  139. package/dist/git/rev-parse.js.map +1 -0
  140. package/dist/git/revert.d.ts +12 -0
  141. package/dist/git/revert.js +30 -0
  142. package/dist/git/revert.js.map +1 -0
  143. package/dist/git/rm.d.ts +12 -0
  144. package/dist/git/rm.js +22 -0
  145. package/dist/git/rm.js.map +1 -0
  146. package/dist/git/show.d.ts +42 -0
  147. package/{src/git/show.ts → dist/git/show.js} +17 -46
  148. package/dist/git/show.js.map +1 -0
  149. package/dist/git/spawn.d.ts +18 -0
  150. package/dist/git/spawn.js +16 -0
  151. package/dist/git/spawn.js.map +1 -0
  152. package/dist/git/squash.d.ts +28 -0
  153. package/dist/git/squash.js +127 -0
  154. package/dist/git/squash.js.map +1 -0
  155. package/dist/git/stage.d.ts +21 -0
  156. package/dist/git/stage.js +72 -0
  157. package/dist/git/stage.js.map +1 -0
  158. package/dist/git/stash.d.ts +53 -0
  159. package/dist/git/stash.js +204 -0
  160. package/dist/git/stash.js.map +1 -0
  161. package/dist/git/status.d.ts +39 -0
  162. package/dist/git/status.js +293 -0
  163. package/dist/git/status.js.map +1 -0
  164. package/dist/git/submodule.d.ts +20 -0
  165. package/dist/git/submodule.js +153 -0
  166. package/dist/git/submodule.js.map +1 -0
  167. package/dist/git/tag.d.ts +32 -0
  168. package/dist/git/tag.js +101 -0
  169. package/dist/git/tag.js.map +1 -0
  170. package/dist/git/update-index.d.ts +11 -0
  171. package/dist/git/update-index.js +99 -0
  172. package/dist/git/update-index.js.map +1 -0
  173. package/dist/git/update-ref.d.ts +23 -0
  174. package/{src/git/update-ref.ts → dist/git/update-ref.js} +10 -28
  175. package/dist/git/update-ref.js.map +1 -0
  176. package/dist/git/var.d.ts +18 -0
  177. package/{src/git/var.ts → dist/git/var.js} +16 -25
  178. package/dist/git/var.js.map +1 -0
  179. package/dist/git/worktree-include.d.ts +42 -0
  180. package/dist/git/worktree-include.js +109 -0
  181. package/dist/git/worktree-include.js.map +1 -0
  182. package/dist/git/worktree.d.ts +25 -0
  183. package/dist/git/worktree.js +139 -0
  184. package/dist/git/worktree.js.map +1 -0
  185. package/dist/index.d.ts +4 -0
  186. package/dist/index.js +7 -0
  187. package/dist/index.js.map +1 -0
  188. package/dist/lib/api.d.ts +2 -0
  189. package/dist/lib/api.js +7 -0
  190. package/dist/lib/api.js.map +1 -0
  191. package/dist/lib/diff-parser.d.ts +20 -0
  192. package/dist/lib/diff-parser.js +184 -0
  193. package/dist/lib/diff-parser.js.map +1 -0
  194. package/dist/lib/directory-exists.d.ts +1 -0
  195. package/dist/lib/directory-exists.js +11 -0
  196. package/dist/lib/directory-exists.js.map +1 -0
  197. package/dist/lib/errno-exception.d.ts +6 -0
  198. package/dist/lib/errno-exception.js +6 -0
  199. package/dist/lib/errno-exception.js.map +1 -0
  200. package/dist/lib/fatal-error.d.ts +4 -0
  201. package/dist/lib/fatal-error.js +18 -0
  202. package/dist/lib/fatal-error.js.map +1 -0
  203. package/dist/lib/feature-flag.d.ts +14 -0
  204. package/dist/lib/feature-flag.js +25 -0
  205. package/dist/lib/feature-flag.js.map +1 -0
  206. package/dist/lib/file-system.d.ts +1 -0
  207. package/dist/lib/file-system.js +7 -0
  208. package/dist/lib/file-system.js.map +1 -0
  209. package/dist/lib/get-old-path.d.ts +2 -0
  210. package/dist/lib/get-old-path.js +9 -0
  211. package/dist/lib/get-old-path.js.map +1 -0
  212. package/dist/lib/git/environment.d.ts +3 -0
  213. package/dist/lib/git/environment.js +7 -0
  214. package/dist/lib/git/environment.js.map +1 -0
  215. package/dist/lib/git-perf.d.ts +1 -0
  216. package/dist/lib/git-perf.js +4 -0
  217. package/dist/lib/git-perf.js.map +1 -0
  218. package/dist/lib/helpers/default-branch.d.ts +1 -0
  219. package/dist/lib/helpers/default-branch.js +4 -0
  220. package/dist/lib/helpers/default-branch.js.map +1 -0
  221. package/dist/lib/helpers/path.d.ts +1 -0
  222. package/dist/lib/helpers/path.js +5 -0
  223. package/dist/lib/helpers/path.js.map +1 -0
  224. package/dist/lib/hooks/with-hooks-env.d.ts +3 -0
  225. package/dist/lib/hooks/with-hooks-env.js +4 -0
  226. package/dist/lib/hooks/with-hooks-env.js.map +1 -0
  227. package/dist/lib/merge.d.ts +1 -0
  228. package/dist/lib/merge.js +4 -0
  229. package/dist/lib/merge.js.map +1 -0
  230. package/dist/lib/noop.d.ts +1 -0
  231. package/dist/lib/noop.js +2 -0
  232. package/dist/lib/noop.js.map +1 -0
  233. package/dist/lib/patch-formatter.d.ts +5 -0
  234. package/dist/lib/patch-formatter.js +7 -0
  235. package/dist/lib/patch-formatter.js.map +1 -0
  236. package/dist/lib/path-exists.d.ts +1 -0
  237. package/dist/lib/path-exists.js +3 -0
  238. package/dist/lib/path-exists.js.map +1 -0
  239. package/dist/lib/progress/from-process.d.ts +2 -0
  240. package/dist/lib/progress/from-process.js +4 -0
  241. package/dist/lib/progress/from-process.js.map +1 -0
  242. package/dist/lib/progress/index.d.ts +49 -0
  243. package/dist/lib/progress/index.js +32 -0
  244. package/dist/lib/progress/index.js.map +1 -0
  245. package/dist/lib/progress/revert.d.ts +8 -0
  246. package/dist/lib/progress/revert.js +15 -0
  247. package/dist/lib/progress/revert.js.map +1 -0
  248. package/dist/lib/rebase.d.ts +1 -0
  249. package/dist/lib/rebase.js +4 -0
  250. package/dist/lib/rebase.js.map +1 -0
  251. package/dist/lib/remove-remote-prefix.d.ts +1 -0
  252. package/dist/lib/remove-remote-prefix.js +5 -0
  253. package/dist/lib/remove-remote-prefix.js.map +1 -0
  254. package/dist/lib/resolve-git-proxy.d.ts +1 -0
  255. package/dist/lib/resolve-git-proxy.js +4 -0
  256. package/dist/lib/resolve-git-proxy.js.map +1 -0
  257. package/dist/lib/round.d.ts +1 -0
  258. package/dist/lib/round.js +5 -0
  259. package/dist/lib/round.js.map +1 -0
  260. package/dist/lib/split-buffer.d.ts +1 -0
  261. package/dist/lib/split-buffer.js +15 -0
  262. package/dist/lib/split-buffer.js.map +1 -0
  263. package/dist/lib/status-parser.d.ts +19 -0
  264. package/dist/lib/status-parser.js +125 -0
  265. package/dist/lib/status-parser.js.map +1 -0
  266. package/dist/lib/stores/helpers/find-default-remote.d.ts +1 -0
  267. package/dist/lib/stores/helpers/find-default-remote.js +4 -0
  268. package/dist/lib/stores/helpers/find-default-remote.js.map +1 -0
  269. package/dist/lib/trampoline/trampoline-environment.d.ts +1 -0
  270. package/dist/lib/trampoline/trampoline-environment.js +4 -0
  271. package/dist/lib/trampoline/trampoline-environment.js.map +1 -0
  272. package/dist/models/branch.d.ts +44 -0
  273. package/dist/models/branch.js +59 -0
  274. package/dist/models/branch.js.map +1 -0
  275. package/dist/models/cherry-pick.d.ts +11 -0
  276. package/dist/models/cherry-pick.js +2 -0
  277. package/dist/models/cherry-pick.js.map +1 -0
  278. package/dist/models/clone-options.d.ts +6 -0
  279. package/dist/models/clone-options.js +2 -0
  280. package/dist/models/clone-options.js.map +1 -0
  281. package/dist/models/commit-identity.d.ts +9 -0
  282. package/dist/models/commit-identity.js +34 -0
  283. package/dist/models/commit-identity.js.map +1 -0
  284. package/dist/models/commit.d.ts +30 -0
  285. package/dist/models/commit.js +32 -0
  286. package/dist/models/commit.js.map +1 -0
  287. package/dist/models/computed-action.d.ts +6 -0
  288. package/dist/models/computed-action.js +8 -0
  289. package/dist/models/computed-action.js.map +1 -0
  290. package/dist/models/diff/diff-data.d.ts +53 -0
  291. package/dist/models/diff/diff-data.js +19 -0
  292. package/dist/models/diff/diff-data.js.map +1 -0
  293. package/dist/models/diff/diff-line.d.ts +18 -0
  294. package/dist/models/diff/diff-line.js +33 -0
  295. package/dist/models/diff/diff-line.js.map +1 -0
  296. package/dist/models/diff/diff-selection.d.ts +22 -0
  297. package/dist/models/diff/diff-selection.js +127 -0
  298. package/dist/models/diff/diff-selection.js.map +1 -0
  299. package/dist/models/diff/image-diff.d.ts +6 -0
  300. package/dist/models/diff/image-diff.js +8 -0
  301. package/dist/models/diff/image-diff.js.map +1 -0
  302. package/dist/models/diff/image.d.ts +7 -0
  303. package/dist/models/diff/image.js +13 -0
  304. package/dist/models/diff/image.js.map +1 -0
  305. package/dist/models/diff/index.d.ts +6 -0
  306. package/dist/models/diff/index.js +7 -0
  307. package/dist/models/diff/index.js.map +1 -0
  308. package/dist/models/diff/raw-diff.d.ts +32 -0
  309. package/dist/models/diff/raw-diff.js +38 -0
  310. package/dist/models/diff/raw-diff.js.map +1 -0
  311. package/dist/models/git-author.d.ts +7 -0
  312. package/dist/models/git-author.js +18 -0
  313. package/dist/models/git-author.js.map +1 -0
  314. package/dist/models/index.d.ts +21 -0
  315. package/dist/models/index.js +20 -0
  316. package/dist/models/index.js.map +1 -0
  317. package/dist/models/manual-conflict-resolution.d.ts +4 -0
  318. package/dist/models/manual-conflict-resolution.js +6 -0
  319. package/dist/models/manual-conflict-resolution.js.map +1 -0
  320. package/dist/models/merge.d.ts +6 -0
  321. package/dist/models/merge.js +2 -0
  322. package/dist/models/merge.js.map +1 -0
  323. package/dist/models/multi-commit-operation.d.ts +6 -0
  324. package/dist/models/multi-commit-operation.js +8 -0
  325. package/dist/models/multi-commit-operation.js.map +1 -0
  326. package/dist/models/progress.d.ts +41 -0
  327. package/dist/models/progress.js +7 -0
  328. package/dist/models/progress.js.map +1 -0
  329. package/dist/models/rebase.d.ts +17 -0
  330. package/dist/models/rebase.js +8 -0
  331. package/dist/models/rebase.js.map +1 -0
  332. package/dist/models/remote.d.ts +5 -0
  333. package/dist/models/remote.js +8 -0
  334. package/dist/models/remote.js.map +1 -0
  335. package/dist/models/repository.d.ts +7 -0
  336. package/dist/models/repository.js +15 -0
  337. package/dist/models/repository.js.map +1 -0
  338. package/dist/models/stash-entry.d.ts +20 -0
  339. package/dist/models/stash-entry.js +7 -0
  340. package/dist/models/stash-entry.js.map +1 -0
  341. package/dist/models/status.d.ts +166 -0
  342. package/dist/models/status.js +135 -0
  343. package/dist/models/status.js.map +1 -0
  344. package/dist/models/submodule.d.ts +12 -0
  345. package/dist/models/submodule.js +2 -0
  346. package/dist/models/submodule.js.map +1 -0
  347. package/dist/models/worktree.d.ts +10 -0
  348. package/dist/models/worktree.js +2 -0
  349. package/dist/models/worktree.js.map +1 -0
  350. package/package.json +44 -5
  351. package/examples/get-status.ts +0 -84
  352. package/src/git/add.ts +0 -16
  353. package/src/git/apply.ts +0 -154
  354. package/src/git/authentication.ts +0 -19
  355. package/src/git/branch.ts +0 -206
  356. package/src/git/checkout.ts +0 -235
  357. package/src/git/cherry-pick.ts +0 -504
  358. package/src/git/clean.ts +0 -9
  359. package/src/git/clone.ts +0 -86
  360. package/src/git/coerce-to-buffer.ts +0 -4
  361. package/src/git/coerce-to-string.ts +0 -4
  362. package/src/git/commit.ts +0 -136
  363. package/src/git/config.ts +0 -392
  364. package/src/git/core.ts +0 -625
  365. package/src/git/create-tail-stream.ts +0 -36
  366. package/src/git/credential.ts +0 -83
  367. package/src/git/description.ts +0 -33
  368. package/src/git/diff-check.ts +0 -27
  369. package/src/git/diff-index.ts +0 -116
  370. package/src/git/diff.ts +0 -880
  371. package/src/git/environment.ts +0 -116
  372. package/src/git/exec.ts +0 -285
  373. package/src/git/fetch.ts +0 -141
  374. package/src/git/for-each-ref.ts +0 -160
  375. package/src/git/format-patch.ts +0 -17
  376. package/src/git/git-delimiter-parser.ts +0 -95
  377. package/src/git/gitignore.ts +0 -157
  378. package/src/git/index.ts +0 -36
  379. package/src/git/init.ts +0 -11
  380. package/src/git/lfs.ts +0 -100
  381. package/src/git/log.ts +0 -376
  382. package/src/git/merge-tree.ts +0 -42
  383. package/src/git/merge.ts +0 -154
  384. package/src/git/multi-operation-terminal-output.ts +0 -68
  385. package/src/git/pull.ts +0 -130
  386. package/src/git/push.ts +0 -119
  387. package/src/git/rebase.ts +0 -627
  388. package/src/git/reflog.ts +0 -127
  389. package/src/git/refs.ts +0 -63
  390. package/src/git/remote.ts +0 -143
  391. package/src/git/reorder.ts +0 -153
  392. package/src/git/reset.ts +0 -101
  393. package/src/git/rev-list.ts +0 -201
  394. package/src/git/rev-parse.ts +0 -92
  395. package/src/git/revert.ts +0 -55
  396. package/src/git/rm.ts +0 -31
  397. package/src/git/spawn.ts +0 -38
  398. package/src/git/squash.ts +0 -173
  399. package/src/git/stage.ts +0 -97
  400. package/src/git/stash.ts +0 -302
  401. package/src/git/status.ts +0 -502
  402. package/src/git/submodule.ts +0 -212
  403. package/src/git/tag.ts +0 -134
  404. package/src/git/update-index.ts +0 -169
  405. package/src/git/worktree-include.ts +0 -146
  406. package/src/git/worktree.ts +0 -219
  407. package/src/index.ts +0 -23
  408. package/src/lib/api.ts +0 -7
  409. package/src/lib/diff-parser.ts +0 -249
  410. package/src/lib/directory-exists.ts +0 -10
  411. package/src/lib/errno-exception.ts +0 -12
  412. package/src/lib/fatal-error.ts +0 -23
  413. package/src/lib/feature-flag.ts +0 -29
  414. package/src/lib/file-system.ts +0 -7
  415. package/src/lib/get-old-path.ts +0 -11
  416. package/src/lib/git/environment.ts +0 -14
  417. package/src/lib/git-perf.ts +0 -3
  418. package/src/lib/helpers/default-branch.ts +0 -3
  419. package/src/lib/helpers/path.ts +0 -5
  420. package/src/lib/hooks/with-hooks-env.ts +0 -7
  421. package/src/lib/merge.ts +0 -3
  422. package/src/lib/noop.ts +0 -1
  423. package/src/lib/patch-formatter.ts +0 -18
  424. package/src/lib/path-exists.ts +0 -7
  425. package/src/lib/progress/from-process.ts +0 -10
  426. package/src/lib/progress/index.ts +0 -43
  427. package/src/lib/progress/revert.ts +0 -17
  428. package/src/lib/rebase.ts +0 -3
  429. package/src/lib/remove-remote-prefix.ts +0 -4
  430. package/src/lib/resolve-git-proxy.ts +0 -3
  431. package/src/lib/round.ts +0 -4
  432. package/src/lib/split-buffer.ts +0 -14
  433. package/src/lib/status-parser.ts +0 -188
  434. package/src/lib/stores/helpers/find-default-remote.ts +0 -3
  435. package/src/lib/trampoline/trampoline-environment.ts +0 -8
  436. package/src/models/branch.ts +0 -78
  437. package/src/models/cherry-pick.ts +0 -12
  438. package/src/models/clone-options.ts +0 -6
  439. package/src/models/commit-identity.ts +0 -35
  440. package/src/models/commit.ts +0 -44
  441. package/src/models/computed-action.ts +0 -6
  442. package/src/models/diff/diff-data.ts +0 -78
  443. package/src/models/diff/diff-line.ts +0 -36
  444. package/src/models/diff/diff-selection.ts +0 -165
  445. package/src/models/diff/image-diff.ts +0 -6
  446. package/src/models/diff/image.ts +0 -8
  447. package/src/models/diff/index.ts +0 -6
  448. package/src/models/diff/raw-diff.ts +0 -41
  449. package/src/models/git-author.ts +0 -16
  450. package/src/models/manual-conflict-resolution.ts +0 -4
  451. package/src/models/merge.ts +0 -6
  452. package/src/models/multi-commit-operation.ts +0 -6
  453. package/src/models/progress.ts +0 -67
  454. package/src/models/rebase.ts +0 -20
  455. package/src/models/remote.ts +0 -10
  456. package/src/models/repository.ts +0 -16
  457. package/src/models/stash-entry.ts +0 -25
  458. package/src/models/status.ts +0 -275
  459. package/src/models/submodule.ts +0 -13
  460. package/src/models/worktree.ts +0 -11
  461. package/tsconfig.json +0 -17
@@ -0,0 +1,114 @@
1
+ import { git } from './core.js';
2
+ import { GitError } from './exec.js';
3
+ import { Branch, BranchType, } from '../models/branch.js';
4
+ import { createForEachRefParser } from './git-delimiter-parser.js';
5
+ /** Get all the branches. */
6
+ export async function getBranches(repository, ...prefixes) {
7
+ const { formatArgs, parse } = createForEachRefParser({
8
+ fullName: '%(refname)',
9
+ shortName: '%(refname:short)',
10
+ upstreamShortName: '%(upstream:short)',
11
+ upstreamTrackingBranch: '%(upstream:track)',
12
+ sha: '%(objectname)',
13
+ symRef: '%(symref)',
14
+ authorDate: '%(authordate:iso8601)',
15
+ });
16
+ if (!prefixes || !prefixes.length) {
17
+ prefixes = ['refs/heads', 'refs/remotes'];
18
+ }
19
+ // TODO: use expectedErrors here to handle a specific error
20
+ // see https://github.com/desktop/desktop/pull/5299#discussion_r206603442 for
21
+ // discussion about what needs to change
22
+ const result = await git(['for-each-ref', ...formatArgs, ...prefixes], repository.path, 'getBranches', { expectedErrors: new Set([GitError.NotAGitRepository]) });
23
+ if (result.gitError === GitError.NotAGitRepository) {
24
+ return [];
25
+ }
26
+ const branches = [];
27
+ for (const ref of parse(result.stdout)) {
28
+ // excude symbolic refs from the branch list
29
+ if (ref.symRef.length > 0) {
30
+ continue;
31
+ }
32
+ const tip = {
33
+ sha: ref.sha,
34
+ author: {
35
+ date: new Date(ref.authorDate),
36
+ },
37
+ };
38
+ const type = ref.fullName.startsWith('refs/heads')
39
+ ? BranchType.Local
40
+ : BranchType.Remote;
41
+ const upstream = ref.upstreamShortName.length > 0 ? ref.upstreamShortName : null;
42
+ const isGone = ['[gone]', '(gone)'].includes(ref.upstreamTrackingBranch);
43
+ branches.push(new Branch(ref.shortName, upstream, tip, type, ref.fullName, isGone));
44
+ }
45
+ return branches;
46
+ }
47
+ /**
48
+ * Gets all branches that differ from their upstream (i.e. they're ahead,
49
+ * behind or both), excluding the current branch.
50
+ * Useful to narrow down a list of branches that could potentially be fast
51
+ * forwarded.
52
+ *
53
+ * @param repository Repository to get the branches from.
54
+ */
55
+ export async function getBranchesDifferingFromUpstream(repository) {
56
+ const { formatArgs, parse } = createForEachRefParser({
57
+ fullName: '%(refname)',
58
+ sha: '%(objectname)', // SHA
59
+ upstream: '%(upstream)',
60
+ symref: '%(symref)',
61
+ head: '%(HEAD)',
62
+ worktreePath: '%(worktreepath)',
63
+ });
64
+ const prefixes = ['refs/heads', 'refs/remotes'];
65
+ const result = await git(['for-each-ref', ...formatArgs, ...prefixes], repository.path, 'getBranchesDifferingFromUpstream', { expectedErrors: new Set([GitError.NotAGitRepository]) });
66
+ if (result.gitError === GitError.NotAGitRepository) {
67
+ return [];
68
+ }
69
+ const localBranches = [];
70
+ const remoteBranchShas = new Map();
71
+ // First we need to collect the relevant info from the command output:
72
+ // - For local branches with upstream: name, ref, SHA and the upstream.
73
+ // - For remote branches we only need the sha (and the ref as key).
74
+ for (const ref of parse(result.stdout)) {
75
+ if (ref.symref.length > 0 || ref.head === '*') {
76
+ // Exclude symbolic refs and the current branch
77
+ continue;
78
+ }
79
+ if (ref.worktreePath.length > 0 && ref.worktreePath !== repository.path) {
80
+ // Exclude branches checked out in other worktrees, since they can't be fast-forwarded from here
81
+ continue;
82
+ }
83
+ if (ref.fullName.startsWith('refs/heads')) {
84
+ if (ref.upstream.length === 0) {
85
+ // Exclude local branches without upstream
86
+ continue;
87
+ }
88
+ localBranches.push({
89
+ ref: ref.fullName,
90
+ sha: ref.sha,
91
+ upstream: ref.upstream,
92
+ });
93
+ }
94
+ else {
95
+ remoteBranchShas.set(ref.fullName, ref.sha);
96
+ }
97
+ }
98
+ const eligibleBranches = new Array();
99
+ // Compare the SHA of every local branch with the SHA of its upstream and
100
+ // collect the names of local branches that differ from their upstream.
101
+ for (const branch of localBranches) {
102
+ const remoteSha = remoteBranchShas.get(branch.upstream);
103
+ if (remoteSha !== undefined && remoteSha !== branch.sha) {
104
+ eligibleBranches.push({
105
+ ref: branch.ref,
106
+ sha: branch.sha,
107
+ upstreamRef: branch.upstream,
108
+ upstreamSha: remoteSha,
109
+ });
110
+ }
111
+ }
112
+ return eligibleBranches;
113
+ }
114
+ //# sourceMappingURL=for-each-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"for-each-ref.js","sourceRoot":"","sources":["../../src/git/for-each-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EACL,MAAM,EACN,UAAU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AyE;IACzE,uEAAuE;IACvE,KAAK,MAAM,MAAM,IAAI,aAAa,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAEvD,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC;YACxD,gBAAgB,CAAC,IAAI,CAAC;gBACpB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,WAAW,EAAE,MAAM,CAAC,QAAQ;gBAC5B,WAAW,EAAE,SAAS;aACvB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Repository } from '../models/repository.js';
2
+ /**
3
+ * Generate a patch representing the changes associated with a range of commits
4
+ *
5
+ * @param repository where to generate path from
6
+ * @param base starting commit in range
7
+ * @param head ending commit in rage
8
+ * @returns patch generated
9
+ */
10
+ export declare function formatPatch({ path }: Repository, base: string, head: string): Promise<string>;
@@ -0,0 +1,16 @@
1
+ import { revRange } from './rev-list.js';
2
+ import { git } from './index.js';
3
+ /**
4
+ * Generate a patch representing the changes associated with a range of commits
5
+ *
6
+ * @param repository where to generate path from
7
+ * @param base starting commit in range
8
+ * @param head ending commit in rage
9
+ * @returns patch generated
10
+ */
11
+ export function formatPatch({ path }, base, head) {
12
+ const range = revRange(base, head);
13
+ const args = ['format-patch', '--unified=1', '--minimal', '--stdout', range];
14
+ return git(args, path, 'formatPatch').then(x => x.stdout);
15
+ }
16
+ //# sourceMappingURL=format-patch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-patch.js","sourceRoot":"","sources":["../../src/git/format-patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAA;AAEhC;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,IAAI,EAAc,EAAE,IAAY,EAAE,IAAY;IAC1E,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAClC,MAAM,IAAI,GAAG,CAAC,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;IAC5E,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAC3D,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Create a new parser suitable for parsing --format output from commands such
3
+ * as `git log`, `git stash`, and other commands that are not derived from
4
+ * `ref-filter`.
5
+ *
6
+ * Returns an object with the arguments that need to be appended to the git
7
+ * call and the parse function itself
8
+ *
9
+ * @param fields An object keyed on the friendly name of the value being
10
+ * parsed with the value being the format string of said value.
11
+ *
12
+ * Example:
13
+ *
14
+ * `const { args, parse } = createLogParser({ sha: '%H' })`
15
+ */
16
+ export declare function createLogParser<T extends Record<string, string>>(fields: T): {
17
+ formatArgs: string[];
18
+ parse: <V extends string | Buffer>(value: V) => { [K in keyof T]: V; }[];
19
+ };
20
+ /**
21
+ * Create a new parser suitable for parsing --format output from commands such
22
+ * as `git for-each-ref`, `git branch`, and other commands that are not derived
23
+ * from `git log`.
24
+ *
25
+ * Returns an object with the arguments that need to be appended to the git
26
+ * call and the parse function itself
27
+ *
28
+ * @param fields An object keyed on the friendly name of the value being
29
+ * parsed with the value being the format string of said value.
30
+ *
31
+ * Example:
32
+ *
33
+ * `const { args, parse } = createForEachRefParser({ sha: '%(objectname)' })`
34
+ */
35
+ export declare function createForEachRefParser<T extends Record<string, string>>(fields: T): {
36
+ formatArgs: string[];
37
+ parse: (value: string) => { [K in keyof T]: string; }[];
38
+ };
@@ -0,0 +1,79 @@
1
+ import { splitBuffer } from '../lib/split-buffer.js';
2
+ /**
3
+ * Create a new parser suitable for parsing --format output from commands such
4
+ * as `git log`, `git stash`, and other commands that are not derived from
5
+ * `ref-filter`.
6
+ *
7
+ * Returns an object with the arguments that need to be appended to the git
8
+ * call and the parse function itself
9
+ *
10
+ * @param fields An object keyed on the friendly name of the value being
11
+ * parsed with the value being the format string of said value.
12
+ *
13
+ * Example:
14
+ *
15
+ * `const { args, parse } = createLogParser({ sha: '%H' })`
16
+ */
17
+ export function createLogParser(fields) {
18
+ const keys = Object.keys(fields);
19
+ const format = Object.values(fields).join('%x00');
20
+ const formatArgs = ['-z', `--format=${format}`];
21
+ const parse = (value) => {
22
+ const records = (Buffer.isBuffer(value) ? splitBuffer(value, '\0') : value.split('\0'));
23
+ const entries = [];
24
+ for (let i = 0; i < records.length - keys.length; i += keys.length) {
25
+ const entry = {};
26
+ keys.forEach((key, ix) => (entry[key] = records[i + ix]));
27
+ entries.push(entry);
28
+ }
29
+ return entries;
30
+ };
31
+ return { formatArgs, parse };
32
+ }
33
+ /**
34
+ * Create a new parser suitable for parsing --format output from commands such
35
+ * as `git for-each-ref`, `git branch`, and other commands that are not derived
36
+ * from `git log`.
37
+ *
38
+ * Returns an object with the arguments that need to be appended to the git
39
+ * call and the parse function itself
40
+ *
41
+ * @param fields An object keyed on the friendly name of the value being
42
+ * parsed with the value being the format string of said value.
43
+ *
44
+ * Example:
45
+ *
46
+ * `const { args, parse } = createForEachRefParser({ sha: '%(objectname)' })`
47
+ */
48
+ export function createForEachRefParser(fields) {
49
+ const keys = Object.keys(fields);
50
+ const format = Object.values(fields).join('%00');
51
+ const formatArgs = [`--format=%00${format}%00`];
52
+ const parse = (value) => {
53
+ const records = value.split('\0');
54
+ const entries = new Array();
55
+ let entry;
56
+ let consumed = 0;
57
+ // start at 1 to avoid 0 modulo X problem. The first record is guaranteed
58
+ // to be empty anyway (due to %00 at the start of --format)
59
+ for (let i = 1; i < records.length - 1; i++) {
60
+ if (i % (keys.length + 1) === 0) {
61
+ if (records[i] !== '\n') {
62
+ throw new Error('Expected newline');
63
+ }
64
+ continue;
65
+ }
66
+ entry = entry ?? {};
67
+ const key = keys[consumed % keys.length];
68
+ entry[key] = records[i];
69
+ consumed++;
70
+ if (consumed % keys.length === 0) {
71
+ entries.push(entry);
72
+ entry = undefined;
73
+ }
74
+ }
75
+ return entries;
76
+ };
77
+ return { formatArgs, parse };
78
+ }
79
+ //# sourceMappingURL=git-delimiter-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-delimiter-parser.js","sourceRoot":"","sources":["../../src/git/git-delimiter-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAmC,MAAS;IACzE,MAAM,IAAI,GAAmB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACjD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,YAAY,MAAM,EAAE,CAAC,CAAA;IAE/C,MAAM,KAAK,GAAG,CAA4B,KAAQ,EAAE,EAAE;QACpD,MAAM,OAAO,GAAG,CACd,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAC/D,CAAA;QACR,MAAM,OAAO,GAAG,EAAE,CAAA;QAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACnE,MAAM,KAAK,GAAG,EAA2B,CAAA;YACzC,IAAI,CAAC,OAAO,CAAC,CAAC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YACnD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;YACxC,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;YACvB,QAAQ,EAAE,CAAA;YAEV,IAAI,QAAQ,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACnB,KAAK,GAAG,SAAS,CAAA;YACnB,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAA;IAED,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Repository } from '../models/repository.js';
2
+ /**
3
+ * Read the contents of the repository .gitignore.
4
+ *
5
+ * Returns a promise which will either be rejected or resolved
6
+ * with the contents of the file. If there's no .gitignore file
7
+ * in the repository root the promise will resolve with null.
8
+ */
9
+ export declare function readGitIgnoreAtRoot(repository: Repository): Promise<string | null>;
10
+ /**
11
+ * Persist the given content to the repository root .gitignore.
12
+ *
13
+ * If the repository root doesn't contain a .gitignore file one
14
+ * will be created, otherwise the current file will be overwritten.
15
+ */
16
+ export declare function saveGitIgnore(repository: Repository, text: string): Promise<void>;
17
+ /** Add the given pattern or patterns to the root gitignore file */
18
+ export declare function appendIgnoreRule(repository: Repository, patterns: string | string[]): Promise<void>;
19
+ /**
20
+ * Convenience method to add the given file path(s) to the repository's gitignore.
21
+ *
22
+ * The file path will be escaped before adding.
23
+ */
24
+ export declare function appendIgnoreFile(repository: Repository, filePath: string | string[]): Promise<void>;
25
+ /** Escapes a string from special characters used in a gitignore file */
26
+ export declare function escapeGitSpecialCharacters(pattern: string): string;
@@ -0,0 +1,124 @@
1
+ import * as Path from 'path';
2
+ import * as FS from 'fs';
3
+ import { getConfigValue } from './config.js';
4
+ import { writeFile } from 'fs/promises';
5
+ /**
6
+ * Read the contents of the repository .gitignore.
7
+ *
8
+ * Returns a promise which will either be rejected or resolved
9
+ * with the contents of the file. If there's no .gitignore file
10
+ * in the repository root the promise will resolve with null.
11
+ */
12
+ export async function readGitIgnoreAtRoot(repository) {
13
+ const ignorePath = Path.join(repository.path, '.gitignore');
14
+ return new Promise((resolve, reject) => {
15
+ FS.readFile(ignorePath, 'utf8', (err, data) => {
16
+ if (err) {
17
+ if (err.code === 'ENOENT') {
18
+ resolve(null);
19
+ }
20
+ else {
21
+ reject(err);
22
+ }
23
+ }
24
+ else {
25
+ resolve(data);
26
+ }
27
+ });
28
+ });
29
+ }
30
+ /**
31
+ * Persist the given content to the repository root .gitignore.
32
+ *
33
+ * If the repository root doesn't contain a .gitignore file one
34
+ * will be created, otherwise the current file will be overwritten.
35
+ */
36
+ export async function saveGitIgnore(repository, text) {
37
+ const ignorePath = Path.join(repository.path, '.gitignore');
38
+ if (text === '') {
39
+ return new Promise((resolve, reject) => {
40
+ FS.unlink(ignorePath, err => {
41
+ if (err) {
42
+ reject(err);
43
+ }
44
+ else {
45
+ resolve();
46
+ }
47
+ });
48
+ });
49
+ }
50
+ const fileContents = await formatGitIgnoreContents(text, repository);
51
+ await writeFile(ignorePath, fileContents);
52
+ }
53
+ /** Add the given pattern or patterns to the root gitignore file */
54
+ export async function appendIgnoreRule(repository, patterns) {
55
+ const text = (await readGitIgnoreAtRoot(repository)) || '';
56
+ const currentContents = await formatGitIgnoreContents(text, repository);
57
+ const newPatternText = patterns instanceof Array ? patterns.join('\n') : patterns;
58
+ const newText = await formatGitIgnoreContents(`${currentContents}${newPatternText}`, repository);
59
+ await saveGitIgnore(repository, newText);
60
+ }
61
+ /**
62
+ * Convenience method to add the given file path(s) to the repository's gitignore.
63
+ *
64
+ * The file path will be escaped before adding.
65
+ */
66
+ export async function appendIgnoreFile(repository, filePath) {
67
+ if (filePath instanceof Array) {
68
+ const escapedFilePaths = filePath.map(path => escapeGitSpecialCharacters(path));
69
+ return appendIgnoreRule(repository, escapedFilePaths);
70
+ }
71
+ const escapedFilePath = escapeGitSpecialCharacters(filePath);
72
+ return appendIgnoreRule(repository, escapedFilePath);
73
+ }
74
+ /** Escapes a string from special characters used in a gitignore file */
75
+ export function escapeGitSpecialCharacters(pattern) {
76
+ const specialCharacters = /[\[\]!\*\#\?]/g;
77
+ return pattern.replaceAll(specialCharacters, match => {
78
+ return '\\' + match;
79
+ });
80
+ }
81
+ /**
82
+ * Format the gitignore text based on the current config settings.
83
+ *
84
+ * This setting looks at core.autocrlf to decide which line endings to use
85
+ * when updating the .gitignore file.
86
+ *
87
+ * If core.safecrlf is also set, adding this file to the index may cause
88
+ * Git to return a non-zero exit code, leaving the working directory in a
89
+ * confusing state for the user. So we should reformat the file in that
90
+ * case.
91
+ *
92
+ * @param text The text to format.
93
+ * @param repository The repository associated with the gitignore file.
94
+ */
95
+ async function formatGitIgnoreContents(text, repository) {
96
+ const autocrlf = await getConfigValue(repository, 'core.autocrlf');
97
+ const safecrlf = await getConfigValue(repository, 'core.safecrlf');
98
+ return new Promise((resolve, reject) => {
99
+ if (autocrlf === 'true' && safecrlf === 'true') {
100
+ // based off https://stackoverflow.com/a/141069/1363815
101
+ const normalizedText = text.replace(/\r\n|\n\r|\n|\r/g, '\r\n');
102
+ resolve(normalizedText + '\r\n');
103
+ return;
104
+ }
105
+ if (text === '' || text.endsWith('\n')) {
106
+ resolve(text);
107
+ return;
108
+ }
109
+ if (autocrlf == null) {
110
+ // fallback to Git default behaviour
111
+ resolve(`${text}\n`);
112
+ }
113
+ else {
114
+ const linesEndInCRLF = autocrlf === 'true';
115
+ if (linesEndInCRLF) {
116
+ resolve(`${text}\n`);
117
+ }
118
+ else {
119
+ resolve(`${text}\r\n`);
120
+ }
121
+ }
122
+ });
123
+ }
124
+ //# sourceMappingURL=gitignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitignore.js","sourceRoot":"","sources":["../../src/git/gitignore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAA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ACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ export * from './add.js';
2
+ export * from './apply.js';
3
+ export * from './branch.js';
4
+ export * from './checkout.js';
5
+ export * from './checkout-index.js';
6
+ export * from './cherry-pick.js';
7
+ export * from './clean.js';
8
+ export * from './clone.js';
9
+ export * from './commit.js';
10
+ export * from './config.js';
11
+ export * from './core.js';
12
+ export * from './description.js';
13
+ export * from './diff.js';
14
+ export * from './diff-index.js';
15
+ export * from './fetch.js';
16
+ export * from './for-each-ref.js';
17
+ export * from './format-patch.js';
18
+ export * from './gitignore.js';
19
+ export * from './init.js';
20
+ export * from './interpret-trailers.js';
21
+ export * from './lfs.js';
22
+ export * from './log.js';
23
+ export * from './merge.js';
24
+ export * from './merge-tree.js';
25
+ export * from './pull.js';
26
+ export * from './push.js';
27
+ export * from './rebase.js';
28
+ export * from './reflog.js';
29
+ export * from './refs.js';
30
+ export * from './remote.js';
31
+ export * from './reorder.js';
32
+ export * from './reset.js';
33
+ export * from './rev-list.js';
34
+ export * from './rev-parse.js';
35
+ export * from './rm.js';
36
+ export * from './squash.js';
37
+ export * from './stage.js';
38
+ export * from './stash.js';
39
+ export * from './status.js';
40
+ export * from './submodule.js';
41
+ export * from './tag.js';
42
+ export * from './update-index.js';
43
+ export * from './update-ref.js';
44
+ export * from './var.js';
45
+ export * from './worktree.js';
46
+ export * from './worktree-include.js';
@@ -0,0 +1,47 @@
1
+ export * from './add.js';
2
+ export * from './apply.js';
3
+ export * from './branch.js';
4
+ export * from './checkout.js';
5
+ export * from './checkout-index.js';
6
+ export * from './cherry-pick.js';
7
+ export * from './clean.js';
8
+ export * from './clone.js';
9
+ export * from './commit.js';
10
+ export * from './config.js';
11
+ export * from './core.js';
12
+ export * from './description.js';
13
+ export * from './diff.js';
14
+ export * from './diff-index.js';
15
+ export * from './fetch.js';
16
+ export * from './for-each-ref.js';
17
+ export * from './format-patch.js';
18
+ export * from './gitignore.js';
19
+ export * from './init.js';
20
+ export * from './interpret-trailers.js';
21
+ export * from './lfs.js';
22
+ export * from './log.js';
23
+ export * from './merge.js';
24
+ export * from './merge-tree.js';
25
+ export * from './pull.js';
26
+ export * from './push.js';
27
+ export * from './rebase.js';
28
+ export * from './reflog.js';
29
+ export * from './refs.js';
30
+ export * from './remote.js';
31
+ export * from './reorder.js';
32
+ export * from './reset.js';
33
+ export * from './rev-list.js';
34
+ export * from './rev-parse.js';
35
+ export * from './rm.js';
36
+ export * from './squash.js';
37
+ export * from './stage.js';
38
+ export * from './stash.js';
39
+ export * from './status.js';
40
+ export * from './submodule.js';
41
+ export * from './tag.js';
42
+ export * from './update-index.js';
43
+ export * from './update-ref.js';
44
+ export * from './var.js';
45
+ export * from './worktree.js';
46
+ export * from './worktree-include.js';
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,yBAAyB,CAAA;AACvC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,2 @@
1
+ /** Init a new git repository in the given path. */
2
+ export declare function initGitRepository(path: string): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import { getDefaultBranch } from '../lib/helpers/default-branch.js';
2
+ import { git } from './core.js';
3
+ /** Init a new git repository in the given path. */
4
+ export async function initGitRepository(path) {
5
+ await git(['-c', `init.defaultBranch=${await getDefaultBranch()}`, 'init'], path, 'initGitRepository');
6
+ }
7
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/git/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE/B,mDAAmD;AACnD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY;IAClD,MAAM,GAAG,CACP,CAAC,IAAI,EAAE,sBAAsB,MAAM,gBAAgB,EAAE,EAAE,EAAE,MAAM,CAAC,EAChE,IAAI,EACJ,mBAAmB,CACpB,CAAA;AACH,CAAC"}