plugin-agent-orchestrator 1.0.13 → 1.0.15

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 (255) hide show
  1. package/README.md +16 -291
  2. package/dist/client/AIEmployeesContext.d.ts +7 -0
  3. package/dist/client/OrchestratorSettings.d.ts +2 -1
  4. package/dist/client/index.js +1 -1
  5. package/dist/client/plugin.d.ts +1 -0
  6. package/dist/client/skill-hub/components/ExecutionHistory.d.ts +2 -0
  7. package/dist/client/skill-hub/components/ExecutionProgress.d.ts +20 -0
  8. package/dist/client/skill-hub/components/GitSkillImport.d.ts +7 -0
  9. package/dist/client/skill-hub/components/SkillEditor.d.ts +7 -0
  10. package/dist/client/skill-hub/components/SkillManager.d.ts +2 -0
  11. package/dist/client/skill-hub/components/SkillMetrics.d.ts +2 -0
  12. package/dist/client/skill-hub/components/SkillTestPanel.d.ts +7 -0
  13. package/dist/client/skill-hub/index.d.ts +10 -0
  14. package/dist/client/skill-hub/locale.d.ts +3 -0
  15. package/dist/client/skill-hub/tools/InteractionSchemasProvider.d.ts +19 -0
  16. package/dist/client/skill-hub/tools/SkillHubCard.d.ts +3 -0
  17. package/dist/client/skill-hub/utils/jsonFields.d.ts +3 -0
  18. package/dist/externalVersion.js +6 -6
  19. package/dist/node_modules/adm-zip/LICENSE +21 -0
  20. package/dist/node_modules/adm-zip/adm-zip.js +1 -0
  21. package/dist/node_modules/adm-zip/headers/entryHeader.js +377 -0
  22. package/dist/node_modules/adm-zip/headers/index.js +2 -0
  23. package/dist/node_modules/adm-zip/headers/mainHeader.js +130 -0
  24. package/dist/node_modules/adm-zip/methods/deflater.js +33 -0
  25. package/dist/node_modules/adm-zip/methods/index.js +3 -0
  26. package/dist/node_modules/adm-zip/methods/inflater.js +34 -0
  27. package/dist/node_modules/adm-zip/methods/zipcrypto.js +175 -0
  28. package/dist/node_modules/adm-zip/package.json +1 -0
  29. package/dist/node_modules/adm-zip/util/constants.js +142 -0
  30. package/dist/node_modules/adm-zip/util/decoder.js +5 -0
  31. package/dist/node_modules/adm-zip/util/errors.js +63 -0
  32. package/dist/node_modules/adm-zip/util/fattr.js +76 -0
  33. package/dist/node_modules/adm-zip/util/index.js +5 -0
  34. package/dist/node_modules/adm-zip/util/utils.js +339 -0
  35. package/dist/node_modules/adm-zip/zipEntry.js +405 -0
  36. package/dist/node_modules/adm-zip/zipFile.js +446 -0
  37. package/dist/node_modules/simple-git/dist/cjs/index.js +7399 -0
  38. package/dist/node_modules/simple-git/dist/esm/index.js +4745 -0
  39. package/dist/node_modules/simple-git/dist/esm/package.json +3 -0
  40. package/dist/node_modules/simple-git/dist/src/lib/api.d.ts +13 -0
  41. package/dist/node_modules/simple-git/dist/src/lib/args/log-format.d.ts +9 -0
  42. package/dist/node_modules/simple-git/dist/src/lib/errors/git-construct-error.d.ts +15 -0
  43. package/dist/node_modules/simple-git/dist/src/lib/errors/git-error.d.ts +30 -0
  44. package/dist/node_modules/simple-git/dist/src/lib/errors/git-plugin-error.d.ts +7 -0
  45. package/dist/node_modules/simple-git/dist/src/lib/errors/git-response-error.d.ts +32 -0
  46. package/dist/node_modules/simple-git/dist/src/lib/errors/task-configuration-error.d.ts +12 -0
  47. package/dist/node_modules/simple-git/dist/src/lib/git-factory.d.ts +15 -0
  48. package/dist/node_modules/simple-git/dist/src/lib/git-logger.d.ts +21 -0
  49. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch-delete.d.ts +5 -0
  50. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-branch.d.ts +2 -0
  51. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-commit.d.ts +2 -0
  52. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-diff-summary.d.ts +3 -0
  53. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-fetch.d.ts +2 -0
  54. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-list-log-summary.d.ts +6 -0
  55. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-merge.d.ts +11 -0
  56. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-move.d.ts +2 -0
  57. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-pull.d.ts +6 -0
  58. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-push.d.ts +4 -0
  59. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-messages.d.ts +5 -0
  60. package/dist/node_modules/simple-git/dist/src/lib/parsers/parse-remote-objects.d.ts +3 -0
  61. package/dist/node_modules/simple-git/dist/src/lib/plugins/abort-plugin.d.ts +3 -0
  62. package/dist/node_modules/simple-git/dist/src/lib/plugins/block-unsafe-operations-plugin.d.ts +3 -0
  63. package/dist/node_modules/simple-git/dist/src/lib/plugins/command-config-prefixing-plugin.d.ts +2 -0
  64. package/dist/node_modules/simple-git/dist/src/lib/plugins/completion-detection.plugin.d.ts +3 -0
  65. package/dist/node_modules/simple-git/dist/src/lib/plugins/custom-binary.plugin.d.ts +3 -0
  66. package/dist/node_modules/simple-git/dist/src/lib/plugins/error-detection.plugin.d.ts +7 -0
  67. package/dist/node_modules/simple-git/dist/src/lib/plugins/index.d.ts +11 -0
  68. package/dist/node_modules/simple-git/dist/src/lib/plugins/plugin-store.d.ts +11 -0
  69. package/dist/node_modules/simple-git/dist/src/lib/plugins/progress-monitor-plugin.d.ts +3 -0
  70. package/dist/node_modules/simple-git/dist/src/lib/plugins/simple-git-plugin.d.ts +48 -0
  71. package/dist/node_modules/simple-git/dist/src/lib/plugins/spawn-options-plugin.d.ts +3 -0
  72. package/dist/node_modules/simple-git/dist/src/lib/plugins/suffix-paths.plugin.d.ts +2 -0
  73. package/dist/node_modules/simple-git/dist/src/lib/plugins/timout-plugin.d.ts +3 -0
  74. package/dist/node_modules/simple-git/dist/src/lib/responses/BranchDeleteSummary.d.ts +12 -0
  75. package/dist/node_modules/simple-git/dist/src/lib/responses/BranchSummary.d.ts +14 -0
  76. package/dist/node_modules/simple-git/dist/src/lib/responses/CheckIgnore.d.ts +4 -0
  77. package/dist/node_modules/simple-git/dist/src/lib/responses/CleanSummary.d.ts +9 -0
  78. package/dist/node_modules/simple-git/dist/src/lib/responses/ConfigList.d.ts +13 -0
  79. package/dist/node_modules/simple-git/dist/src/lib/responses/DiffSummary.d.ts +10 -0
  80. package/dist/node_modules/simple-git/dist/src/lib/responses/FileStatusSummary.d.ts +9 -0
  81. package/dist/node_modules/simple-git/dist/src/lib/responses/GetRemoteSummary.d.ts +11 -0
  82. package/dist/node_modules/simple-git/dist/src/lib/responses/InitSummary.d.ts +9 -0
  83. package/dist/node_modules/simple-git/dist/src/lib/responses/MergeSummary.d.ts +16 -0
  84. package/dist/node_modules/simple-git/dist/src/lib/responses/PullSummary.d.ts +25 -0
  85. package/dist/node_modules/simple-git/dist/src/lib/responses/StatusSummary.d.ts +19 -0
  86. package/dist/node_modules/simple-git/dist/src/lib/responses/TagList.d.ts +7 -0
  87. package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor-chain.d.ts +25 -0
  88. package/dist/node_modules/simple-git/dist/src/lib/runners/git-executor.d.ts +14 -0
  89. package/dist/node_modules/simple-git/dist/src/lib/runners/promise-wrapped.d.ts +2 -0
  90. package/dist/node_modules/simple-git/dist/src/lib/runners/scheduler.d.ts +11 -0
  91. package/dist/node_modules/simple-git/dist/src/lib/runners/tasks-pending-queue.d.ts +23 -0
  92. package/dist/node_modules/simple-git/dist/src/lib/simple-git-api.d.ts +20 -0
  93. package/dist/node_modules/simple-git/dist/src/lib/task-callback.d.ts +2 -0
  94. package/dist/node_modules/simple-git/dist/src/lib/tasks/apply-patch.d.ts +3 -0
  95. package/dist/node_modules/simple-git/dist/src/lib/tasks/branch.d.ts +7 -0
  96. package/dist/node_modules/simple-git/dist/src/lib/tasks/change-working-directory.d.ts +2 -0
  97. package/dist/node_modules/simple-git/dist/src/lib/tasks/check-ignore.d.ts +2 -0
  98. package/dist/node_modules/simple-git/dist/src/lib/tasks/check-is-repo.d.ts +9 -0
  99. package/dist/node_modules/simple-git/dist/src/lib/tasks/checkout.d.ts +2 -0
  100. package/dist/node_modules/simple-git/dist/src/lib/tasks/clean.d.ts +25 -0
  101. package/dist/node_modules/simple-git/dist/src/lib/tasks/clone.d.ts +9 -0
  102. package/dist/node_modules/simple-git/dist/src/lib/tasks/commit.d.ts +4 -0
  103. package/dist/node_modules/simple-git/dist/src/lib/tasks/config.d.ts +8 -0
  104. package/dist/node_modules/simple-git/dist/src/lib/tasks/count-objects.d.ts +12 -0
  105. package/dist/node_modules/simple-git/dist/src/lib/tasks/diff-name-status.d.ts +12 -0
  106. package/dist/node_modules/simple-git/dist/src/lib/tasks/diff.d.ts +5 -0
  107. package/dist/node_modules/simple-git/dist/src/lib/tasks/fetch.d.ts +4 -0
  108. package/dist/node_modules/simple-git/dist/src/lib/tasks/first-commit.d.ts +2 -0
  109. package/dist/node_modules/simple-git/dist/src/lib/tasks/grep.d.ts +12 -0
  110. package/dist/node_modules/simple-git/dist/src/lib/tasks/hash-object.d.ts +5 -0
  111. package/dist/node_modules/simple-git/dist/src/lib/tasks/init.d.ts +3 -0
  112. package/dist/node_modules/simple-git/dist/src/lib/tasks/log.d.ts +32 -0
  113. package/dist/node_modules/simple-git/dist/src/lib/tasks/merge.d.ts +4 -0
  114. package/dist/node_modules/simple-git/dist/src/lib/tasks/move.d.ts +3 -0
  115. package/dist/node_modules/simple-git/dist/src/lib/tasks/pull.d.ts +3 -0
  116. package/dist/node_modules/simple-git/dist/src/lib/tasks/push.d.ts +9 -0
  117. package/dist/node_modules/simple-git/dist/src/lib/tasks/remote.d.ts +8 -0
  118. package/dist/node_modules/simple-git/dist/src/lib/tasks/reset.d.ts +11 -0
  119. package/dist/node_modules/simple-git/dist/src/lib/tasks/show.d.ts +2 -0
  120. package/dist/node_modules/simple-git/dist/src/lib/tasks/stash-list.d.ts +4 -0
  121. package/dist/node_modules/simple-git/dist/src/lib/tasks/status.d.ts +3 -0
  122. package/dist/node_modules/simple-git/dist/src/lib/tasks/sub-module.d.ts +5 -0
  123. package/dist/node_modules/simple-git/dist/src/lib/tasks/tag.d.ts +18 -0
  124. package/dist/node_modules/simple-git/dist/src/lib/tasks/task.d.ts +14 -0
  125. package/dist/node_modules/simple-git/dist/src/lib/tasks/version.d.ts +9 -0
  126. package/dist/node_modules/simple-git/dist/src/lib/types/handlers.d.ts +21 -0
  127. package/dist/node_modules/simple-git/dist/src/lib/types/index.d.ts +136 -0
  128. package/dist/node_modules/simple-git/dist/src/lib/types/tasks.d.ts +19 -0
  129. package/dist/node_modules/simple-git/dist/src/lib/utils/argument-filters.d.ts +14 -0
  130. package/dist/node_modules/simple-git/dist/src/lib/utils/exit-codes.d.ts +10 -0
  131. package/dist/node_modules/simple-git/dist/src/lib/utils/git-output-streams.d.ts +7 -0
  132. package/dist/node_modules/simple-git/dist/src/lib/utils/index.d.ts +8 -0
  133. package/dist/node_modules/simple-git/dist/src/lib/utils/line-parser.d.ts +15 -0
  134. package/dist/node_modules/simple-git/dist/src/lib/utils/simple-git-options.d.ts +2 -0
  135. package/dist/node_modules/simple-git/dist/src/lib/utils/task-options.d.ts +13 -0
  136. package/dist/node_modules/simple-git/dist/src/lib/utils/task-parser.d.ts +5 -0
  137. package/dist/node_modules/simple-git/dist/src/lib/utils/util.d.ts +47 -0
  138. package/dist/node_modules/simple-git/dist/typings/errors.d.ts +5 -0
  139. package/dist/node_modules/simple-git/dist/typings/index.d.ts +14 -0
  140. package/dist/node_modules/simple-git/dist/typings/response.d.ts +556 -0
  141. package/dist/node_modules/simple-git/dist/typings/simple-git.d.ts +1033 -0
  142. package/dist/node_modules/simple-git/dist/typings/types.d.ts +22 -0
  143. package/dist/node_modules/simple-git/node_modules/debug/package.json +64 -0
  144. package/dist/node_modules/simple-git/node_modules/debug/src/browser.js +272 -0
  145. package/dist/node_modules/simple-git/node_modules/debug/src/common.js +292 -0
  146. package/dist/node_modules/simple-git/node_modules/debug/src/index.js +10 -0
  147. package/dist/node_modules/simple-git/node_modules/debug/src/node.js +263 -0
  148. package/dist/node_modules/simple-git/package.json +1 -0
  149. package/dist/node_modules/simple-git/promise.js +17 -0
  150. package/dist/server/collections/agent-execution-spans.d.ts +9 -0
  151. package/dist/server/collections/agent-execution-spans.js +152 -0
  152. package/dist/server/collections/orchestrator-config.d.ts +1 -1
  153. package/dist/server/collections/orchestrator-config.js +6 -0
  154. package/dist/server/collections/orchestrator-logs.d.ts +1 -1
  155. package/dist/server/collections/skill-definitions.d.ts +2 -0
  156. package/dist/server/collections/skill-definitions.js +158 -0
  157. package/dist/server/collections/skill-executions.d.ts +2 -0
  158. package/dist/server/collections/skill-executions.js +123 -0
  159. package/dist/server/collections/skill-worker-configs.d.ts +2 -0
  160. package/dist/server/collections/skill-worker-configs.js +115 -0
  161. package/dist/server/migrations/20260423000000-add-progress-fields.d.ts +4 -0
  162. package/dist/server/migrations/20260423000000-add-progress-fields.js +69 -0
  163. package/dist/server/migrations/20260425000000-add-interaction-schema.d.ts +4 -0
  164. package/dist/server/migrations/20260425000000-add-interaction-schema.js +61 -0
  165. package/dist/server/migrations/20260427000000-change-packages-to-text.d.ts +4 -0
  166. package/dist/server/migrations/20260427000000-change-packages-to-text.js +70 -0
  167. package/dist/server/migrations/20260427000001-change-other-json-to-text.d.ts +4 -0
  168. package/dist/server/migrations/20260427000001-change-other-json-to-text.js +80 -0
  169. package/dist/server/migrations/20260429000000-add-llm-fields.js +8 -0
  170. package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.d.ts +16 -0
  171. package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.js +51 -0
  172. package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.d.ts +7 -0
  173. package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.js +57 -0
  174. package/dist/server/plugin.d.ts +3 -0
  175. package/dist/server/plugin.js +37 -1
  176. package/dist/server/resources/tracing.js +154 -11
  177. package/dist/server/services/CodeValidator.d.ts +32 -0
  178. package/dist/server/services/CodeValidator.js +206 -0
  179. package/dist/server/services/ExecutionSpanService.d.ts +44 -0
  180. package/dist/server/services/ExecutionSpanService.js +104 -0
  181. package/dist/server/services/FileManager.d.ts +28 -0
  182. package/dist/server/services/FileManager.js +151 -0
  183. package/dist/server/services/SandboxRunner.d.ts +41 -0
  184. package/dist/server/services/SandboxRunner.js +167 -0
  185. package/dist/server/services/SkillManager.d.ts +6 -0
  186. package/dist/server/services/SkillManager.js +640 -0
  187. package/dist/server/services/SkillRepositoryService.d.ts +22 -0
  188. package/dist/server/services/SkillRepositoryService.js +157 -0
  189. package/dist/server/services/WorkerEnvManager.d.ts +26 -0
  190. package/dist/server/services/WorkerEnvManager.js +120 -0
  191. package/dist/server/skill-hub/actions/git-import.d.ts +21 -0
  192. package/dist/server/skill-hub/actions/git-import.js +413 -0
  193. package/dist/server/skill-hub/mcp/McpController.d.ts +15 -0
  194. package/dist/server/skill-hub/mcp/McpController.js +111 -0
  195. package/dist/server/skill-hub/plugin.d.ts +58 -0
  196. package/dist/server/skill-hub/plugin.js +694 -0
  197. package/dist/server/skill-hub/sandbox-config.json +6 -0
  198. package/dist/server/skill-hub/tasks/SkillExecutionTask.d.ts +16 -0
  199. package/dist/server/skill-hub/tasks/SkillExecutionTask.js +389 -0
  200. package/dist/server/skill-hub/utils/json-fields.d.ts +7 -0
  201. package/dist/server/skill-hub/utils/json-fields.js +88 -0
  202. package/dist/server/tools/delegate-task.d.ts +4 -0
  203. package/dist/server/tools/delegate-task.js +606 -104
  204. package/dist/server/tools/skill-execute.d.ts +36 -0
  205. package/dist/server/tools/skill-execute.js +167 -0
  206. package/package.json +3 -1
  207. package/src/client/AIEmployeeSelect.tsx +1 -3
  208. package/src/client/AIEmployeesContext.tsx +28 -13
  209. package/src/client/OrchestratorSettings.tsx +43 -5
  210. package/src/client/RulesTab.tsx +253 -32
  211. package/src/client/TracingTab.tsx +277 -213
  212. package/src/client/index.tsx +1 -1
  213. package/src/client/plugin.tsx +54 -15
  214. package/src/client/skill-hub/components/ExecutionHistory.tsx +201 -0
  215. package/src/client/skill-hub/components/ExecutionProgress.tsx +55 -0
  216. package/src/client/skill-hub/components/GitSkillImport.tsx +555 -0
  217. package/src/client/skill-hub/components/SkillEditor.tsx +456 -0
  218. package/src/client/skill-hub/components/SkillManager.tsx +181 -0
  219. package/src/client/skill-hub/components/SkillMetrics.tsx +124 -0
  220. package/src/client/skill-hub/components/SkillTestPanel.tsx +144 -0
  221. package/src/client/skill-hub/index.tsx +75 -0
  222. package/src/client/skill-hub/locale.ts +16 -0
  223. package/src/client/skill-hub/tools/InteractionSchemasProvider.tsx +59 -0
  224. package/src/client/skill-hub/tools/SkillHubCard.tsx +78 -0
  225. package/src/client/skill-hub/utils/jsonFields.ts +37 -0
  226. package/src/server/collections/agent-execution-spans.ts +129 -0
  227. package/src/server/collections/orchestrator-config.ts +7 -0
  228. package/src/server/collections/skill-definitions.ts +128 -0
  229. package/src/server/collections/skill-executions.ts +94 -0
  230. package/src/server/collections/skill-worker-configs.ts +86 -0
  231. package/src/server/migrations/20260423000000-add-progress-fields.ts +50 -0
  232. package/src/server/migrations/20260425000000-add-interaction-schema.ts +35 -0
  233. package/src/server/migrations/20260427000000-add-tracing-detail-fields.ts +5 -5
  234. package/src/server/migrations/20260427000000-change-packages-to-text.ts +47 -0
  235. package/src/server/migrations/20260427000001-change-other-json-to-text.ts +57 -0
  236. package/src/server/migrations/20260429000000-add-llm-fields.ts +11 -2
  237. package/src/server/migrations/20260429000000-fix-inputargs-json-to-text.ts +38 -0
  238. package/src/server/migrations/20260503000000-add-orchestrator-trace-fields.ts +32 -0
  239. package/src/server/plugin.ts +94 -46
  240. package/src/server/resources/tracing.ts +182 -15
  241. package/src/server/services/CodeValidator.ts +159 -0
  242. package/src/server/services/ExecutionSpanService.ts +106 -0
  243. package/src/server/services/FileManager.ts +144 -0
  244. package/src/server/services/SandboxRunner.ts +205 -0
  245. package/src/server/services/SkillManager.ts +623 -0
  246. package/src/server/services/SkillRepositoryService.ts +142 -0
  247. package/src/server/services/WorkerEnvManager.ts +113 -0
  248. package/src/server/skill-hub/actions/git-import.ts +486 -0
  249. package/src/server/skill-hub/mcp/McpController.ts +86 -0
  250. package/src/server/skill-hub/plugin.ts +771 -0
  251. package/src/server/skill-hub/sandbox-config.json +6 -0
  252. package/src/server/skill-hub/tasks/SkillExecutionTask.ts +443 -0
  253. package/src/server/skill-hub/utils/json-fields.ts +57 -0
  254. package/src/server/tools/delegate-task.ts +803 -127
  255. package/src/server/tools/skill-execute.ts +157 -0
@@ -0,0 +1,4745 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __esm = (fn, res) => function __init() {
6
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
+ };
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+
25
+ // src/lib/errors/git-error.ts
26
+ var GitError;
27
+ var init_git_error = __esm({
28
+ "src/lib/errors/git-error.ts"() {
29
+ "use strict";
30
+ GitError = class extends Error {
31
+ constructor(task, message) {
32
+ super(message);
33
+ this.task = task;
34
+ Object.setPrototypeOf(this, new.target.prototype);
35
+ }
36
+ };
37
+ }
38
+ });
39
+
40
+ // src/lib/errors/git-response-error.ts
41
+ var GitResponseError;
42
+ var init_git_response_error = __esm({
43
+ "src/lib/errors/git-response-error.ts"() {
44
+ "use strict";
45
+ init_git_error();
46
+ GitResponseError = class extends GitError {
47
+ constructor(git, message) {
48
+ super(void 0, message || String(git));
49
+ this.git = git;
50
+ }
51
+ };
52
+ }
53
+ });
54
+
55
+ // src/lib/errors/task-configuration-error.ts
56
+ var TaskConfigurationError;
57
+ var init_task_configuration_error = __esm({
58
+ "src/lib/errors/task-configuration-error.ts"() {
59
+ "use strict";
60
+ init_git_error();
61
+ TaskConfigurationError = class extends GitError {
62
+ constructor(message) {
63
+ super(void 0, message);
64
+ }
65
+ };
66
+ }
67
+ });
68
+
69
+ // src/lib/utils/util.ts
70
+ import { exists, FOLDER } from "@kwsites/file-exists";
71
+ function asFunction(source) {
72
+ if (typeof source !== "function") {
73
+ return NOOP;
74
+ }
75
+ return source;
76
+ }
77
+ function isUserFunction(source) {
78
+ return typeof source === "function" && source !== NOOP;
79
+ }
80
+ function splitOn(input, char) {
81
+ const index = input.indexOf(char);
82
+ if (index <= 0) {
83
+ return [input, ""];
84
+ }
85
+ return [input.substr(0, index), input.substr(index + 1)];
86
+ }
87
+ function first(input, offset = 0) {
88
+ return isArrayLike(input) && input.length > offset ? input[offset] : void 0;
89
+ }
90
+ function last(input, offset = 0) {
91
+ if (isArrayLike(input) && input.length > offset) {
92
+ return input[input.length - 1 - offset];
93
+ }
94
+ }
95
+ function isArrayLike(input) {
96
+ return filterHasLength(input);
97
+ }
98
+ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
99
+ return input.split(separator).reduce((output, line) => {
100
+ const lineContent = trimmed2 ? line.trim() : line;
101
+ if (lineContent) {
102
+ output.push(lineContent);
103
+ }
104
+ return output;
105
+ }, []);
106
+ }
107
+ function forEachLineWithContent(input, callback) {
108
+ return toLinesWithContent(input, true).map((line) => callback(line));
109
+ }
110
+ function folderExists(path) {
111
+ return exists(path, FOLDER);
112
+ }
113
+ function append(target, item) {
114
+ if (Array.isArray(target)) {
115
+ if (!target.includes(item)) {
116
+ target.push(item);
117
+ }
118
+ } else {
119
+ target.add(item);
120
+ }
121
+ return item;
122
+ }
123
+ function including(target, item) {
124
+ if (Array.isArray(target) && !target.includes(item)) {
125
+ target.push(item);
126
+ }
127
+ return target;
128
+ }
129
+ function remove(target, item) {
130
+ if (Array.isArray(target)) {
131
+ const index = target.indexOf(item);
132
+ if (index >= 0) {
133
+ target.splice(index, 1);
134
+ }
135
+ } else {
136
+ target.delete(item);
137
+ }
138
+ return item;
139
+ }
140
+ function asArray(source) {
141
+ return Array.isArray(source) ? source : [source];
142
+ }
143
+ function asCamelCase(str) {
144
+ return str.replace(/[\s-]+(.)/g, (_all, chr) => {
145
+ return chr.toUpperCase();
146
+ });
147
+ }
148
+ function asStringArray(source) {
149
+ return asArray(source).map((item) => {
150
+ return item instanceof String ? item : String(item);
151
+ });
152
+ }
153
+ function asNumber(source, onNaN = 0) {
154
+ if (source == null) {
155
+ return onNaN;
156
+ }
157
+ const num = parseInt(source, 10);
158
+ return Number.isNaN(num) ? onNaN : num;
159
+ }
160
+ function prefixedArray(input, prefix) {
161
+ const output = [];
162
+ for (let i = 0, max = input.length; i < max; i++) {
163
+ output.push(prefix, input[i]);
164
+ }
165
+ return output;
166
+ }
167
+ function bufferToString(input) {
168
+ return (Array.isArray(input) ? Buffer.concat(input) : input).toString("utf-8");
169
+ }
170
+ function pick(source, properties) {
171
+ const out = {};
172
+ properties.forEach((key) => {
173
+ if (source[key] !== void 0) {
174
+ out[key] = source[key];
175
+ }
176
+ });
177
+ return out;
178
+ }
179
+ function delay(duration = 0) {
180
+ return new Promise((done) => setTimeout(done, duration));
181
+ }
182
+ function orVoid(input) {
183
+ if (input === false) {
184
+ return void 0;
185
+ }
186
+ return input;
187
+ }
188
+ var NULL, NOOP, objectToString;
189
+ var init_util = __esm({
190
+ "src/lib/utils/util.ts"() {
191
+ "use strict";
192
+ init_argument_filters();
193
+ NULL = "\0";
194
+ NOOP = () => {
195
+ };
196
+ objectToString = Object.prototype.toString.call.bind(Object.prototype.toString);
197
+ }
198
+ });
199
+
200
+ // src/lib/utils/argument-filters.ts
201
+ import { isPathSpec } from "@simple-git/args-pathspec";
202
+ function filterType(input, filter, def) {
203
+ if (filter(input)) {
204
+ return input;
205
+ }
206
+ return arguments.length > 2 ? def : void 0;
207
+ }
208
+ function filterPrimitives(input, omit) {
209
+ const type = isPathSpec(input) ? "string" : typeof input;
210
+ return /number|string|boolean/.test(type) && (!omit || !omit.includes(type));
211
+ }
212
+ function filterPlainObject(input) {
213
+ return !!input && objectToString(input) === "[object Object]";
214
+ }
215
+ function filterFunction(input) {
216
+ return typeof input === "function";
217
+ }
218
+ var filterArray, filterNumber, filterString, filterStringOrStringArray, filterHasLength;
219
+ var init_argument_filters = __esm({
220
+ "src/lib/utils/argument-filters.ts"() {
221
+ "use strict";
222
+ init_util();
223
+ filterArray = (input) => {
224
+ return Array.isArray(input);
225
+ };
226
+ filterNumber = (input) => {
227
+ return typeof input === "number";
228
+ };
229
+ filterString = (input) => {
230
+ return typeof input === "string" || isPathSpec(input);
231
+ };
232
+ filterStringOrStringArray = (input) => {
233
+ return filterString(input) || Array.isArray(input) && input.every(filterString);
234
+ };
235
+ filterHasLength = (input) => {
236
+ if (input == null || "number|boolean|function".includes(typeof input)) {
237
+ return false;
238
+ }
239
+ return typeof input.length === "number";
240
+ };
241
+ }
242
+ });
243
+
244
+ // src/lib/utils/exit-codes.ts
245
+ var ExitCodes;
246
+ var init_exit_codes = __esm({
247
+ "src/lib/utils/exit-codes.ts"() {
248
+ "use strict";
249
+ ExitCodes = /* @__PURE__ */ ((ExitCodes2) => {
250
+ ExitCodes2[ExitCodes2["SUCCESS"] = 0] = "SUCCESS";
251
+ ExitCodes2[ExitCodes2["ERROR"] = 1] = "ERROR";
252
+ ExitCodes2[ExitCodes2["NOT_FOUND"] = -2] = "NOT_FOUND";
253
+ ExitCodes2[ExitCodes2["UNCLEAN"] = 128] = "UNCLEAN";
254
+ return ExitCodes2;
255
+ })(ExitCodes || {});
256
+ }
257
+ });
258
+
259
+ // src/lib/utils/git-output-streams.ts
260
+ var GitOutputStreams;
261
+ var init_git_output_streams = __esm({
262
+ "src/lib/utils/git-output-streams.ts"() {
263
+ "use strict";
264
+ GitOutputStreams = class _GitOutputStreams {
265
+ constructor(stdOut, stdErr) {
266
+ this.stdOut = stdOut;
267
+ this.stdErr = stdErr;
268
+ }
269
+ asStrings() {
270
+ return new _GitOutputStreams(this.stdOut.toString("utf8"), this.stdErr.toString("utf8"));
271
+ }
272
+ };
273
+ }
274
+ });
275
+
276
+ // src/lib/utils/line-parser.ts
277
+ function useMatchesDefault() {
278
+ throw new Error(`LineParser:useMatches not implemented`);
279
+ }
280
+ var LineParser, RemoteLineParser;
281
+ var init_line_parser = __esm({
282
+ "src/lib/utils/line-parser.ts"() {
283
+ "use strict";
284
+ LineParser = class {
285
+ constructor(regExp, useMatches) {
286
+ this.matches = [];
287
+ this.useMatches = useMatchesDefault;
288
+ this.parse = (line, target) => {
289
+ this.resetMatches();
290
+ if (!this._regExp.every((reg, index) => this.addMatch(reg, index, line(index)))) {
291
+ return false;
292
+ }
293
+ return this.useMatches(target, this.prepareMatches()) !== false;
294
+ };
295
+ this._regExp = Array.isArray(regExp) ? regExp : [regExp];
296
+ if (useMatches) {
297
+ this.useMatches = useMatches;
298
+ }
299
+ }
300
+ resetMatches() {
301
+ this.matches.length = 0;
302
+ }
303
+ prepareMatches() {
304
+ return this.matches;
305
+ }
306
+ addMatch(reg, index, line) {
307
+ const matched = line && reg.exec(line);
308
+ if (matched) {
309
+ this.pushMatch(index, matched);
310
+ }
311
+ return !!matched;
312
+ }
313
+ pushMatch(_index, matched) {
314
+ this.matches.push(...matched.slice(1));
315
+ }
316
+ };
317
+ RemoteLineParser = class extends LineParser {
318
+ addMatch(reg, index, line) {
319
+ return /^remote:\s/.test(String(line)) && super.addMatch(reg, index, line);
320
+ }
321
+ pushMatch(index, matched) {
322
+ if (index > 0 || matched.length > 1) {
323
+ super.pushMatch(index, matched);
324
+ }
325
+ }
326
+ };
327
+ }
328
+ });
329
+
330
+ // src/lib/utils/simple-git-options.ts
331
+ function createInstanceConfig(...options) {
332
+ const baseDir = process.cwd();
333
+ const config = Object.assign(
334
+ { baseDir, ...defaultOptions },
335
+ ...options.filter((o) => typeof o === "object" && o)
336
+ );
337
+ config.baseDir = config.baseDir || baseDir;
338
+ config.trimmed = config.trimmed === true;
339
+ return config;
340
+ }
341
+ var defaultOptions;
342
+ var init_simple_git_options = __esm({
343
+ "src/lib/utils/simple-git-options.ts"() {
344
+ "use strict";
345
+ defaultOptions = {
346
+ binary: "git",
347
+ maxConcurrentProcesses: 5,
348
+ config: [],
349
+ trimmed: false
350
+ };
351
+ }
352
+ });
353
+
354
+ // src/lib/utils/task-options.ts
355
+ import { isPathSpec as isPathSpec2 } from "@simple-git/args-pathspec";
356
+ function appendTaskOptions(options, commands = []) {
357
+ if (!filterPlainObject(options)) {
358
+ return commands;
359
+ }
360
+ return Object.keys(options).reduce((commands2, key) => {
361
+ const value = options[key];
362
+ if (isPathSpec2(value)) {
363
+ commands2.push(value);
364
+ } else if (filterPrimitives(value, ["boolean"])) {
365
+ commands2.push(key + "=" + value);
366
+ } else if (Array.isArray(value)) {
367
+ for (const v of value) {
368
+ if (!filterPrimitives(v, ["string", "number"])) {
369
+ commands2.push(key + "=" + v);
370
+ }
371
+ }
372
+ } else {
373
+ commands2.push(key);
374
+ }
375
+ return commands2;
376
+ }, commands);
377
+ }
378
+ function getTrailingOptions(args, initialPrimitive = 0, objectOnly = false) {
379
+ const command = [];
380
+ for (let i = 0, max = initialPrimitive < 0 ? args.length : initialPrimitive; i < max; i++) {
381
+ if ("string|number".includes(typeof args[i])) {
382
+ command.push(String(args[i]));
383
+ }
384
+ }
385
+ appendTaskOptions(trailingOptionsArgument(args), command);
386
+ if (!objectOnly) {
387
+ command.push(...trailingArrayArgument(args));
388
+ }
389
+ return command;
390
+ }
391
+ function trailingArrayArgument(args) {
392
+ const hasTrailingCallback = typeof last(args) === "function";
393
+ return asStringArray(filterType(last(args, hasTrailingCallback ? 1 : 0), filterArray, []));
394
+ }
395
+ function trailingOptionsArgument(args) {
396
+ const hasTrailingCallback = filterFunction(last(args));
397
+ return filterType(last(args, hasTrailingCallback ? 1 : 0), filterPlainObject);
398
+ }
399
+ function trailingFunctionArgument(args, includeNoop = true) {
400
+ const callback = asFunction(last(args));
401
+ return includeNoop || isUserFunction(callback) ? callback : void 0;
402
+ }
403
+ var init_task_options = __esm({
404
+ "src/lib/utils/task-options.ts"() {
405
+ "use strict";
406
+ init_argument_filters();
407
+ init_util();
408
+ }
409
+ });
410
+
411
+ // src/lib/utils/task-parser.ts
412
+ function callTaskParser(parser4, streams) {
413
+ return parser4(streams.stdOut, streams.stdErr);
414
+ }
415
+ function parseStringResponse(result, parsers12, texts, trim = true) {
416
+ asArray(texts).forEach((text) => {
417
+ for (let lines = toLinesWithContent(text, trim), i = 0, max = lines.length; i < max; i++) {
418
+ const line = (offset = 0) => {
419
+ if (i + offset >= max) {
420
+ return;
421
+ }
422
+ return lines[i + offset];
423
+ };
424
+ parsers12.some(({ parse }) => parse(line, result));
425
+ }
426
+ });
427
+ return result;
428
+ }
429
+ var init_task_parser = __esm({
430
+ "src/lib/utils/task-parser.ts"() {
431
+ "use strict";
432
+ init_util();
433
+ }
434
+ });
435
+
436
+ // src/lib/utils/index.ts
437
+ var utils_exports = {};
438
+ __export(utils_exports, {
439
+ ExitCodes: () => ExitCodes,
440
+ GitOutputStreams: () => GitOutputStreams,
441
+ LineParser: () => LineParser,
442
+ NOOP: () => NOOP,
443
+ NULL: () => NULL,
444
+ RemoteLineParser: () => RemoteLineParser,
445
+ append: () => append,
446
+ appendTaskOptions: () => appendTaskOptions,
447
+ asArray: () => asArray,
448
+ asCamelCase: () => asCamelCase,
449
+ asFunction: () => asFunction,
450
+ asNumber: () => asNumber,
451
+ asStringArray: () => asStringArray,
452
+ bufferToString: () => bufferToString,
453
+ callTaskParser: () => callTaskParser,
454
+ createInstanceConfig: () => createInstanceConfig,
455
+ delay: () => delay,
456
+ filterArray: () => filterArray,
457
+ filterFunction: () => filterFunction,
458
+ filterHasLength: () => filterHasLength,
459
+ filterNumber: () => filterNumber,
460
+ filterPlainObject: () => filterPlainObject,
461
+ filterPrimitives: () => filterPrimitives,
462
+ filterString: () => filterString,
463
+ filterStringOrStringArray: () => filterStringOrStringArray,
464
+ filterType: () => filterType,
465
+ first: () => first,
466
+ folderExists: () => folderExists,
467
+ forEachLineWithContent: () => forEachLineWithContent,
468
+ getTrailingOptions: () => getTrailingOptions,
469
+ including: () => including,
470
+ isUserFunction: () => isUserFunction,
471
+ last: () => last,
472
+ objectToString: () => objectToString,
473
+ orVoid: () => orVoid,
474
+ parseStringResponse: () => parseStringResponse,
475
+ pick: () => pick,
476
+ prefixedArray: () => prefixedArray,
477
+ remove: () => remove,
478
+ splitOn: () => splitOn,
479
+ toLinesWithContent: () => toLinesWithContent,
480
+ trailingFunctionArgument: () => trailingFunctionArgument,
481
+ trailingOptionsArgument: () => trailingOptionsArgument
482
+ });
483
+ var init_utils = __esm({
484
+ "src/lib/utils/index.ts"() {
485
+ "use strict";
486
+ init_argument_filters();
487
+ init_exit_codes();
488
+ init_git_output_streams();
489
+ init_line_parser();
490
+ init_simple_git_options();
491
+ init_task_options();
492
+ init_task_parser();
493
+ init_util();
494
+ }
495
+ });
496
+
497
+ // src/lib/tasks/check-is-repo.ts
498
+ var check_is_repo_exports = {};
499
+ __export(check_is_repo_exports, {
500
+ CheckRepoActions: () => CheckRepoActions,
501
+ checkIsBareRepoTask: () => checkIsBareRepoTask,
502
+ checkIsRepoRootTask: () => checkIsRepoRootTask,
503
+ checkIsRepoTask: () => checkIsRepoTask
504
+ });
505
+ function checkIsRepoTask(action) {
506
+ switch (action) {
507
+ case "bare" /* BARE */:
508
+ return checkIsBareRepoTask();
509
+ case "root" /* IS_REPO_ROOT */:
510
+ return checkIsRepoRootTask();
511
+ }
512
+ const commands = ["rev-parse", "--is-inside-work-tree"];
513
+ return {
514
+ commands,
515
+ format: "utf-8",
516
+ onError,
517
+ parser
518
+ };
519
+ }
520
+ function checkIsRepoRootTask() {
521
+ const commands = ["rev-parse", "--git-dir"];
522
+ return {
523
+ commands,
524
+ format: "utf-8",
525
+ onError,
526
+ parser(path) {
527
+ return /^\.(git)?$/.test(path.trim());
528
+ }
529
+ };
530
+ }
531
+ function checkIsBareRepoTask() {
532
+ const commands = ["rev-parse", "--is-bare-repository"];
533
+ return {
534
+ commands,
535
+ format: "utf-8",
536
+ onError,
537
+ parser
538
+ };
539
+ }
540
+ function isNotRepoMessage(error) {
541
+ return /(Not a git repository|Kein Git-Repository)/i.test(String(error));
542
+ }
543
+ var CheckRepoActions, onError, parser;
544
+ var init_check_is_repo = __esm({
545
+ "src/lib/tasks/check-is-repo.ts"() {
546
+ "use strict";
547
+ init_utils();
548
+ CheckRepoActions = /* @__PURE__ */ ((CheckRepoActions2) => {
549
+ CheckRepoActions2["BARE"] = "bare";
550
+ CheckRepoActions2["IN_TREE"] = "tree";
551
+ CheckRepoActions2["IS_REPO_ROOT"] = "root";
552
+ return CheckRepoActions2;
553
+ })(CheckRepoActions || {});
554
+ onError = ({ exitCode }, error, done, fail) => {
555
+ if (exitCode === 128 /* UNCLEAN */ && isNotRepoMessage(error)) {
556
+ return done(Buffer.from("false"));
557
+ }
558
+ fail(error);
559
+ };
560
+ parser = (text) => {
561
+ return text.trim() === "true";
562
+ };
563
+ }
564
+ });
565
+
566
+ // src/lib/responses/CleanSummary.ts
567
+ function cleanSummaryParser(dryRun, text) {
568
+ const summary = new CleanResponse(dryRun);
569
+ const regexp = dryRun ? dryRunRemovalRegexp : removalRegexp;
570
+ toLinesWithContent(text).forEach((line) => {
571
+ const removed = line.replace(regexp, "");
572
+ summary.paths.push(removed);
573
+ (isFolderRegexp.test(removed) ? summary.folders : summary.files).push(removed);
574
+ });
575
+ return summary;
576
+ }
577
+ var CleanResponse, removalRegexp, dryRunRemovalRegexp, isFolderRegexp;
578
+ var init_CleanSummary = __esm({
579
+ "src/lib/responses/CleanSummary.ts"() {
580
+ "use strict";
581
+ init_utils();
582
+ CleanResponse = class {
583
+ constructor(dryRun) {
584
+ this.dryRun = dryRun;
585
+ this.paths = [];
586
+ this.files = [];
587
+ this.folders = [];
588
+ }
589
+ };
590
+ removalRegexp = /^[a-z]+\s*/i;
591
+ dryRunRemovalRegexp = /^[a-z]+\s+[a-z]+\s*/i;
592
+ isFolderRegexp = /\/$/;
593
+ }
594
+ });
595
+
596
+ // src/lib/tasks/task.ts
597
+ var task_exports = {};
598
+ __export(task_exports, {
599
+ EMPTY_COMMANDS: () => EMPTY_COMMANDS,
600
+ adhocExecTask: () => adhocExecTask,
601
+ configurationErrorTask: () => configurationErrorTask,
602
+ isBufferTask: () => isBufferTask,
603
+ isEmptyTask: () => isEmptyTask,
604
+ straightThroughBufferTask: () => straightThroughBufferTask,
605
+ straightThroughStringTask: () => straightThroughStringTask
606
+ });
607
+ function adhocExecTask(parser4) {
608
+ return {
609
+ commands: EMPTY_COMMANDS,
610
+ format: "empty",
611
+ parser: parser4
612
+ };
613
+ }
614
+ function configurationErrorTask(error) {
615
+ return {
616
+ commands: EMPTY_COMMANDS,
617
+ format: "empty",
618
+ parser() {
619
+ throw typeof error === "string" ? new TaskConfigurationError(error) : error;
620
+ }
621
+ };
622
+ }
623
+ function straightThroughStringTask(commands, trimmed2 = false) {
624
+ return {
625
+ commands,
626
+ format: "utf-8",
627
+ parser(text) {
628
+ return trimmed2 ? String(text).trim() : text;
629
+ }
630
+ };
631
+ }
632
+ function straightThroughBufferTask(commands) {
633
+ return {
634
+ commands,
635
+ format: "buffer",
636
+ parser(buffer) {
637
+ return buffer;
638
+ }
639
+ };
640
+ }
641
+ function isBufferTask(task) {
642
+ return task.format === "buffer";
643
+ }
644
+ function isEmptyTask(task) {
645
+ return task.format === "empty" || !task.commands.length;
646
+ }
647
+ var EMPTY_COMMANDS;
648
+ var init_task = __esm({
649
+ "src/lib/tasks/task.ts"() {
650
+ "use strict";
651
+ init_task_configuration_error();
652
+ EMPTY_COMMANDS = [];
653
+ }
654
+ });
655
+
656
+ // src/lib/tasks/clean.ts
657
+ var clean_exports = {};
658
+ __export(clean_exports, {
659
+ CONFIG_ERROR_INTERACTIVE_MODE: () => CONFIG_ERROR_INTERACTIVE_MODE,
660
+ CONFIG_ERROR_MODE_REQUIRED: () => CONFIG_ERROR_MODE_REQUIRED,
661
+ CONFIG_ERROR_UNKNOWN_OPTION: () => CONFIG_ERROR_UNKNOWN_OPTION,
662
+ CleanOptions: () => CleanOptions,
663
+ cleanTask: () => cleanTask,
664
+ cleanWithOptionsTask: () => cleanWithOptionsTask,
665
+ isCleanOptionsArray: () => isCleanOptionsArray
666
+ });
667
+ function cleanWithOptionsTask(mode, customArgs) {
668
+ const { cleanMode, options, valid } = getCleanOptions(mode);
669
+ if (!cleanMode) {
670
+ return configurationErrorTask(CONFIG_ERROR_MODE_REQUIRED);
671
+ }
672
+ if (!valid.options) {
673
+ return configurationErrorTask(CONFIG_ERROR_UNKNOWN_OPTION + JSON.stringify(mode));
674
+ }
675
+ options.push(...customArgs);
676
+ if (options.some(isInteractiveMode)) {
677
+ return configurationErrorTask(CONFIG_ERROR_INTERACTIVE_MODE);
678
+ }
679
+ return cleanTask(cleanMode, options);
680
+ }
681
+ function cleanTask(mode, customArgs) {
682
+ const commands = ["clean", `-${mode}`, ...customArgs];
683
+ return {
684
+ commands,
685
+ format: "utf-8",
686
+ parser(text) {
687
+ return cleanSummaryParser(mode === "n" /* DRY_RUN */, text);
688
+ }
689
+ };
690
+ }
691
+ function isCleanOptionsArray(input) {
692
+ return Array.isArray(input) && input.every((test) => CleanOptionValues.has(test));
693
+ }
694
+ function getCleanOptions(input) {
695
+ let cleanMode;
696
+ let options = [];
697
+ let valid = { cleanMode: false, options: true };
698
+ input.replace(/[^a-z]i/g, "").split("").forEach((char) => {
699
+ if (isCleanMode(char)) {
700
+ cleanMode = char;
701
+ valid.cleanMode = true;
702
+ } else {
703
+ valid.options = valid.options && isKnownOption(options[options.length] = `-${char}`);
704
+ }
705
+ });
706
+ return {
707
+ cleanMode,
708
+ options,
709
+ valid
710
+ };
711
+ }
712
+ function isCleanMode(cleanMode) {
713
+ return cleanMode === "f" /* FORCE */ || cleanMode === "n" /* DRY_RUN */;
714
+ }
715
+ function isKnownOption(option) {
716
+ return /^-[a-z]$/i.test(option) && CleanOptionValues.has(option.charAt(1));
717
+ }
718
+ function isInteractiveMode(option) {
719
+ if (/^-[^\-]/.test(option)) {
720
+ return option.indexOf("i") > 0;
721
+ }
722
+ return option === "--interactive";
723
+ }
724
+ var CONFIG_ERROR_INTERACTIVE_MODE, CONFIG_ERROR_MODE_REQUIRED, CONFIG_ERROR_UNKNOWN_OPTION, CleanOptions, CleanOptionValues;
725
+ var init_clean = __esm({
726
+ "src/lib/tasks/clean.ts"() {
727
+ "use strict";
728
+ init_CleanSummary();
729
+ init_utils();
730
+ init_task();
731
+ CONFIG_ERROR_INTERACTIVE_MODE = "Git clean interactive mode is not supported";
732
+ CONFIG_ERROR_MODE_REQUIRED = 'Git clean mode parameter ("n" or "f") is required';
733
+ CONFIG_ERROR_UNKNOWN_OPTION = "Git clean unknown option found in: ";
734
+ CleanOptions = /* @__PURE__ */ ((CleanOptions2) => {
735
+ CleanOptions2["DRY_RUN"] = "n";
736
+ CleanOptions2["FORCE"] = "f";
737
+ CleanOptions2["IGNORED_INCLUDED"] = "x";
738
+ CleanOptions2["IGNORED_ONLY"] = "X";
739
+ CleanOptions2["EXCLUDING"] = "e";
740
+ CleanOptions2["QUIET"] = "q";
741
+ CleanOptions2["RECURSIVE"] = "d";
742
+ return CleanOptions2;
743
+ })(CleanOptions || {});
744
+ CleanOptionValues = /* @__PURE__ */ new Set([
745
+ "i",
746
+ ...asStringArray(Object.values(CleanOptions))
747
+ ]);
748
+ }
749
+ });
750
+
751
+ // src/lib/responses/ConfigList.ts
752
+ function configListParser(text) {
753
+ const config = new ConfigList();
754
+ for (const item of configParser(text)) {
755
+ config.addValue(item.file, String(item.key), item.value);
756
+ }
757
+ return config;
758
+ }
759
+ function configGetParser(text, key) {
760
+ let value = null;
761
+ const values = [];
762
+ const scopes = /* @__PURE__ */ new Map();
763
+ for (const item of configParser(text, key)) {
764
+ if (item.key !== key) {
765
+ continue;
766
+ }
767
+ values.push(value = item.value);
768
+ if (!scopes.has(item.file)) {
769
+ scopes.set(item.file, []);
770
+ }
771
+ scopes.get(item.file).push(value);
772
+ }
773
+ return {
774
+ key,
775
+ paths: Array.from(scopes.keys()),
776
+ scopes,
777
+ value,
778
+ values
779
+ };
780
+ }
781
+ function configFilePath(filePath) {
782
+ return filePath.replace(/^(file):/, "");
783
+ }
784
+ function* configParser(text, requestedKey = null) {
785
+ const lines = text.split("\0");
786
+ for (let i = 0, max = lines.length - 1; i < max; ) {
787
+ const file = configFilePath(lines[i++]);
788
+ let value = lines[i++];
789
+ let key = requestedKey;
790
+ if (value.includes("\n")) {
791
+ const line = splitOn(value, "\n");
792
+ key = line[0];
793
+ value = line[1];
794
+ }
795
+ yield { file, key, value };
796
+ }
797
+ }
798
+ var ConfigList;
799
+ var init_ConfigList = __esm({
800
+ "src/lib/responses/ConfigList.ts"() {
801
+ "use strict";
802
+ init_utils();
803
+ ConfigList = class {
804
+ constructor() {
805
+ this.files = [];
806
+ this.values = /* @__PURE__ */ Object.create(null);
807
+ }
808
+ get all() {
809
+ if (!this._all) {
810
+ this._all = this.files.reduce((all, file) => {
811
+ return Object.assign(all, this.values[file]);
812
+ }, {});
813
+ }
814
+ return this._all;
815
+ }
816
+ addFile(file) {
817
+ if (!(file in this.values)) {
818
+ const latest = last(this.files);
819
+ this.values[file] = latest ? Object.create(this.values[latest]) : {};
820
+ this.files.push(file);
821
+ }
822
+ return this.values[file];
823
+ }
824
+ addValue(file, key, value) {
825
+ const values = this.addFile(file);
826
+ if (!Object.hasOwn(values, key)) {
827
+ values[key] = value;
828
+ } else if (Array.isArray(values[key])) {
829
+ values[key].push(value);
830
+ } else {
831
+ values[key] = [values[key], value];
832
+ }
833
+ this._all = void 0;
834
+ }
835
+ };
836
+ }
837
+ });
838
+
839
+ // src/lib/tasks/config.ts
840
+ function asConfigScope(scope, fallback) {
841
+ if (typeof scope === "string" && Object.hasOwn(GitConfigScope, scope)) {
842
+ return scope;
843
+ }
844
+ return fallback;
845
+ }
846
+ function addConfigTask(key, value, append2, scope) {
847
+ const commands = ["config", `--${scope}`];
848
+ if (append2) {
849
+ commands.push("--add");
850
+ }
851
+ commands.push(key, value);
852
+ return {
853
+ commands,
854
+ format: "utf-8",
855
+ parser(text) {
856
+ return text;
857
+ }
858
+ };
859
+ }
860
+ function getConfigTask(key, scope) {
861
+ const commands = ["config", "--null", "--show-origin", "--get-all", key];
862
+ if (scope) {
863
+ commands.splice(1, 0, `--${scope}`);
864
+ }
865
+ return {
866
+ commands,
867
+ format: "utf-8",
868
+ parser(text) {
869
+ return configGetParser(text, key);
870
+ }
871
+ };
872
+ }
873
+ function listConfigTask(scope) {
874
+ const commands = ["config", "--list", "--show-origin", "--null"];
875
+ if (scope) {
876
+ commands.push(`--${scope}`);
877
+ }
878
+ return {
879
+ commands,
880
+ format: "utf-8",
881
+ parser(text) {
882
+ return configListParser(text);
883
+ }
884
+ };
885
+ }
886
+ function config_default() {
887
+ return {
888
+ addConfig(key, value, ...rest) {
889
+ return this._runTask(
890
+ addConfigTask(
891
+ key,
892
+ value,
893
+ rest[0] === true,
894
+ asConfigScope(rest[1], "local" /* local */)
895
+ ),
896
+ trailingFunctionArgument(arguments)
897
+ );
898
+ },
899
+ getConfig(key, scope) {
900
+ return this._runTask(
901
+ getConfigTask(key, asConfigScope(scope, void 0)),
902
+ trailingFunctionArgument(arguments)
903
+ );
904
+ },
905
+ listConfig(...rest) {
906
+ return this._runTask(
907
+ listConfigTask(asConfigScope(rest[0], void 0)),
908
+ trailingFunctionArgument(arguments)
909
+ );
910
+ }
911
+ };
912
+ }
913
+ var GitConfigScope;
914
+ var init_config = __esm({
915
+ "src/lib/tasks/config.ts"() {
916
+ "use strict";
917
+ init_ConfigList();
918
+ init_utils();
919
+ GitConfigScope = /* @__PURE__ */ ((GitConfigScope2) => {
920
+ GitConfigScope2["system"] = "system";
921
+ GitConfigScope2["global"] = "global";
922
+ GitConfigScope2["local"] = "local";
923
+ GitConfigScope2["worktree"] = "worktree";
924
+ return GitConfigScope2;
925
+ })(GitConfigScope || {});
926
+ }
927
+ });
928
+
929
+ // src/lib/tasks/diff-name-status.ts
930
+ function isDiffNameStatus(input) {
931
+ return diffNameStatus.has(input);
932
+ }
933
+ var DiffNameStatus, diffNameStatus;
934
+ var init_diff_name_status = __esm({
935
+ "src/lib/tasks/diff-name-status.ts"() {
936
+ "use strict";
937
+ DiffNameStatus = /* @__PURE__ */ ((DiffNameStatus2) => {
938
+ DiffNameStatus2["ADDED"] = "A";
939
+ DiffNameStatus2["COPIED"] = "C";
940
+ DiffNameStatus2["DELETED"] = "D";
941
+ DiffNameStatus2["MODIFIED"] = "M";
942
+ DiffNameStatus2["RENAMED"] = "R";
943
+ DiffNameStatus2["CHANGED"] = "T";
944
+ DiffNameStatus2["UNMERGED"] = "U";
945
+ DiffNameStatus2["UNKNOWN"] = "X";
946
+ DiffNameStatus2["BROKEN"] = "B";
947
+ return DiffNameStatus2;
948
+ })(DiffNameStatus || {});
949
+ diffNameStatus = new Set(Object.values(DiffNameStatus));
950
+ }
951
+ });
952
+
953
+ // src/lib/tasks/grep.ts
954
+ function grepQueryBuilder(...params) {
955
+ return new GrepQuery().param(...params);
956
+ }
957
+ function parseGrep(grep) {
958
+ const paths = /* @__PURE__ */ new Set();
959
+ const results = {};
960
+ forEachLineWithContent(grep, (input) => {
961
+ const [path, line, preview] = input.split(NULL);
962
+ paths.add(path);
963
+ (results[path] = results[path] || []).push({
964
+ line: asNumber(line),
965
+ path,
966
+ preview
967
+ });
968
+ });
969
+ return {
970
+ paths,
971
+ results
972
+ };
973
+ }
974
+ function grep_default() {
975
+ return {
976
+ grep(searchTerm) {
977
+ const then = trailingFunctionArgument(arguments);
978
+ const options = getTrailingOptions(arguments);
979
+ for (const option of disallowedOptions) {
980
+ if (options.includes(option)) {
981
+ return this._runTask(
982
+ configurationErrorTask(`git.grep: use of "${option}" is not supported.`),
983
+ then
984
+ );
985
+ }
986
+ }
987
+ if (typeof searchTerm === "string") {
988
+ searchTerm = grepQueryBuilder().param(searchTerm);
989
+ }
990
+ const commands = ["grep", "--null", "-n", "--full-name", ...options, ...searchTerm];
991
+ return this._runTask(
992
+ {
993
+ commands,
994
+ format: "utf-8",
995
+ parser(stdOut) {
996
+ return parseGrep(stdOut);
997
+ }
998
+ },
999
+ then
1000
+ );
1001
+ }
1002
+ };
1003
+ }
1004
+ var disallowedOptions, Query, _a, GrepQuery;
1005
+ var init_grep = __esm({
1006
+ "src/lib/tasks/grep.ts"() {
1007
+ "use strict";
1008
+ init_utils();
1009
+ init_task();
1010
+ disallowedOptions = ["-h"];
1011
+ Query = Symbol("grepQuery");
1012
+ GrepQuery = class {
1013
+ constructor() {
1014
+ this[_a] = [];
1015
+ }
1016
+ *[(_a = Query, Symbol.iterator)]() {
1017
+ for (const query of this[Query]) {
1018
+ yield query;
1019
+ }
1020
+ }
1021
+ and(...and) {
1022
+ and.length && this[Query].push("--and", "(", ...prefixedArray(and, "-e"), ")");
1023
+ return this;
1024
+ }
1025
+ param(...param) {
1026
+ this[Query].push(...prefixedArray(param, "-e"));
1027
+ return this;
1028
+ }
1029
+ };
1030
+ }
1031
+ });
1032
+
1033
+ // src/lib/tasks/reset.ts
1034
+ var reset_exports = {};
1035
+ __export(reset_exports, {
1036
+ ResetMode: () => ResetMode,
1037
+ getResetMode: () => getResetMode,
1038
+ resetTask: () => resetTask
1039
+ });
1040
+ function resetTask(mode, customArgs) {
1041
+ const commands = ["reset"];
1042
+ if (isValidResetMode(mode)) {
1043
+ commands.push(`--${mode}`);
1044
+ }
1045
+ commands.push(...customArgs);
1046
+ return straightThroughStringTask(commands);
1047
+ }
1048
+ function getResetMode(mode) {
1049
+ if (isValidResetMode(mode)) {
1050
+ return mode;
1051
+ }
1052
+ switch (typeof mode) {
1053
+ case "string":
1054
+ case "undefined":
1055
+ return "soft" /* SOFT */;
1056
+ }
1057
+ return;
1058
+ }
1059
+ function isValidResetMode(mode) {
1060
+ return typeof mode === "string" && validResetModes.includes(mode);
1061
+ }
1062
+ var ResetMode, validResetModes;
1063
+ var init_reset = __esm({
1064
+ "src/lib/tasks/reset.ts"() {
1065
+ "use strict";
1066
+ init_utils();
1067
+ init_task();
1068
+ ResetMode = /* @__PURE__ */ ((ResetMode2) => {
1069
+ ResetMode2["MIXED"] = "mixed";
1070
+ ResetMode2["SOFT"] = "soft";
1071
+ ResetMode2["HARD"] = "hard";
1072
+ ResetMode2["MERGE"] = "merge";
1073
+ ResetMode2["KEEP"] = "keep";
1074
+ return ResetMode2;
1075
+ })(ResetMode || {});
1076
+ validResetModes = asStringArray(Object.values(ResetMode));
1077
+ }
1078
+ });
1079
+
1080
+ // src/lib/git-logger.ts
1081
+ import debug from "debug";
1082
+ function createLog() {
1083
+ return debug("simple-git");
1084
+ }
1085
+ function prefixedLogger(to, prefix, forward) {
1086
+ if (!prefix || !String(prefix).replace(/\s*/, "")) {
1087
+ return !forward ? to : (message, ...args) => {
1088
+ to(message, ...args);
1089
+ forward(message, ...args);
1090
+ };
1091
+ }
1092
+ return (message, ...args) => {
1093
+ to(`%s ${message}`, prefix, ...args);
1094
+ if (forward) {
1095
+ forward(message, ...args);
1096
+ }
1097
+ };
1098
+ }
1099
+ function childLoggerName(name, childDebugger, { namespace: parentNamespace }) {
1100
+ if (typeof name === "string") {
1101
+ return name;
1102
+ }
1103
+ const childNamespace = childDebugger && childDebugger.namespace || "";
1104
+ if (childNamespace.startsWith(parentNamespace)) {
1105
+ return childNamespace.substr(parentNamespace.length + 1);
1106
+ }
1107
+ return childNamespace || parentNamespace;
1108
+ }
1109
+ function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
1110
+ const labelPrefix = label && `[${label}]` || "";
1111
+ const spawned = [];
1112
+ const debugDebugger = typeof verbose === "string" ? infoDebugger.extend(verbose) : verbose;
1113
+ const key = childLoggerName(filterType(verbose, filterString), debugDebugger, infoDebugger);
1114
+ return step(initialStep);
1115
+ function sibling(name, initial) {
1116
+ return append(
1117
+ spawned,
1118
+ createLogger(label, key.replace(/^[^:]+/, name), initial, infoDebugger)
1119
+ );
1120
+ }
1121
+ function step(phase) {
1122
+ const stepPrefix = phase && `[${phase}]` || "";
1123
+ const debug2 = debugDebugger && prefixedLogger(debugDebugger, stepPrefix) || NOOP;
1124
+ const info = prefixedLogger(infoDebugger, `${labelPrefix} ${stepPrefix}`, debug2);
1125
+ return Object.assign(debugDebugger ? debug2 : info, {
1126
+ label,
1127
+ sibling,
1128
+ info,
1129
+ step
1130
+ });
1131
+ }
1132
+ }
1133
+ var init_git_logger = __esm({
1134
+ "src/lib/git-logger.ts"() {
1135
+ "use strict";
1136
+ init_utils();
1137
+ debug.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
1138
+ debug.formatters.B = (value) => {
1139
+ if (Buffer.isBuffer(value)) {
1140
+ return value.toString("utf8");
1141
+ }
1142
+ return objectToString(value);
1143
+ };
1144
+ }
1145
+ });
1146
+
1147
+ // src/lib/runners/tasks-pending-queue.ts
1148
+ var TasksPendingQueue;
1149
+ var init_tasks_pending_queue = __esm({
1150
+ "src/lib/runners/tasks-pending-queue.ts"() {
1151
+ "use strict";
1152
+ init_git_error();
1153
+ init_git_logger();
1154
+ TasksPendingQueue = class _TasksPendingQueue {
1155
+ constructor(logLabel = "GitExecutor") {
1156
+ this.logLabel = logLabel;
1157
+ this._queue = /* @__PURE__ */ new Map();
1158
+ }
1159
+ withProgress(task) {
1160
+ return this._queue.get(task);
1161
+ }
1162
+ createProgress(task) {
1163
+ const name = _TasksPendingQueue.getName(task.commands[0]);
1164
+ const logger = createLogger(this.logLabel, name);
1165
+ return {
1166
+ task,
1167
+ logger,
1168
+ name
1169
+ };
1170
+ }
1171
+ push(task) {
1172
+ const progress = this.createProgress(task);
1173
+ progress.logger("Adding task to the queue, commands = %o", task.commands);
1174
+ this._queue.set(task, progress);
1175
+ return progress;
1176
+ }
1177
+ fatal(err) {
1178
+ for (const [task, { logger }] of Array.from(this._queue.entries())) {
1179
+ if (task === err.task) {
1180
+ logger.info(`Failed %o`, err);
1181
+ logger(
1182
+ `Fatal exception, any as-yet un-started tasks run through this executor will not be attempted`
1183
+ );
1184
+ } else {
1185
+ logger.info(
1186
+ `A fatal exception occurred in a previous task, the queue has been purged: %o`,
1187
+ err.message
1188
+ );
1189
+ }
1190
+ this.complete(task);
1191
+ }
1192
+ if (this._queue.size !== 0) {
1193
+ throw new Error(`Queue size should be zero after fatal: ${this._queue.size}`);
1194
+ }
1195
+ }
1196
+ complete(task) {
1197
+ const progress = this.withProgress(task);
1198
+ if (progress) {
1199
+ this._queue.delete(task);
1200
+ }
1201
+ }
1202
+ attempt(task) {
1203
+ const progress = this.withProgress(task);
1204
+ if (!progress) {
1205
+ throw new GitError(void 0, "TasksPendingQueue: attempt called for an unknown task");
1206
+ }
1207
+ progress.logger("Starting task");
1208
+ return progress;
1209
+ }
1210
+ static getName(name = "empty") {
1211
+ return `task:${name}:${++_TasksPendingQueue.counter}`;
1212
+ }
1213
+ static {
1214
+ this.counter = 0;
1215
+ }
1216
+ };
1217
+ }
1218
+ });
1219
+
1220
+ // src/lib/runners/git-executor-chain.ts
1221
+ import { spawn } from "child_process";
1222
+ function pluginContext(task, commands) {
1223
+ return {
1224
+ method: first(task.commands) || "",
1225
+ commands
1226
+ };
1227
+ }
1228
+ function onErrorReceived(target, logger) {
1229
+ return (err) => {
1230
+ logger(`[ERROR] child process exception %o`, err);
1231
+ target.push(Buffer.from(String(err.stack), "ascii"));
1232
+ };
1233
+ }
1234
+ function onDataReceived(target, name, logger, output) {
1235
+ return (buffer) => {
1236
+ logger(`%s received %L bytes`, name, buffer);
1237
+ output(`%B`, buffer);
1238
+ target.push(buffer);
1239
+ };
1240
+ }
1241
+ var GitExecutorChain;
1242
+ var init_git_executor_chain = __esm({
1243
+ "src/lib/runners/git-executor-chain.ts"() {
1244
+ "use strict";
1245
+ init_git_error();
1246
+ init_task();
1247
+ init_utils();
1248
+ init_tasks_pending_queue();
1249
+ GitExecutorChain = class {
1250
+ constructor(_executor, _scheduler, _plugins) {
1251
+ this._executor = _executor;
1252
+ this._scheduler = _scheduler;
1253
+ this._plugins = _plugins;
1254
+ this._chain = Promise.resolve();
1255
+ this._queue = new TasksPendingQueue();
1256
+ }
1257
+ get cwd() {
1258
+ return this._cwd || this._executor.cwd;
1259
+ }
1260
+ set cwd(cwd) {
1261
+ this._cwd = cwd;
1262
+ }
1263
+ get env() {
1264
+ return this._executor.env;
1265
+ }
1266
+ get outputHandler() {
1267
+ return this._executor.outputHandler;
1268
+ }
1269
+ chain() {
1270
+ return this;
1271
+ }
1272
+ push(task) {
1273
+ this._queue.push(task);
1274
+ return this._chain = this._chain.then(() => this.attemptTask(task));
1275
+ }
1276
+ async attemptTask(task) {
1277
+ const onScheduleComplete = await this._scheduler.next();
1278
+ const onQueueComplete = () => this._queue.complete(task);
1279
+ try {
1280
+ const { logger } = this._queue.attempt(task);
1281
+ return await (isEmptyTask(task) ? this.attemptEmptyTask(task, logger) : this.attemptRemoteTask(task, logger));
1282
+ } catch (e) {
1283
+ throw this.onFatalException(task, e);
1284
+ } finally {
1285
+ onQueueComplete();
1286
+ onScheduleComplete();
1287
+ }
1288
+ }
1289
+ onFatalException(task, e) {
1290
+ const gitError = e instanceof GitError ? Object.assign(e, { task }) : new GitError(task, e && String(e));
1291
+ this._chain = Promise.resolve();
1292
+ this._queue.fatal(gitError);
1293
+ return gitError;
1294
+ }
1295
+ async attemptRemoteTask(task, logger) {
1296
+ const binary = this._plugins.exec("spawn.binary", "", pluginContext(task, task.commands));
1297
+ const args = this._plugins.exec("spawn.args", [...task.commands], {
1298
+ ...pluginContext(task, task.commands),
1299
+ env: { ...this.env }
1300
+ });
1301
+ const raw = await this.gitResponse(
1302
+ task,
1303
+ binary,
1304
+ args,
1305
+ this.outputHandler,
1306
+ logger.step("SPAWN")
1307
+ );
1308
+ const outputStreams = await this.handleTaskData(task, args, raw, logger.step("HANDLE"));
1309
+ logger(`passing response to task's parser as a %s`, task.format);
1310
+ if (isBufferTask(task)) {
1311
+ return callTaskParser(task.parser, outputStreams);
1312
+ }
1313
+ return callTaskParser(task.parser, outputStreams.asStrings());
1314
+ }
1315
+ async attemptEmptyTask(task, logger) {
1316
+ logger(`empty task bypassing child process to call to task's parser`);
1317
+ return task.parser(this);
1318
+ }
1319
+ handleTaskData(task, args, result, logger) {
1320
+ const { exitCode, rejection, stdOut, stdErr } = result;
1321
+ return new Promise((done, fail) => {
1322
+ logger(`Preparing to handle process response exitCode=%d stdOut=`, exitCode);
1323
+ const { error } = this._plugins.exec(
1324
+ "task.error",
1325
+ { error: rejection },
1326
+ {
1327
+ ...pluginContext(task, args),
1328
+ ...result
1329
+ }
1330
+ );
1331
+ if (error && task.onError) {
1332
+ logger.info(`exitCode=%s handling with custom error handler`);
1333
+ return task.onError(
1334
+ result,
1335
+ error,
1336
+ (newStdOut) => {
1337
+ logger.info(`custom error handler treated as success`);
1338
+ logger(`custom error returned a %s`, objectToString(newStdOut));
1339
+ done(
1340
+ new GitOutputStreams(
1341
+ Array.isArray(newStdOut) ? Buffer.concat(newStdOut) : newStdOut,
1342
+ Buffer.concat(stdErr)
1343
+ )
1344
+ );
1345
+ },
1346
+ fail
1347
+ );
1348
+ }
1349
+ if (error) {
1350
+ logger.info(
1351
+ `handling as error: exitCode=%s stdErr=%s rejection=%o`,
1352
+ exitCode,
1353
+ stdErr.length,
1354
+ rejection
1355
+ );
1356
+ return fail(error);
1357
+ }
1358
+ logger.info(`retrieving task output complete`);
1359
+ done(new GitOutputStreams(Buffer.concat(stdOut), Buffer.concat(stdErr)));
1360
+ });
1361
+ }
1362
+ async gitResponse(task, command, args, outputHandler, logger) {
1363
+ const outputLogger = logger.sibling("output");
1364
+ const spawnOptions = this._plugins.exec(
1365
+ "spawn.options",
1366
+ {
1367
+ cwd: this.cwd,
1368
+ env: this.env,
1369
+ windowsHide: true
1370
+ },
1371
+ pluginContext(task, task.commands)
1372
+ );
1373
+ return new Promise((done) => {
1374
+ const stdOut = [];
1375
+ const stdErr = [];
1376
+ logger.info(`%s %o`, command, args);
1377
+ logger("%O", spawnOptions);
1378
+ let rejection = this._beforeSpawn(task, args);
1379
+ if (rejection) {
1380
+ return done({
1381
+ stdOut,
1382
+ stdErr,
1383
+ exitCode: 9901,
1384
+ rejection
1385
+ });
1386
+ }
1387
+ this._plugins.exec("spawn.before", void 0, {
1388
+ ...pluginContext(task, args),
1389
+ kill(reason) {
1390
+ rejection = reason || rejection;
1391
+ }
1392
+ });
1393
+ const spawned = spawn(command, args, spawnOptions);
1394
+ spawned.stdout.on(
1395
+ "data",
1396
+ onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut"))
1397
+ );
1398
+ spawned.stderr.on(
1399
+ "data",
1400
+ onDataReceived(stdErr, "stdErr", logger, outputLogger.step("stdErr"))
1401
+ );
1402
+ spawned.on("error", onErrorReceived(stdErr, logger));
1403
+ if (outputHandler) {
1404
+ logger(`Passing child process stdOut/stdErr to custom outputHandler`);
1405
+ outputHandler(command, spawned.stdout, spawned.stderr, [...args]);
1406
+ }
1407
+ this._plugins.exec("spawn.after", void 0, {
1408
+ ...pluginContext(task, args),
1409
+ spawned,
1410
+ close(exitCode, reason) {
1411
+ done({
1412
+ stdOut,
1413
+ stdErr,
1414
+ exitCode,
1415
+ rejection: rejection || reason
1416
+ });
1417
+ },
1418
+ kill(reason) {
1419
+ if (spawned.killed) {
1420
+ return;
1421
+ }
1422
+ rejection = reason;
1423
+ spawned.kill("SIGINT");
1424
+ }
1425
+ });
1426
+ });
1427
+ }
1428
+ _beforeSpawn(task, args) {
1429
+ let rejection;
1430
+ this._plugins.exec("spawn.before", void 0, {
1431
+ ...pluginContext(task, args),
1432
+ kill(reason) {
1433
+ rejection = reason || rejection;
1434
+ }
1435
+ });
1436
+ return rejection;
1437
+ }
1438
+ };
1439
+ }
1440
+ });
1441
+
1442
+ // src/lib/runners/git-executor.ts
1443
+ var git_executor_exports = {};
1444
+ __export(git_executor_exports, {
1445
+ GitExecutor: () => GitExecutor
1446
+ });
1447
+ var GitExecutor;
1448
+ var init_git_executor = __esm({
1449
+ "src/lib/runners/git-executor.ts"() {
1450
+ "use strict";
1451
+ init_git_executor_chain();
1452
+ GitExecutor = class {
1453
+ constructor(cwd, _scheduler, _plugins) {
1454
+ this.cwd = cwd;
1455
+ this._scheduler = _scheduler;
1456
+ this._plugins = _plugins;
1457
+ this._chain = new GitExecutorChain(this, this._scheduler, this._plugins);
1458
+ }
1459
+ chain() {
1460
+ return new GitExecutorChain(this, this._scheduler, this._plugins);
1461
+ }
1462
+ push(task) {
1463
+ return this._chain.push(task);
1464
+ }
1465
+ };
1466
+ }
1467
+ });
1468
+
1469
+ // src/lib/task-callback.ts
1470
+ function taskCallback(task, response, callback = NOOP) {
1471
+ const onSuccess = (data) => {
1472
+ callback(null, data);
1473
+ };
1474
+ const onError2 = (err) => {
1475
+ if (err?.task === task) {
1476
+ callback(
1477
+ err instanceof GitResponseError ? addDeprecationNoticeToError(err) : err,
1478
+ void 0
1479
+ );
1480
+ }
1481
+ };
1482
+ response.then(onSuccess, onError2);
1483
+ }
1484
+ function addDeprecationNoticeToError(err) {
1485
+ let log = (name) => {
1486
+ console.warn(
1487
+ `simple-git deprecation notice: accessing GitResponseError.${name} should be GitResponseError.git.${name}, this will no longer be available in version 3`
1488
+ );
1489
+ log = NOOP;
1490
+ };
1491
+ return Object.create(err, Object.getOwnPropertyNames(err.git).reduce(descriptorReducer, {}));
1492
+ function descriptorReducer(all, name) {
1493
+ if (name in err) {
1494
+ return all;
1495
+ }
1496
+ all[name] = {
1497
+ enumerable: false,
1498
+ configurable: false,
1499
+ get() {
1500
+ log(name);
1501
+ return err.git[name];
1502
+ }
1503
+ };
1504
+ return all;
1505
+ }
1506
+ }
1507
+ var init_task_callback = __esm({
1508
+ "src/lib/task-callback.ts"() {
1509
+ "use strict";
1510
+ init_git_response_error();
1511
+ init_utils();
1512
+ }
1513
+ });
1514
+
1515
+ // src/lib/tasks/change-working-directory.ts
1516
+ function changeWorkingDirectoryTask(directory, root) {
1517
+ return adhocExecTask((instance) => {
1518
+ if (!folderExists(directory)) {
1519
+ throw new Error(`Git.cwd: cannot change to non-directory "${directory}"`);
1520
+ }
1521
+ return (root || instance).cwd = directory;
1522
+ });
1523
+ }
1524
+ var init_change_working_directory = __esm({
1525
+ "src/lib/tasks/change-working-directory.ts"() {
1526
+ "use strict";
1527
+ init_utils();
1528
+ init_task();
1529
+ }
1530
+ });
1531
+
1532
+ // src/lib/tasks/checkout.ts
1533
+ function checkoutTask(args) {
1534
+ const commands = ["checkout", ...args];
1535
+ if (commands[1] === "-b" && commands.includes("-B")) {
1536
+ commands[1] = remove(commands, "-B");
1537
+ }
1538
+ return straightThroughStringTask(commands);
1539
+ }
1540
+ function checkout_default() {
1541
+ return {
1542
+ checkout() {
1543
+ return this._runTask(
1544
+ checkoutTask(getTrailingOptions(arguments, 1)),
1545
+ trailingFunctionArgument(arguments)
1546
+ );
1547
+ },
1548
+ checkoutBranch(branchName, startPoint) {
1549
+ return this._runTask(
1550
+ checkoutTask(["-b", branchName, startPoint, ...getTrailingOptions(arguments)]),
1551
+ trailingFunctionArgument(arguments)
1552
+ );
1553
+ },
1554
+ checkoutLocalBranch(branchName) {
1555
+ return this._runTask(
1556
+ checkoutTask(["-b", branchName, ...getTrailingOptions(arguments)]),
1557
+ trailingFunctionArgument(arguments)
1558
+ );
1559
+ }
1560
+ };
1561
+ }
1562
+ var init_checkout = __esm({
1563
+ "src/lib/tasks/checkout.ts"() {
1564
+ "use strict";
1565
+ init_utils();
1566
+ init_task();
1567
+ }
1568
+ });
1569
+
1570
+ // src/lib/tasks/count-objects.ts
1571
+ function countObjectsResponse() {
1572
+ return {
1573
+ count: 0,
1574
+ garbage: 0,
1575
+ inPack: 0,
1576
+ packs: 0,
1577
+ prunePackable: 0,
1578
+ size: 0,
1579
+ sizeGarbage: 0,
1580
+ sizePack: 0
1581
+ };
1582
+ }
1583
+ function count_objects_default() {
1584
+ return {
1585
+ countObjects() {
1586
+ return this._runTask({
1587
+ commands: ["count-objects", "--verbose"],
1588
+ format: "utf-8",
1589
+ parser(stdOut) {
1590
+ return parseStringResponse(countObjectsResponse(), [parser2], stdOut);
1591
+ }
1592
+ });
1593
+ }
1594
+ };
1595
+ }
1596
+ var parser2;
1597
+ var init_count_objects = __esm({
1598
+ "src/lib/tasks/count-objects.ts"() {
1599
+ "use strict";
1600
+ init_utils();
1601
+ parser2 = new LineParser(
1602
+ /([a-z-]+): (\d+)$/,
1603
+ (result, [key, value]) => {
1604
+ const property = asCamelCase(key);
1605
+ if (Object.hasOwn(result, property)) {
1606
+ result[property] = asNumber(value);
1607
+ }
1608
+ }
1609
+ );
1610
+ }
1611
+ });
1612
+
1613
+ // src/lib/parsers/parse-commit.ts
1614
+ function parseCommitResult(stdOut) {
1615
+ const result = {
1616
+ author: null,
1617
+ branch: "",
1618
+ commit: "",
1619
+ root: false,
1620
+ summary: {
1621
+ changes: 0,
1622
+ insertions: 0,
1623
+ deletions: 0
1624
+ }
1625
+ };
1626
+ return parseStringResponse(result, parsers, stdOut);
1627
+ }
1628
+ var parsers;
1629
+ var init_parse_commit = __esm({
1630
+ "src/lib/parsers/parse-commit.ts"() {
1631
+ "use strict";
1632
+ init_utils();
1633
+ parsers = [
1634
+ new LineParser(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/, (result, [branch, root, commit]) => {
1635
+ result.branch = branch;
1636
+ result.commit = commit;
1637
+ result.root = !!root;
1638
+ }),
1639
+ new LineParser(/\s*Author:\s(.+)/i, (result, [author]) => {
1640
+ const parts = author.split("<");
1641
+ const email = parts.pop();
1642
+ if (!email || !email.includes("@")) {
1643
+ return;
1644
+ }
1645
+ result.author = {
1646
+ email: email.substr(0, email.length - 1),
1647
+ name: parts.join("<").trim()
1648
+ };
1649
+ }),
1650
+ new LineParser(
1651
+ /(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g,
1652
+ (result, [changes, insertions, deletions]) => {
1653
+ result.summary.changes = parseInt(changes, 10) || 0;
1654
+ result.summary.insertions = parseInt(insertions, 10) || 0;
1655
+ result.summary.deletions = parseInt(deletions, 10) || 0;
1656
+ }
1657
+ ),
1658
+ new LineParser(
1659
+ /^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/,
1660
+ (result, [changes, lines, direction]) => {
1661
+ result.summary.changes = parseInt(changes, 10) || 0;
1662
+ const count = parseInt(lines, 10) || 0;
1663
+ if (direction === "-") {
1664
+ result.summary.deletions = count;
1665
+ } else if (direction === "+") {
1666
+ result.summary.insertions = count;
1667
+ }
1668
+ }
1669
+ )
1670
+ ];
1671
+ }
1672
+ });
1673
+
1674
+ // src/lib/tasks/commit.ts
1675
+ function commitTask(message, files, customArgs) {
1676
+ const commands = [
1677
+ "-c",
1678
+ "core.abbrev=40",
1679
+ "commit",
1680
+ ...prefixedArray(message, "-m"),
1681
+ ...files,
1682
+ ...customArgs
1683
+ ];
1684
+ return {
1685
+ commands,
1686
+ format: "utf-8",
1687
+ parser: parseCommitResult
1688
+ };
1689
+ }
1690
+ function commit_default() {
1691
+ return {
1692
+ commit(message, ...rest) {
1693
+ const next = trailingFunctionArgument(arguments);
1694
+ const task = rejectDeprecatedSignatures(message) || commitTask(
1695
+ asArray(message),
1696
+ asArray(filterType(rest[0], filterStringOrStringArray, [])),
1697
+ [
1698
+ ...asStringArray(filterType(rest[1], filterArray, [])),
1699
+ ...getTrailingOptions(arguments, 0, true)
1700
+ ]
1701
+ );
1702
+ return this._runTask(task, next);
1703
+ }
1704
+ };
1705
+ function rejectDeprecatedSignatures(message) {
1706
+ return !filterStringOrStringArray(message) && configurationErrorTask(
1707
+ `git.commit: requires the commit message to be supplied as a string/string[]`
1708
+ );
1709
+ }
1710
+ }
1711
+ var init_commit = __esm({
1712
+ "src/lib/tasks/commit.ts"() {
1713
+ "use strict";
1714
+ init_parse_commit();
1715
+ init_utils();
1716
+ init_task();
1717
+ }
1718
+ });
1719
+
1720
+ // src/lib/tasks/first-commit.ts
1721
+ function first_commit_default() {
1722
+ return {
1723
+ firstCommit() {
1724
+ return this._runTask(
1725
+ straightThroughStringTask(["rev-list", "--max-parents=0", "HEAD"], true),
1726
+ trailingFunctionArgument(arguments)
1727
+ );
1728
+ }
1729
+ };
1730
+ }
1731
+ var init_first_commit = __esm({
1732
+ "src/lib/tasks/first-commit.ts"() {
1733
+ "use strict";
1734
+ init_utils();
1735
+ init_task();
1736
+ }
1737
+ });
1738
+
1739
+ // src/lib/tasks/hash-object.ts
1740
+ function hashObjectTask(filePath, write) {
1741
+ const commands = ["hash-object", filePath];
1742
+ if (write) {
1743
+ commands.push("-w");
1744
+ }
1745
+ return straightThroughStringTask(commands, true);
1746
+ }
1747
+ var init_hash_object = __esm({
1748
+ "src/lib/tasks/hash-object.ts"() {
1749
+ "use strict";
1750
+ init_task();
1751
+ }
1752
+ });
1753
+
1754
+ // src/lib/responses/InitSummary.ts
1755
+ function parseInit(bare, path, text) {
1756
+ const response = String(text).trim();
1757
+ let result;
1758
+ if (result = initResponseRegex.exec(response)) {
1759
+ return new InitSummary(bare, path, false, result[1]);
1760
+ }
1761
+ if (result = reInitResponseRegex.exec(response)) {
1762
+ return new InitSummary(bare, path, true, result[1]);
1763
+ }
1764
+ let gitDir = "";
1765
+ const tokens = response.split(" ");
1766
+ while (tokens.length) {
1767
+ const token = tokens.shift();
1768
+ if (token === "in") {
1769
+ gitDir = tokens.join(" ");
1770
+ break;
1771
+ }
1772
+ }
1773
+ return new InitSummary(bare, path, /^re/i.test(response), gitDir);
1774
+ }
1775
+ var InitSummary, initResponseRegex, reInitResponseRegex;
1776
+ var init_InitSummary = __esm({
1777
+ "src/lib/responses/InitSummary.ts"() {
1778
+ "use strict";
1779
+ InitSummary = class {
1780
+ constructor(bare, path, existing, gitDir) {
1781
+ this.bare = bare;
1782
+ this.path = path;
1783
+ this.existing = existing;
1784
+ this.gitDir = gitDir;
1785
+ }
1786
+ };
1787
+ initResponseRegex = /^Init.+ repository in (.+)$/;
1788
+ reInitResponseRegex = /^Rein.+ in (.+)$/;
1789
+ }
1790
+ });
1791
+
1792
+ // src/lib/tasks/init.ts
1793
+ function hasBareCommand(command) {
1794
+ return command.includes(bareCommand);
1795
+ }
1796
+ function initTask(bare = false, path, customArgs) {
1797
+ const commands = ["init", ...customArgs];
1798
+ if (bare && !hasBareCommand(commands)) {
1799
+ commands.splice(1, 0, bareCommand);
1800
+ }
1801
+ return {
1802
+ commands,
1803
+ format: "utf-8",
1804
+ parser(text) {
1805
+ return parseInit(commands.includes("--bare"), path, text);
1806
+ }
1807
+ };
1808
+ }
1809
+ var bareCommand;
1810
+ var init_init = __esm({
1811
+ "src/lib/tasks/init.ts"() {
1812
+ "use strict";
1813
+ init_InitSummary();
1814
+ bareCommand = "--bare";
1815
+ }
1816
+ });
1817
+
1818
+ // src/lib/args/log-format.ts
1819
+ function logFormatFromCommand(customArgs) {
1820
+ for (let i = 0; i < customArgs.length; i++) {
1821
+ const format = logFormatRegex.exec(customArgs[i]);
1822
+ if (format) {
1823
+ return `--${format[1]}`;
1824
+ }
1825
+ }
1826
+ return "" /* NONE */;
1827
+ }
1828
+ function isLogFormat(customArg) {
1829
+ return logFormatRegex.test(customArg);
1830
+ }
1831
+ var logFormatRegex;
1832
+ var init_log_format = __esm({
1833
+ "src/lib/args/log-format.ts"() {
1834
+ "use strict";
1835
+ logFormatRegex = /^--(stat|numstat|name-only|name-status)(=|$)/;
1836
+ }
1837
+ });
1838
+
1839
+ // src/lib/responses/DiffSummary.ts
1840
+ var DiffSummary;
1841
+ var init_DiffSummary = __esm({
1842
+ "src/lib/responses/DiffSummary.ts"() {
1843
+ "use strict";
1844
+ DiffSummary = class {
1845
+ constructor() {
1846
+ this.changed = 0;
1847
+ this.deletions = 0;
1848
+ this.insertions = 0;
1849
+ this.files = [];
1850
+ }
1851
+ };
1852
+ }
1853
+ });
1854
+
1855
+ // src/lib/parsers/parse-diff-summary.ts
1856
+ function getDiffParser(format = "" /* NONE */) {
1857
+ const parser4 = diffSummaryParsers[format];
1858
+ return (stdOut) => parseStringResponse(new DiffSummary(), parser4, stdOut, false);
1859
+ }
1860
+ var statParser, numStatParser, nameOnlyParser, nameStatusParser, diffSummaryParsers;
1861
+ var init_parse_diff_summary = __esm({
1862
+ "src/lib/parsers/parse-diff-summary.ts"() {
1863
+ "use strict";
1864
+ init_log_format();
1865
+ init_DiffSummary();
1866
+ init_diff_name_status();
1867
+ init_utils();
1868
+ statParser = [
1869
+ new LineParser(
1870
+ /^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,
1871
+ (result, [file, changes, alterations = ""]) => {
1872
+ result.files.push({
1873
+ file: file.trim(),
1874
+ changes: asNumber(changes),
1875
+ insertions: alterations.replace(/[^+]/g, "").length,
1876
+ deletions: alterations.replace(/[^-]/g, "").length,
1877
+ binary: false
1878
+ });
1879
+ }
1880
+ ),
1881
+ new LineParser(
1882
+ /^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,
1883
+ (result, [file, before, after]) => {
1884
+ result.files.push({
1885
+ file: file.trim(),
1886
+ before: asNumber(before),
1887
+ after: asNumber(after),
1888
+ binary: true
1889
+ });
1890
+ }
1891
+ ),
1892
+ new LineParser(
1893
+ /(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,
1894
+ (result, [changed, summary]) => {
1895
+ const inserted = /(\d+) i/.exec(summary);
1896
+ const deleted = /(\d+) d/.exec(summary);
1897
+ result.changed = asNumber(changed);
1898
+ result.insertions = asNumber(inserted?.[1]);
1899
+ result.deletions = asNumber(deleted?.[1]);
1900
+ }
1901
+ )
1902
+ ];
1903
+ numStatParser = [
1904
+ new LineParser(
1905
+ /(\d+)\t(\d+)\t(.+)$/,
1906
+ (result, [changesInsert, changesDelete, file]) => {
1907
+ const insertions = asNumber(changesInsert);
1908
+ const deletions = asNumber(changesDelete);
1909
+ result.changed++;
1910
+ result.insertions += insertions;
1911
+ result.deletions += deletions;
1912
+ result.files.push({
1913
+ file,
1914
+ changes: insertions + deletions,
1915
+ insertions,
1916
+ deletions,
1917
+ binary: false
1918
+ });
1919
+ }
1920
+ ),
1921
+ new LineParser(/-\t-\t(.+)$/, (result, [file]) => {
1922
+ result.changed++;
1923
+ result.files.push({
1924
+ file,
1925
+ after: 0,
1926
+ before: 0,
1927
+ binary: true
1928
+ });
1929
+ })
1930
+ ];
1931
+ nameOnlyParser = [
1932
+ new LineParser(/(.+)$/, (result, [file]) => {
1933
+ result.changed++;
1934
+ result.files.push({
1935
+ file,
1936
+ changes: 0,
1937
+ insertions: 0,
1938
+ deletions: 0,
1939
+ binary: false
1940
+ });
1941
+ })
1942
+ ];
1943
+ nameStatusParser = [
1944
+ new LineParser(
1945
+ /([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,
1946
+ (result, [status, similarity, from, _to, to]) => {
1947
+ result.changed++;
1948
+ result.files.push({
1949
+ file: to ?? from,
1950
+ changes: 0,
1951
+ insertions: 0,
1952
+ deletions: 0,
1953
+ binary: false,
1954
+ status: orVoid(isDiffNameStatus(status) && status),
1955
+ from: orVoid(!!to && from !== to && from),
1956
+ similarity: asNumber(similarity)
1957
+ });
1958
+ }
1959
+ )
1960
+ ];
1961
+ diffSummaryParsers = {
1962
+ ["" /* NONE */]: statParser,
1963
+ ["--stat" /* STAT */]: statParser,
1964
+ ["--numstat" /* NUM_STAT */]: numStatParser,
1965
+ ["--name-status" /* NAME_STATUS */]: nameStatusParser,
1966
+ ["--name-only" /* NAME_ONLY */]: nameOnlyParser
1967
+ };
1968
+ }
1969
+ });
1970
+
1971
+ // src/lib/parsers/parse-list-log-summary.ts
1972
+ function lineBuilder(tokens, fields) {
1973
+ return fields.reduce(
1974
+ (line, field, index) => {
1975
+ line[field] = tokens[index] || "";
1976
+ return line;
1977
+ },
1978
+ /* @__PURE__ */ Object.create({ diff: null })
1979
+ );
1980
+ }
1981
+ function createListLogSummaryParser(splitter = SPLITTER, fields = defaultFieldNames, logFormat = "" /* NONE */) {
1982
+ const parseDiffResult = getDiffParser(logFormat);
1983
+ return function(stdOut) {
1984
+ const all = toLinesWithContent(
1985
+ stdOut.trim(),
1986
+ false,
1987
+ START_BOUNDARY
1988
+ ).map(function(item) {
1989
+ const lineDetail = item.split(COMMIT_BOUNDARY);
1990
+ const listLogLine = lineBuilder(lineDetail[0].split(splitter), fields);
1991
+ if (lineDetail.length > 1 && !!lineDetail[1].trim()) {
1992
+ listLogLine.diff = parseDiffResult(lineDetail[1]);
1993
+ }
1994
+ return listLogLine;
1995
+ });
1996
+ return {
1997
+ all,
1998
+ latest: all.length && all[0] || null,
1999
+ total: all.length
2000
+ };
2001
+ };
2002
+ }
2003
+ var START_BOUNDARY, COMMIT_BOUNDARY, SPLITTER, defaultFieldNames;
2004
+ var init_parse_list_log_summary = __esm({
2005
+ "src/lib/parsers/parse-list-log-summary.ts"() {
2006
+ "use strict";
2007
+ init_utils();
2008
+ init_parse_diff_summary();
2009
+ init_log_format();
2010
+ START_BOUNDARY = "\xF2\xF2\xF2\xF2\xF2\xF2 ";
2011
+ COMMIT_BOUNDARY = " \xF2\xF2";
2012
+ SPLITTER = " \xF2 ";
2013
+ defaultFieldNames = ["hash", "date", "message", "refs", "author_name", "author_email"];
2014
+ }
2015
+ });
2016
+
2017
+ // src/lib/tasks/diff.ts
2018
+ var diff_exports = {};
2019
+ __export(diff_exports, {
2020
+ diffSummaryTask: () => diffSummaryTask,
2021
+ validateLogFormatConfig: () => validateLogFormatConfig
2022
+ });
2023
+ function diffSummaryTask(customArgs) {
2024
+ let logFormat = logFormatFromCommand(customArgs);
2025
+ const commands = ["diff"];
2026
+ if (logFormat === "" /* NONE */) {
2027
+ logFormat = "--stat" /* STAT */;
2028
+ commands.push("--stat=4096");
2029
+ }
2030
+ commands.push(...customArgs);
2031
+ return validateLogFormatConfig(commands) || {
2032
+ commands,
2033
+ format: "utf-8",
2034
+ parser: getDiffParser(logFormat)
2035
+ };
2036
+ }
2037
+ function validateLogFormatConfig(customArgs) {
2038
+ const flags = customArgs.filter(isLogFormat);
2039
+ if (flags.length > 1) {
2040
+ return configurationErrorTask(
2041
+ `Summary flags are mutually exclusive - pick one of ${flags.join(",")}`
2042
+ );
2043
+ }
2044
+ if (flags.length && customArgs.includes("-z")) {
2045
+ return configurationErrorTask(
2046
+ `Summary flag ${flags} parsing is not compatible with null termination option '-z'`
2047
+ );
2048
+ }
2049
+ }
2050
+ var init_diff = __esm({
2051
+ "src/lib/tasks/diff.ts"() {
2052
+ "use strict";
2053
+ init_log_format();
2054
+ init_parse_diff_summary();
2055
+ init_task();
2056
+ }
2057
+ });
2058
+
2059
+ // src/lib/tasks/log.ts
2060
+ import { pathspec as pathspec2 } from "@simple-git/args-pathspec";
2061
+ function prettyFormat(format, splitter) {
2062
+ const fields = [];
2063
+ const formatStr = [];
2064
+ Object.keys(format).forEach((field) => {
2065
+ fields.push(field);
2066
+ formatStr.push(String(format[field]));
2067
+ });
2068
+ return [fields, formatStr.join(splitter)];
2069
+ }
2070
+ function userOptions(input) {
2071
+ return Object.keys(input).reduce((out, key) => {
2072
+ if (!(key in excludeOptions)) {
2073
+ out[key] = input[key];
2074
+ }
2075
+ return out;
2076
+ }, {});
2077
+ }
2078
+ function parseLogOptions(opt = {}, customArgs = []) {
2079
+ const splitter = filterType(opt.splitter, filterString, SPLITTER);
2080
+ const format = filterPlainObject(opt.format) ? opt.format : {
2081
+ hash: "%H",
2082
+ date: opt.strictDate === false ? "%ai" : "%aI",
2083
+ message: "%s",
2084
+ refs: "%D",
2085
+ body: opt.multiLine ? "%B" : "%b",
2086
+ author_name: opt.mailMap !== false ? "%aN" : "%an",
2087
+ author_email: opt.mailMap !== false ? "%aE" : "%ae"
2088
+ };
2089
+ const [fields, formatStr] = prettyFormat(format, splitter);
2090
+ const suffix = [];
2091
+ const command = [
2092
+ `--pretty=format:${START_BOUNDARY}${formatStr}${COMMIT_BOUNDARY}`,
2093
+ ...customArgs
2094
+ ];
2095
+ const maxCount = opt.n || opt["max-count"] || opt.maxCount;
2096
+ if (maxCount) {
2097
+ command.push(`--max-count=${maxCount}`);
2098
+ }
2099
+ if (opt.from || opt.to) {
2100
+ const rangeOperator = opt.symmetric !== false ? "..." : "..";
2101
+ suffix.push(`${opt.from || ""}${rangeOperator}${opt.to || ""}`);
2102
+ }
2103
+ if (filterString(opt.file)) {
2104
+ command.push("--follow", pathspec2(opt.file));
2105
+ }
2106
+ appendTaskOptions(userOptions(opt), command);
2107
+ return {
2108
+ fields,
2109
+ splitter,
2110
+ commands: [...command, ...suffix]
2111
+ };
2112
+ }
2113
+ function logTask(splitter, fields, customArgs) {
2114
+ const parser4 = createListLogSummaryParser(splitter, fields, logFormatFromCommand(customArgs));
2115
+ return {
2116
+ commands: ["log", ...customArgs],
2117
+ format: "utf-8",
2118
+ parser: parser4
2119
+ };
2120
+ }
2121
+ function log_default() {
2122
+ return {
2123
+ log(...rest) {
2124
+ const next = trailingFunctionArgument(arguments);
2125
+ const options = parseLogOptions(
2126
+ trailingOptionsArgument(arguments),
2127
+ asStringArray(filterType(arguments[0], filterArray, []))
2128
+ );
2129
+ const task = rejectDeprecatedSignatures(...rest) || validateLogFormatConfig(options.commands) || createLogTask(options);
2130
+ return this._runTask(task, next);
2131
+ }
2132
+ };
2133
+ function createLogTask(options) {
2134
+ return logTask(options.splitter, options.fields, options.commands);
2135
+ }
2136
+ function rejectDeprecatedSignatures(from, to) {
2137
+ return filterString(from) && filterString(to) && configurationErrorTask(
2138
+ `git.log(string, string) should be replaced with git.log({ from: string, to: string })`
2139
+ );
2140
+ }
2141
+ }
2142
+ var excludeOptions;
2143
+ var init_log = __esm({
2144
+ "src/lib/tasks/log.ts"() {
2145
+ "use strict";
2146
+ init_log_format();
2147
+ init_parse_list_log_summary();
2148
+ init_utils();
2149
+ init_task();
2150
+ init_diff();
2151
+ excludeOptions = /* @__PURE__ */ ((excludeOptions2) => {
2152
+ excludeOptions2[excludeOptions2["--pretty"] = 0] = "--pretty";
2153
+ excludeOptions2[excludeOptions2["max-count"] = 1] = "max-count";
2154
+ excludeOptions2[excludeOptions2["maxCount"] = 2] = "maxCount";
2155
+ excludeOptions2[excludeOptions2["n"] = 3] = "n";
2156
+ excludeOptions2[excludeOptions2["file"] = 4] = "file";
2157
+ excludeOptions2[excludeOptions2["format"] = 5] = "format";
2158
+ excludeOptions2[excludeOptions2["from"] = 6] = "from";
2159
+ excludeOptions2[excludeOptions2["to"] = 7] = "to";
2160
+ excludeOptions2[excludeOptions2["splitter"] = 8] = "splitter";
2161
+ excludeOptions2[excludeOptions2["symmetric"] = 9] = "symmetric";
2162
+ excludeOptions2[excludeOptions2["mailMap"] = 10] = "mailMap";
2163
+ excludeOptions2[excludeOptions2["multiLine"] = 11] = "multiLine";
2164
+ excludeOptions2[excludeOptions2["strictDate"] = 12] = "strictDate";
2165
+ return excludeOptions2;
2166
+ })(excludeOptions || {});
2167
+ }
2168
+ });
2169
+
2170
+ // src/lib/responses/MergeSummary.ts
2171
+ var MergeSummaryConflict, MergeSummaryDetail;
2172
+ var init_MergeSummary = __esm({
2173
+ "src/lib/responses/MergeSummary.ts"() {
2174
+ "use strict";
2175
+ MergeSummaryConflict = class {
2176
+ constructor(reason, file = null, meta) {
2177
+ this.reason = reason;
2178
+ this.file = file;
2179
+ this.meta = meta;
2180
+ }
2181
+ toString() {
2182
+ return `${this.file}:${this.reason}`;
2183
+ }
2184
+ };
2185
+ MergeSummaryDetail = class {
2186
+ constructor() {
2187
+ this.conflicts = [];
2188
+ this.merges = [];
2189
+ this.result = "success";
2190
+ }
2191
+ get failed() {
2192
+ return this.conflicts.length > 0;
2193
+ }
2194
+ get reason() {
2195
+ return this.result;
2196
+ }
2197
+ toString() {
2198
+ if (this.conflicts.length) {
2199
+ return `CONFLICTS: ${this.conflicts.join(", ")}`;
2200
+ }
2201
+ return "OK";
2202
+ }
2203
+ };
2204
+ }
2205
+ });
2206
+
2207
+ // src/lib/responses/PullSummary.ts
2208
+ var PullSummary, PullFailedSummary;
2209
+ var init_PullSummary = __esm({
2210
+ "src/lib/responses/PullSummary.ts"() {
2211
+ "use strict";
2212
+ PullSummary = class {
2213
+ constructor() {
2214
+ this.remoteMessages = {
2215
+ all: []
2216
+ };
2217
+ this.created = [];
2218
+ this.deleted = [];
2219
+ this.files = [];
2220
+ this.deletions = {};
2221
+ this.insertions = {};
2222
+ this.summary = {
2223
+ changes: 0,
2224
+ deletions: 0,
2225
+ insertions: 0
2226
+ };
2227
+ }
2228
+ };
2229
+ PullFailedSummary = class {
2230
+ constructor() {
2231
+ this.remote = "";
2232
+ this.hash = {
2233
+ local: "",
2234
+ remote: ""
2235
+ };
2236
+ this.branch = {
2237
+ local: "",
2238
+ remote: ""
2239
+ };
2240
+ this.message = "";
2241
+ }
2242
+ toString() {
2243
+ return this.message;
2244
+ }
2245
+ };
2246
+ }
2247
+ });
2248
+
2249
+ // src/lib/parsers/parse-remote-objects.ts
2250
+ function objectEnumerationResult(remoteMessages) {
2251
+ return remoteMessages.objects = remoteMessages.objects || {
2252
+ compressing: 0,
2253
+ counting: 0,
2254
+ enumerating: 0,
2255
+ packReused: 0,
2256
+ reused: { count: 0, delta: 0 },
2257
+ total: { count: 0, delta: 0 }
2258
+ };
2259
+ }
2260
+ function asObjectCount(source) {
2261
+ const count = /^\s*(\d+)/.exec(source);
2262
+ const delta = /delta (\d+)/i.exec(source);
2263
+ return {
2264
+ count: asNumber(count && count[1] || "0"),
2265
+ delta: asNumber(delta && delta[1] || "0")
2266
+ };
2267
+ }
2268
+ var remoteMessagesObjectParsers;
2269
+ var init_parse_remote_objects = __esm({
2270
+ "src/lib/parsers/parse-remote-objects.ts"() {
2271
+ "use strict";
2272
+ init_utils();
2273
+ remoteMessagesObjectParsers = [
2274
+ new RemoteLineParser(
2275
+ /^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,
2276
+ (result, [action, count]) => {
2277
+ const key = action.toLowerCase();
2278
+ const enumeration = objectEnumerationResult(result.remoteMessages);
2279
+ Object.assign(enumeration, { [key]: asNumber(count) });
2280
+ }
2281
+ ),
2282
+ new RemoteLineParser(
2283
+ /^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,
2284
+ (result, [action, count]) => {
2285
+ const key = action.toLowerCase();
2286
+ const enumeration = objectEnumerationResult(result.remoteMessages);
2287
+ Object.assign(enumeration, { [key]: asNumber(count) });
2288
+ }
2289
+ ),
2290
+ new RemoteLineParser(
2291
+ /total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,
2292
+ (result, [total, reused, packReused]) => {
2293
+ const objects = objectEnumerationResult(result.remoteMessages);
2294
+ objects.total = asObjectCount(total);
2295
+ objects.reused = asObjectCount(reused);
2296
+ objects.packReused = asNumber(packReused);
2297
+ }
2298
+ )
2299
+ ];
2300
+ }
2301
+ });
2302
+
2303
+ // src/lib/parsers/parse-remote-messages.ts
2304
+ function parseRemoteMessages(_stdOut, stdErr) {
2305
+ return parseStringResponse({ remoteMessages: new RemoteMessageSummary() }, parsers2, stdErr);
2306
+ }
2307
+ var parsers2, RemoteMessageSummary;
2308
+ var init_parse_remote_messages = __esm({
2309
+ "src/lib/parsers/parse-remote-messages.ts"() {
2310
+ "use strict";
2311
+ init_utils();
2312
+ init_parse_remote_objects();
2313
+ parsers2 = [
2314
+ new RemoteLineParser(/^remote:\s*(.+)$/, (result, [text]) => {
2315
+ result.remoteMessages.all.push(text.trim());
2316
+ return false;
2317
+ }),
2318
+ ...remoteMessagesObjectParsers,
2319
+ new RemoteLineParser(
2320
+ [/create a (?:pull|merge) request/i, /\s(https?:\/\/\S+)$/],
2321
+ (result, [pullRequestUrl]) => {
2322
+ result.remoteMessages.pullRequestUrl = pullRequestUrl;
2323
+ }
2324
+ ),
2325
+ new RemoteLineParser(
2326
+ [/found (\d+) vulnerabilities.+\(([^)]+)\)/i, /\s(https?:\/\/\S+)$/],
2327
+ (result, [count, summary, url]) => {
2328
+ result.remoteMessages.vulnerabilities = {
2329
+ count: asNumber(count),
2330
+ summary,
2331
+ url
2332
+ };
2333
+ }
2334
+ )
2335
+ ];
2336
+ RemoteMessageSummary = class {
2337
+ constructor() {
2338
+ this.all = [];
2339
+ }
2340
+ };
2341
+ }
2342
+ });
2343
+
2344
+ // src/lib/parsers/parse-pull.ts
2345
+ function parsePullErrorResult(stdOut, stdErr) {
2346
+ const pullError = parseStringResponse(new PullFailedSummary(), errorParsers, [stdOut, stdErr]);
2347
+ return pullError.message && pullError;
2348
+ }
2349
+ var FILE_UPDATE_REGEX, SUMMARY_REGEX, ACTION_REGEX, parsers3, errorParsers, parsePullDetail, parsePullResult;
2350
+ var init_parse_pull = __esm({
2351
+ "src/lib/parsers/parse-pull.ts"() {
2352
+ "use strict";
2353
+ init_PullSummary();
2354
+ init_utils();
2355
+ init_parse_remote_messages();
2356
+ FILE_UPDATE_REGEX = /^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/;
2357
+ SUMMARY_REGEX = /(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/;
2358
+ ACTION_REGEX = /^(create|delete) mode \d+ (.+)/;
2359
+ parsers3 = [
2360
+ new LineParser(FILE_UPDATE_REGEX, (result, [file, insertions, deletions]) => {
2361
+ result.files.push(file);
2362
+ if (insertions) {
2363
+ result.insertions[file] = insertions.length;
2364
+ }
2365
+ if (deletions) {
2366
+ result.deletions[file] = deletions.length;
2367
+ }
2368
+ }),
2369
+ new LineParser(SUMMARY_REGEX, (result, [changes, , insertions, , deletions]) => {
2370
+ if (insertions !== void 0 || deletions !== void 0) {
2371
+ result.summary.changes = +changes || 0;
2372
+ result.summary.insertions = +insertions || 0;
2373
+ result.summary.deletions = +deletions || 0;
2374
+ return true;
2375
+ }
2376
+ return false;
2377
+ }),
2378
+ new LineParser(ACTION_REGEX, (result, [action, file]) => {
2379
+ append(result.files, file);
2380
+ append(action === "create" ? result.created : result.deleted, file);
2381
+ })
2382
+ ];
2383
+ errorParsers = [
2384
+ new LineParser(/^from\s(.+)$/i, (result, [remote]) => void (result.remote = remote)),
2385
+ new LineParser(/^fatal:\s(.+)$/, (result, [message]) => void (result.message = message)),
2386
+ new LineParser(
2387
+ /([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/,
2388
+ (result, [hashLocal, hashRemote, branchLocal, branchRemote]) => {
2389
+ result.branch.local = branchLocal;
2390
+ result.hash.local = hashLocal;
2391
+ result.branch.remote = branchRemote;
2392
+ result.hash.remote = hashRemote;
2393
+ }
2394
+ )
2395
+ ];
2396
+ parsePullDetail = (stdOut, stdErr) => {
2397
+ return parseStringResponse(new PullSummary(), parsers3, [stdOut, stdErr]);
2398
+ };
2399
+ parsePullResult = (stdOut, stdErr) => {
2400
+ return Object.assign(
2401
+ new PullSummary(),
2402
+ parsePullDetail(stdOut, stdErr),
2403
+ parseRemoteMessages(stdOut, stdErr)
2404
+ );
2405
+ };
2406
+ }
2407
+ });
2408
+
2409
+ // src/lib/parsers/parse-merge.ts
2410
+ var parsers4, parseMergeResult, parseMergeDetail;
2411
+ var init_parse_merge = __esm({
2412
+ "src/lib/parsers/parse-merge.ts"() {
2413
+ "use strict";
2414
+ init_MergeSummary();
2415
+ init_utils();
2416
+ init_parse_pull();
2417
+ parsers4 = [
2418
+ new LineParser(/^Auto-merging\s+(.+)$/, (summary, [autoMerge]) => {
2419
+ summary.merges.push(autoMerge);
2420
+ }),
2421
+ new LineParser(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/, (summary, [reason, file]) => {
2422
+ summary.conflicts.push(new MergeSummaryConflict(reason, file));
2423
+ }),
2424
+ new LineParser(
2425
+ /^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,
2426
+ (summary, [reason, file, deleteRef]) => {
2427
+ summary.conflicts.push(new MergeSummaryConflict(reason, file, { deleteRef }));
2428
+ }
2429
+ ),
2430
+ new LineParser(/^CONFLICT\s+\((.+)\):/, (summary, [reason]) => {
2431
+ summary.conflicts.push(new MergeSummaryConflict(reason, null));
2432
+ }),
2433
+ new LineParser(/^Automatic merge failed;\s+(.+)$/, (summary, [result]) => {
2434
+ summary.result = result;
2435
+ })
2436
+ ];
2437
+ parseMergeResult = (stdOut, stdErr) => {
2438
+ return Object.assign(parseMergeDetail(stdOut, stdErr), parsePullResult(stdOut, stdErr));
2439
+ };
2440
+ parseMergeDetail = (stdOut) => {
2441
+ return parseStringResponse(new MergeSummaryDetail(), parsers4, stdOut);
2442
+ };
2443
+ }
2444
+ });
2445
+
2446
+ // src/lib/tasks/merge.ts
2447
+ function mergeTask(customArgs) {
2448
+ if (!customArgs.length) {
2449
+ return configurationErrorTask("Git.merge requires at least one option");
2450
+ }
2451
+ return {
2452
+ commands: ["merge", ...customArgs],
2453
+ format: "utf-8",
2454
+ parser(stdOut, stdErr) {
2455
+ const merge = parseMergeResult(stdOut, stdErr);
2456
+ if (merge.failed) {
2457
+ throw new GitResponseError(merge);
2458
+ }
2459
+ return merge;
2460
+ }
2461
+ };
2462
+ }
2463
+ var init_merge = __esm({
2464
+ "src/lib/tasks/merge.ts"() {
2465
+ "use strict";
2466
+ init_git_response_error();
2467
+ init_parse_merge();
2468
+ init_task();
2469
+ }
2470
+ });
2471
+
2472
+ // src/lib/parsers/parse-push.ts
2473
+ function pushResultPushedItem(local, remote, status) {
2474
+ const deleted = status.includes("deleted");
2475
+ const tag = status.includes("tag") || /^refs\/tags/.test(local);
2476
+ const alreadyUpdated = !status.includes("new");
2477
+ return {
2478
+ deleted,
2479
+ tag,
2480
+ branch: !tag,
2481
+ new: !alreadyUpdated,
2482
+ alreadyUpdated,
2483
+ local,
2484
+ remote
2485
+ };
2486
+ }
2487
+ var parsers5, parsePushResult, parsePushDetail;
2488
+ var init_parse_push = __esm({
2489
+ "src/lib/parsers/parse-push.ts"() {
2490
+ "use strict";
2491
+ init_utils();
2492
+ init_parse_remote_messages();
2493
+ parsers5 = [
2494
+ new LineParser(/^Pushing to (.+)$/, (result, [repo]) => {
2495
+ result.repo = repo;
2496
+ }),
2497
+ new LineParser(/^updating local tracking ref '(.+)'/, (result, [local]) => {
2498
+ result.ref = {
2499
+ ...result.ref || {},
2500
+ local
2501
+ };
2502
+ }),
2503
+ new LineParser(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/, (result, [local, remote, type]) => {
2504
+ result.pushed.push(pushResultPushedItem(local, remote, type));
2505
+ }),
2506
+ new LineParser(
2507
+ /^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,
2508
+ (result, [local, remote, remoteName]) => {
2509
+ result.branch = {
2510
+ ...result.branch || {},
2511
+ local,
2512
+ remote,
2513
+ remoteName
2514
+ };
2515
+ }
2516
+ ),
2517
+ new LineParser(
2518
+ /^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/,
2519
+ (result, [local, remote, from, to]) => {
2520
+ result.update = {
2521
+ head: {
2522
+ local,
2523
+ remote
2524
+ },
2525
+ hash: {
2526
+ from,
2527
+ to
2528
+ }
2529
+ };
2530
+ }
2531
+ )
2532
+ ];
2533
+ parsePushResult = (stdOut, stdErr) => {
2534
+ const pushDetail = parsePushDetail(stdOut, stdErr);
2535
+ const responseDetail = parseRemoteMessages(stdOut, stdErr);
2536
+ return {
2537
+ ...pushDetail,
2538
+ ...responseDetail
2539
+ };
2540
+ };
2541
+ parsePushDetail = (stdOut, stdErr) => {
2542
+ return parseStringResponse({ pushed: [] }, parsers5, [stdOut, stdErr]);
2543
+ };
2544
+ }
2545
+ });
2546
+
2547
+ // src/lib/tasks/push.ts
2548
+ var push_exports = {};
2549
+ __export(push_exports, {
2550
+ pushTagsTask: () => pushTagsTask,
2551
+ pushTask: () => pushTask
2552
+ });
2553
+ function pushTagsTask(ref = {}, customArgs) {
2554
+ append(customArgs, "--tags");
2555
+ return pushTask(ref, customArgs);
2556
+ }
2557
+ function pushTask(ref = {}, customArgs) {
2558
+ const commands = ["push", ...customArgs];
2559
+ if (ref.branch) {
2560
+ commands.splice(1, 0, ref.branch);
2561
+ }
2562
+ if (ref.remote) {
2563
+ commands.splice(1, 0, ref.remote);
2564
+ }
2565
+ remove(commands, "-v");
2566
+ append(commands, "--verbose");
2567
+ append(commands, "--porcelain");
2568
+ return {
2569
+ commands,
2570
+ format: "utf-8",
2571
+ parser: parsePushResult
2572
+ };
2573
+ }
2574
+ var init_push = __esm({
2575
+ "src/lib/tasks/push.ts"() {
2576
+ "use strict";
2577
+ init_parse_push();
2578
+ init_utils();
2579
+ }
2580
+ });
2581
+
2582
+ // src/lib/tasks/show.ts
2583
+ function show_default() {
2584
+ return {
2585
+ showBuffer() {
2586
+ const commands = ["show", ...getTrailingOptions(arguments, 1)];
2587
+ if (!commands.includes("--binary")) {
2588
+ commands.splice(1, 0, "--binary");
2589
+ }
2590
+ return this._runTask(
2591
+ straightThroughBufferTask(commands),
2592
+ trailingFunctionArgument(arguments)
2593
+ );
2594
+ },
2595
+ show() {
2596
+ const commands = ["show", ...getTrailingOptions(arguments, 1)];
2597
+ return this._runTask(
2598
+ straightThroughStringTask(commands),
2599
+ trailingFunctionArgument(arguments)
2600
+ );
2601
+ }
2602
+ };
2603
+ }
2604
+ var init_show = __esm({
2605
+ "src/lib/tasks/show.ts"() {
2606
+ "use strict";
2607
+ init_utils();
2608
+ init_task();
2609
+ }
2610
+ });
2611
+
2612
+ // src/lib/responses/FileStatusSummary.ts
2613
+ var fromPathRegex, FileStatusSummary;
2614
+ var init_FileStatusSummary = __esm({
2615
+ "src/lib/responses/FileStatusSummary.ts"() {
2616
+ "use strict";
2617
+ fromPathRegex = /^(.+)\0(.+)$/;
2618
+ FileStatusSummary = class {
2619
+ constructor(path, index, working_dir) {
2620
+ this.path = path;
2621
+ this.index = index;
2622
+ this.working_dir = working_dir;
2623
+ if (index === "R" || working_dir === "R") {
2624
+ const detail = fromPathRegex.exec(path) || [null, path, path];
2625
+ this.from = detail[2] || "";
2626
+ this.path = detail[1] || "";
2627
+ }
2628
+ }
2629
+ };
2630
+ }
2631
+ });
2632
+
2633
+ // src/lib/responses/StatusSummary.ts
2634
+ function renamedFile(line) {
2635
+ const [to, from] = line.split(NULL);
2636
+ return {
2637
+ from: from || to,
2638
+ to
2639
+ };
2640
+ }
2641
+ function parser3(indexX, indexY, handler) {
2642
+ return [`${indexX}${indexY}`, handler];
2643
+ }
2644
+ function conflicts(indexX, ...indexY) {
2645
+ return indexY.map((y) => parser3(indexX, y, (result, file) => result.conflicted.push(file)));
2646
+ }
2647
+ function splitLine(result, lineStr) {
2648
+ const trimmed2 = lineStr.trim();
2649
+ switch (" ") {
2650
+ case trimmed2.charAt(2):
2651
+ return data(trimmed2.charAt(0), trimmed2.charAt(1), trimmed2.slice(3));
2652
+ case trimmed2.charAt(1):
2653
+ return data(" " /* NONE */, trimmed2.charAt(0), trimmed2.slice(2));
2654
+ default:
2655
+ return;
2656
+ }
2657
+ function data(index, workingDir, path) {
2658
+ const raw = `${index}${workingDir}`;
2659
+ const handler = parsers6.get(raw);
2660
+ if (handler) {
2661
+ handler(result, path);
2662
+ }
2663
+ if (raw !== "##" && raw !== "!!") {
2664
+ result.files.push(new FileStatusSummary(path, index, workingDir));
2665
+ }
2666
+ }
2667
+ }
2668
+ var StatusSummary, parsers6, parseStatusSummary;
2669
+ var init_StatusSummary = __esm({
2670
+ "src/lib/responses/StatusSummary.ts"() {
2671
+ "use strict";
2672
+ init_utils();
2673
+ init_FileStatusSummary();
2674
+ StatusSummary = class {
2675
+ constructor() {
2676
+ this.not_added = [];
2677
+ this.conflicted = [];
2678
+ this.created = [];
2679
+ this.deleted = [];
2680
+ this.ignored = void 0;
2681
+ this.modified = [];
2682
+ this.renamed = [];
2683
+ this.files = [];
2684
+ this.staged = [];
2685
+ this.ahead = 0;
2686
+ this.behind = 0;
2687
+ this.current = null;
2688
+ this.tracking = null;
2689
+ this.detached = false;
2690
+ this.isClean = () => {
2691
+ return !this.files.length;
2692
+ };
2693
+ }
2694
+ };
2695
+ parsers6 = new Map([
2696
+ parser3(
2697
+ " " /* NONE */,
2698
+ "A" /* ADDED */,
2699
+ (result, file) => result.created.push(file)
2700
+ ),
2701
+ parser3(
2702
+ " " /* NONE */,
2703
+ "D" /* DELETED */,
2704
+ (result, file) => result.deleted.push(file)
2705
+ ),
2706
+ parser3(
2707
+ " " /* NONE */,
2708
+ "M" /* MODIFIED */,
2709
+ (result, file) => result.modified.push(file)
2710
+ ),
2711
+ parser3("A" /* ADDED */, " " /* NONE */, (result, file) => {
2712
+ result.created.push(file);
2713
+ result.staged.push(file);
2714
+ }),
2715
+ parser3("A" /* ADDED */, "M" /* MODIFIED */, (result, file) => {
2716
+ result.created.push(file);
2717
+ result.staged.push(file);
2718
+ result.modified.push(file);
2719
+ }),
2720
+ parser3("D" /* DELETED */, " " /* NONE */, (result, file) => {
2721
+ result.deleted.push(file);
2722
+ result.staged.push(file);
2723
+ }),
2724
+ parser3("M" /* MODIFIED */, " " /* NONE */, (result, file) => {
2725
+ result.modified.push(file);
2726
+ result.staged.push(file);
2727
+ }),
2728
+ parser3("M" /* MODIFIED */, "M" /* MODIFIED */, (result, file) => {
2729
+ result.modified.push(file);
2730
+ result.staged.push(file);
2731
+ }),
2732
+ parser3("R" /* RENAMED */, " " /* NONE */, (result, file) => {
2733
+ result.renamed.push(renamedFile(file));
2734
+ }),
2735
+ parser3("R" /* RENAMED */, "M" /* MODIFIED */, (result, file) => {
2736
+ const renamed = renamedFile(file);
2737
+ result.renamed.push(renamed);
2738
+ result.modified.push(renamed.to);
2739
+ }),
2740
+ parser3("!" /* IGNORED */, "!" /* IGNORED */, (_result, _file) => {
2741
+ (_result.ignored = _result.ignored || []).push(_file);
2742
+ }),
2743
+ parser3(
2744
+ "?" /* UNTRACKED */,
2745
+ "?" /* UNTRACKED */,
2746
+ (result, file) => result.not_added.push(file)
2747
+ ),
2748
+ ...conflicts("A" /* ADDED */, "A" /* ADDED */, "U" /* UNMERGED */),
2749
+ ...conflicts(
2750
+ "D" /* DELETED */,
2751
+ "D" /* DELETED */,
2752
+ "U" /* UNMERGED */
2753
+ ),
2754
+ ...conflicts(
2755
+ "U" /* UNMERGED */,
2756
+ "A" /* ADDED */,
2757
+ "D" /* DELETED */,
2758
+ "U" /* UNMERGED */
2759
+ ),
2760
+ [
2761
+ "##",
2762
+ (result, line) => {
2763
+ const aheadReg = /ahead (\d+)/;
2764
+ const behindReg = /behind (\d+)/;
2765
+ const currentReg = /^(.+?(?=(?:\.{3}|\s|$)))/;
2766
+ const trackingReg = /\.{3}(\S*)/;
2767
+ const onEmptyBranchReg = /\son\s(\S+?)(?=\.{3}|$)/;
2768
+ let regexResult = aheadReg.exec(line);
2769
+ result.ahead = regexResult && +regexResult[1] || 0;
2770
+ regexResult = behindReg.exec(line);
2771
+ result.behind = regexResult && +regexResult[1] || 0;
2772
+ regexResult = currentReg.exec(line);
2773
+ result.current = filterType(regexResult?.[1], filterString, null);
2774
+ regexResult = trackingReg.exec(line);
2775
+ result.tracking = filterType(regexResult?.[1], filterString, null);
2776
+ regexResult = onEmptyBranchReg.exec(line);
2777
+ if (regexResult) {
2778
+ result.current = filterType(regexResult?.[1], filterString, result.current);
2779
+ }
2780
+ result.detached = /\(no branch\)/.test(line);
2781
+ }
2782
+ ]
2783
+ ]);
2784
+ parseStatusSummary = function(text) {
2785
+ const lines = text.split(NULL);
2786
+ const status = new StatusSummary();
2787
+ for (let i = 0, l = lines.length; i < l; ) {
2788
+ let line = lines[i++].trim();
2789
+ if (!line) {
2790
+ continue;
2791
+ }
2792
+ if (line.charAt(0) === "R" /* RENAMED */) {
2793
+ line += NULL + (lines[i++] || "");
2794
+ }
2795
+ splitLine(status, line);
2796
+ }
2797
+ return status;
2798
+ };
2799
+ }
2800
+ });
2801
+
2802
+ // src/lib/tasks/status.ts
2803
+ function statusTask(customArgs) {
2804
+ const commands = [
2805
+ "status",
2806
+ "--porcelain",
2807
+ "-b",
2808
+ "-u",
2809
+ "--null",
2810
+ ...customArgs.filter((arg) => !ignoredOptions.includes(arg))
2811
+ ];
2812
+ return {
2813
+ format: "utf-8",
2814
+ commands,
2815
+ parser(text) {
2816
+ return parseStatusSummary(text);
2817
+ }
2818
+ };
2819
+ }
2820
+ var ignoredOptions;
2821
+ var init_status = __esm({
2822
+ "src/lib/tasks/status.ts"() {
2823
+ "use strict";
2824
+ init_StatusSummary();
2825
+ ignoredOptions = ["--null", "-z"];
2826
+ }
2827
+ });
2828
+
2829
+ // src/lib/tasks/version.ts
2830
+ function versionResponse(major = 0, minor = 0, patch = 0, agent = "", installed = true) {
2831
+ return Object.defineProperty(
2832
+ {
2833
+ major,
2834
+ minor,
2835
+ patch,
2836
+ agent,
2837
+ installed
2838
+ },
2839
+ "toString",
2840
+ {
2841
+ value() {
2842
+ return `${this.major}.${this.minor}.${this.patch}`;
2843
+ },
2844
+ configurable: false,
2845
+ enumerable: false
2846
+ }
2847
+ );
2848
+ }
2849
+ function notInstalledResponse() {
2850
+ return versionResponse(0, 0, 0, "", false);
2851
+ }
2852
+ function version_default() {
2853
+ return {
2854
+ version() {
2855
+ return this._runTask({
2856
+ commands: ["--version"],
2857
+ format: "utf-8",
2858
+ parser: versionParser,
2859
+ onError(result, error, done, fail) {
2860
+ if (result.exitCode === -2 /* NOT_FOUND */) {
2861
+ return done(Buffer.from(NOT_INSTALLED));
2862
+ }
2863
+ fail(error);
2864
+ }
2865
+ });
2866
+ }
2867
+ };
2868
+ }
2869
+ function versionParser(stdOut) {
2870
+ if (stdOut === NOT_INSTALLED) {
2871
+ return notInstalledResponse();
2872
+ }
2873
+ return parseStringResponse(versionResponse(0, 0, 0, stdOut), parsers7, stdOut);
2874
+ }
2875
+ var NOT_INSTALLED, parsers7;
2876
+ var init_version = __esm({
2877
+ "src/lib/tasks/version.ts"() {
2878
+ "use strict";
2879
+ init_utils();
2880
+ NOT_INSTALLED = "installed=false";
2881
+ parsers7 = [
2882
+ new LineParser(
2883
+ /version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,
2884
+ (result, [major, minor, patch, agent = ""]) => {
2885
+ Object.assign(
2886
+ result,
2887
+ versionResponse(asNumber(major), asNumber(minor), asNumber(patch), agent)
2888
+ );
2889
+ }
2890
+ ),
2891
+ new LineParser(
2892
+ /version (\d+)\.(\d+)\.(\D+)(.+)?$/,
2893
+ (result, [major, minor, patch, agent = ""]) => {
2894
+ Object.assign(result, versionResponse(asNumber(major), asNumber(minor), patch, agent));
2895
+ }
2896
+ )
2897
+ ];
2898
+ }
2899
+ });
2900
+
2901
+ // src/lib/tasks/clone.ts
2902
+ import { pathspec as pathspec3 } from "@simple-git/args-pathspec";
2903
+ function createCloneTask(api, task, repoPath, ...args) {
2904
+ if (!filterString(repoPath)) {
2905
+ return configurationErrorTask(`git.${api}() requires a string 'repoPath'`);
2906
+ }
2907
+ return task(repoPath, filterType(args[0], filterString), getTrailingOptions(arguments));
2908
+ }
2909
+ function clone_default() {
2910
+ return {
2911
+ clone(repo, ...rest) {
2912
+ return this._runTask(
2913
+ createCloneTask("clone", cloneTask, filterType(repo, filterString), ...rest),
2914
+ trailingFunctionArgument(arguments)
2915
+ );
2916
+ },
2917
+ mirror(repo, ...rest) {
2918
+ return this._runTask(
2919
+ createCloneTask("mirror", cloneMirrorTask, filterType(repo, filterString), ...rest),
2920
+ trailingFunctionArgument(arguments)
2921
+ );
2922
+ }
2923
+ };
2924
+ }
2925
+ var cloneTask, cloneMirrorTask;
2926
+ var init_clone = __esm({
2927
+ "src/lib/tasks/clone.ts"() {
2928
+ "use strict";
2929
+ init_task();
2930
+ init_utils();
2931
+ cloneTask = (repo, directory, customArgs) => {
2932
+ const commands = ["clone", ...customArgs];
2933
+ filterString(repo) && commands.push(pathspec3(repo));
2934
+ filterString(directory) && commands.push(pathspec3(directory));
2935
+ return straightThroughStringTask(commands);
2936
+ };
2937
+ cloneMirrorTask = (repo, directory, customArgs) => {
2938
+ append(customArgs, "--mirror");
2939
+ return cloneTask(repo, directory, customArgs);
2940
+ };
2941
+ }
2942
+ });
2943
+
2944
+ // src/lib/simple-git-api.ts
2945
+ var simple_git_api_exports = {};
2946
+ __export(simple_git_api_exports, {
2947
+ SimpleGitApi: () => SimpleGitApi
2948
+ });
2949
+ var SimpleGitApi;
2950
+ var init_simple_git_api = __esm({
2951
+ "src/lib/simple-git-api.ts"() {
2952
+ "use strict";
2953
+ init_task_callback();
2954
+ init_change_working_directory();
2955
+ init_checkout();
2956
+ init_count_objects();
2957
+ init_commit();
2958
+ init_config();
2959
+ init_first_commit();
2960
+ init_grep();
2961
+ init_hash_object();
2962
+ init_init();
2963
+ init_log();
2964
+ init_merge();
2965
+ init_push();
2966
+ init_show();
2967
+ init_status();
2968
+ init_task();
2969
+ init_version();
2970
+ init_utils();
2971
+ init_clone();
2972
+ SimpleGitApi = class {
2973
+ constructor(_executor) {
2974
+ this._executor = _executor;
2975
+ }
2976
+ _runTask(task, then) {
2977
+ const chain = this._executor.chain();
2978
+ const promise = chain.push(task);
2979
+ if (then) {
2980
+ taskCallback(task, promise, then);
2981
+ }
2982
+ return Object.create(this, {
2983
+ then: { value: promise.then.bind(promise) },
2984
+ catch: { value: promise.catch.bind(promise) },
2985
+ _executor: { value: chain }
2986
+ });
2987
+ }
2988
+ add(files) {
2989
+ return this._runTask(
2990
+ straightThroughStringTask(["add", ...asArray(files)]),
2991
+ trailingFunctionArgument(arguments)
2992
+ );
2993
+ }
2994
+ cwd(directory) {
2995
+ const next = trailingFunctionArgument(arguments);
2996
+ if (typeof directory === "string") {
2997
+ return this._runTask(changeWorkingDirectoryTask(directory, this._executor), next);
2998
+ }
2999
+ if (typeof directory?.path === "string") {
3000
+ return this._runTask(
3001
+ changeWorkingDirectoryTask(
3002
+ directory.path,
3003
+ directory.root && this._executor || void 0
3004
+ ),
3005
+ next
3006
+ );
3007
+ }
3008
+ return this._runTask(
3009
+ configurationErrorTask("Git.cwd: workingDirectory must be supplied as a string"),
3010
+ next
3011
+ );
3012
+ }
3013
+ hashObject(path, write) {
3014
+ return this._runTask(
3015
+ hashObjectTask(path, write === true),
3016
+ trailingFunctionArgument(arguments)
3017
+ );
3018
+ }
3019
+ init(bare) {
3020
+ return this._runTask(
3021
+ initTask(bare === true, this._executor.cwd, getTrailingOptions(arguments)),
3022
+ trailingFunctionArgument(arguments)
3023
+ );
3024
+ }
3025
+ merge() {
3026
+ return this._runTask(
3027
+ mergeTask(getTrailingOptions(arguments)),
3028
+ trailingFunctionArgument(arguments)
3029
+ );
3030
+ }
3031
+ mergeFromTo(remote, branch) {
3032
+ if (!(filterString(remote) && filterString(branch))) {
3033
+ return this._runTask(
3034
+ configurationErrorTask(
3035
+ `Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`
3036
+ )
3037
+ );
3038
+ }
3039
+ return this._runTask(
3040
+ mergeTask([remote, branch, ...getTrailingOptions(arguments)]),
3041
+ trailingFunctionArgument(arguments, false)
3042
+ );
3043
+ }
3044
+ outputHandler(handler) {
3045
+ this._executor.outputHandler = handler;
3046
+ return this;
3047
+ }
3048
+ push() {
3049
+ const task = pushTask(
3050
+ {
3051
+ remote: filterType(arguments[0], filterString),
3052
+ branch: filterType(arguments[1], filterString)
3053
+ },
3054
+ getTrailingOptions(arguments)
3055
+ );
3056
+ return this._runTask(task, trailingFunctionArgument(arguments));
3057
+ }
3058
+ stash() {
3059
+ return this._runTask(
3060
+ straightThroughStringTask(["stash", ...getTrailingOptions(arguments)]),
3061
+ trailingFunctionArgument(arguments)
3062
+ );
3063
+ }
3064
+ status() {
3065
+ return this._runTask(
3066
+ statusTask(getTrailingOptions(arguments)),
3067
+ trailingFunctionArgument(arguments)
3068
+ );
3069
+ }
3070
+ };
3071
+ Object.assign(
3072
+ SimpleGitApi.prototype,
3073
+ checkout_default(),
3074
+ clone_default(),
3075
+ commit_default(),
3076
+ config_default(),
3077
+ count_objects_default(),
3078
+ first_commit_default(),
3079
+ grep_default(),
3080
+ log_default(),
3081
+ show_default(),
3082
+ version_default()
3083
+ );
3084
+ }
3085
+ });
3086
+
3087
+ // src/lib/runners/scheduler.ts
3088
+ var scheduler_exports = {};
3089
+ __export(scheduler_exports, {
3090
+ Scheduler: () => Scheduler
3091
+ });
3092
+ import { createDeferred } from "@kwsites/promise-deferred";
3093
+ var createScheduledTask, Scheduler;
3094
+ var init_scheduler = __esm({
3095
+ "src/lib/runners/scheduler.ts"() {
3096
+ "use strict";
3097
+ init_utils();
3098
+ init_git_logger();
3099
+ createScheduledTask = /* @__PURE__ */ (() => {
3100
+ let id = 0;
3101
+ return () => {
3102
+ id++;
3103
+ const { promise, done } = createDeferred();
3104
+ return {
3105
+ promise,
3106
+ done,
3107
+ id
3108
+ };
3109
+ };
3110
+ })();
3111
+ Scheduler = class {
3112
+ constructor(concurrency = 2) {
3113
+ this.concurrency = concurrency;
3114
+ this.logger = createLogger("", "scheduler");
3115
+ this.pending = [];
3116
+ this.running = [];
3117
+ this.logger(`Constructed, concurrency=%s`, concurrency);
3118
+ }
3119
+ schedule() {
3120
+ if (!this.pending.length || this.running.length >= this.concurrency) {
3121
+ this.logger(
3122
+ `Schedule attempt ignored, pending=%s running=%s concurrency=%s`,
3123
+ this.pending.length,
3124
+ this.running.length,
3125
+ this.concurrency
3126
+ );
3127
+ return;
3128
+ }
3129
+ const task = append(this.running, this.pending.shift());
3130
+ this.logger(`Attempting id=%s`, task.id);
3131
+ task.done(() => {
3132
+ this.logger(`Completing id=`, task.id);
3133
+ remove(this.running, task);
3134
+ this.schedule();
3135
+ });
3136
+ }
3137
+ next() {
3138
+ const { promise, id } = append(this.pending, createScheduledTask());
3139
+ this.logger(`Scheduling id=%s`, id);
3140
+ this.schedule();
3141
+ return promise;
3142
+ }
3143
+ };
3144
+ }
3145
+ });
3146
+
3147
+ // src/lib/tasks/apply-patch.ts
3148
+ var apply_patch_exports = {};
3149
+ __export(apply_patch_exports, {
3150
+ applyPatchTask: () => applyPatchTask
3151
+ });
3152
+ function applyPatchTask(patches, customArgs) {
3153
+ return straightThroughStringTask(["apply", ...customArgs, ...patches]);
3154
+ }
3155
+ var init_apply_patch = __esm({
3156
+ "src/lib/tasks/apply-patch.ts"() {
3157
+ "use strict";
3158
+ init_task();
3159
+ }
3160
+ });
3161
+
3162
+ // src/lib/responses/BranchDeleteSummary.ts
3163
+ function branchDeletionSuccess(branch, hash) {
3164
+ return {
3165
+ branch,
3166
+ hash,
3167
+ success: true
3168
+ };
3169
+ }
3170
+ function branchDeletionFailure(branch) {
3171
+ return {
3172
+ branch,
3173
+ hash: null,
3174
+ success: false
3175
+ };
3176
+ }
3177
+ var BranchDeletionBatch;
3178
+ var init_BranchDeleteSummary = __esm({
3179
+ "src/lib/responses/BranchDeleteSummary.ts"() {
3180
+ "use strict";
3181
+ BranchDeletionBatch = class {
3182
+ constructor() {
3183
+ this.all = [];
3184
+ this.branches = {};
3185
+ this.errors = [];
3186
+ }
3187
+ get success() {
3188
+ return !this.errors.length;
3189
+ }
3190
+ };
3191
+ }
3192
+ });
3193
+
3194
+ // src/lib/parsers/parse-branch-delete.ts
3195
+ function hasBranchDeletionError(data, processExitCode) {
3196
+ return processExitCode === 1 /* ERROR */ && deleteErrorRegex.test(data);
3197
+ }
3198
+ var deleteSuccessRegex, deleteErrorRegex, parsers8, parseBranchDeletions;
3199
+ var init_parse_branch_delete = __esm({
3200
+ "src/lib/parsers/parse-branch-delete.ts"() {
3201
+ "use strict";
3202
+ init_BranchDeleteSummary();
3203
+ init_utils();
3204
+ deleteSuccessRegex = /(\S+)\s+\(\S+\s([^)]+)\)/;
3205
+ deleteErrorRegex = /^error[^']+'([^']+)'/m;
3206
+ parsers8 = [
3207
+ new LineParser(deleteSuccessRegex, (result, [branch, hash]) => {
3208
+ const deletion = branchDeletionSuccess(branch, hash);
3209
+ result.all.push(deletion);
3210
+ result.branches[branch] = deletion;
3211
+ }),
3212
+ new LineParser(deleteErrorRegex, (result, [branch]) => {
3213
+ const deletion = branchDeletionFailure(branch);
3214
+ result.errors.push(deletion);
3215
+ result.all.push(deletion);
3216
+ result.branches[branch] = deletion;
3217
+ })
3218
+ ];
3219
+ parseBranchDeletions = (stdOut, stdErr) => {
3220
+ return parseStringResponse(new BranchDeletionBatch(), parsers8, [stdOut, stdErr]);
3221
+ };
3222
+ }
3223
+ });
3224
+
3225
+ // src/lib/responses/BranchSummary.ts
3226
+ var BranchSummaryResult;
3227
+ var init_BranchSummary = __esm({
3228
+ "src/lib/responses/BranchSummary.ts"() {
3229
+ "use strict";
3230
+ BranchSummaryResult = class {
3231
+ constructor() {
3232
+ this.all = [];
3233
+ this.branches = {};
3234
+ this.current = "";
3235
+ this.detached = false;
3236
+ }
3237
+ push(status, detached, name, commit, label) {
3238
+ if (status === "*" /* CURRENT */) {
3239
+ this.detached = detached;
3240
+ this.current = name;
3241
+ }
3242
+ this.all.push(name);
3243
+ this.branches[name] = {
3244
+ current: status === "*" /* CURRENT */,
3245
+ linkedWorkTree: status === "+" /* LINKED */,
3246
+ name,
3247
+ commit,
3248
+ label
3249
+ };
3250
+ }
3251
+ };
3252
+ }
3253
+ });
3254
+
3255
+ // src/lib/parsers/parse-branch.ts
3256
+ function branchStatus(input) {
3257
+ return input ? input.charAt(0) : "";
3258
+ }
3259
+ function parseBranchSummary(stdOut, currentOnly = false) {
3260
+ return parseStringResponse(
3261
+ new BranchSummaryResult(),
3262
+ currentOnly ? [currentBranchParser] : parsers9,
3263
+ stdOut
3264
+ );
3265
+ }
3266
+ var parsers9, currentBranchParser;
3267
+ var init_parse_branch = __esm({
3268
+ "src/lib/parsers/parse-branch.ts"() {
3269
+ "use strict";
3270
+ init_BranchSummary();
3271
+ init_utils();
3272
+ parsers9 = [
3273
+ new LineParser(
3274
+ /^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,
3275
+ (result, [current, name, commit, label]) => {
3276
+ result.push(branchStatus(current), true, name, commit, label);
3277
+ }
3278
+ ),
3279
+ new LineParser(
3280
+ /^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,
3281
+ (result, [current, name, commit, label]) => {
3282
+ result.push(branchStatus(current), false, name, commit, label);
3283
+ }
3284
+ )
3285
+ ];
3286
+ currentBranchParser = new LineParser(/^(\S+)$/s, (result, [name]) => {
3287
+ result.push("*" /* CURRENT */, false, name, "", "");
3288
+ });
3289
+ }
3290
+ });
3291
+
3292
+ // src/lib/tasks/branch.ts
3293
+ var branch_exports = {};
3294
+ __export(branch_exports, {
3295
+ branchLocalTask: () => branchLocalTask,
3296
+ branchTask: () => branchTask,
3297
+ containsDeleteBranchCommand: () => containsDeleteBranchCommand,
3298
+ deleteBranchTask: () => deleteBranchTask,
3299
+ deleteBranchesTask: () => deleteBranchesTask
3300
+ });
3301
+ function containsDeleteBranchCommand(commands) {
3302
+ const deleteCommands = ["-d", "-D", "--delete"];
3303
+ return commands.some((command) => deleteCommands.includes(command));
3304
+ }
3305
+ function branchTask(customArgs) {
3306
+ const isDelete = containsDeleteBranchCommand(customArgs);
3307
+ const isCurrentOnly = customArgs.includes("--show-current");
3308
+ const commands = ["branch", ...customArgs];
3309
+ if (commands.length === 1) {
3310
+ commands.push("-a");
3311
+ }
3312
+ if (!commands.includes("-v")) {
3313
+ commands.splice(1, 0, "-v");
3314
+ }
3315
+ return {
3316
+ format: "utf-8",
3317
+ commands,
3318
+ parser(stdOut, stdErr) {
3319
+ if (isDelete) {
3320
+ return parseBranchDeletions(stdOut, stdErr).all[0];
3321
+ }
3322
+ return parseBranchSummary(stdOut, isCurrentOnly);
3323
+ }
3324
+ };
3325
+ }
3326
+ function branchLocalTask() {
3327
+ return {
3328
+ format: "utf-8",
3329
+ commands: ["branch", "-v"],
3330
+ parser(stdOut) {
3331
+ return parseBranchSummary(stdOut);
3332
+ }
3333
+ };
3334
+ }
3335
+ function deleteBranchesTask(branches, forceDelete = false) {
3336
+ return {
3337
+ format: "utf-8",
3338
+ commands: ["branch", "-v", forceDelete ? "-D" : "-d", ...branches],
3339
+ parser(stdOut, stdErr) {
3340
+ return parseBranchDeletions(stdOut, stdErr);
3341
+ },
3342
+ onError({ exitCode, stdOut }, error, done, fail) {
3343
+ if (!hasBranchDeletionError(String(error), exitCode)) {
3344
+ return fail(error);
3345
+ }
3346
+ done(stdOut);
3347
+ }
3348
+ };
3349
+ }
3350
+ function deleteBranchTask(branch, forceDelete = false) {
3351
+ const task = {
3352
+ format: "utf-8",
3353
+ commands: ["branch", "-v", forceDelete ? "-D" : "-d", branch],
3354
+ parser(stdOut, stdErr) {
3355
+ return parseBranchDeletions(stdOut, stdErr).branches[branch];
3356
+ },
3357
+ onError({ exitCode, stdErr, stdOut }, error, _, fail) {
3358
+ if (!hasBranchDeletionError(String(error), exitCode)) {
3359
+ return fail(error);
3360
+ }
3361
+ throw new GitResponseError(
3362
+ task.parser(bufferToString(stdOut), bufferToString(stdErr)),
3363
+ String(error)
3364
+ );
3365
+ }
3366
+ };
3367
+ return task;
3368
+ }
3369
+ var init_branch = __esm({
3370
+ "src/lib/tasks/branch.ts"() {
3371
+ "use strict";
3372
+ init_git_response_error();
3373
+ init_parse_branch_delete();
3374
+ init_parse_branch();
3375
+ init_utils();
3376
+ }
3377
+ });
3378
+
3379
+ // src/lib/responses/CheckIgnore.ts
3380
+ import { normalize } from "node:path";
3381
+ function toPath(input) {
3382
+ const path = input.trim().replace(/^["']|["']$/g, "");
3383
+ return path && normalize(path);
3384
+ }
3385
+ var parseCheckIgnore;
3386
+ var init_CheckIgnore = __esm({
3387
+ "src/lib/responses/CheckIgnore.ts"() {
3388
+ "use strict";
3389
+ parseCheckIgnore = (text) => {
3390
+ return text.split(/\n/g).map(toPath).filter(Boolean);
3391
+ };
3392
+ }
3393
+ });
3394
+
3395
+ // src/lib/tasks/check-ignore.ts
3396
+ var check_ignore_exports = {};
3397
+ __export(check_ignore_exports, {
3398
+ checkIgnoreTask: () => checkIgnoreTask
3399
+ });
3400
+ function checkIgnoreTask(paths) {
3401
+ return {
3402
+ commands: ["check-ignore", ...paths],
3403
+ format: "utf-8",
3404
+ parser: parseCheckIgnore
3405
+ };
3406
+ }
3407
+ var init_check_ignore = __esm({
3408
+ "src/lib/tasks/check-ignore.ts"() {
3409
+ "use strict";
3410
+ init_CheckIgnore();
3411
+ }
3412
+ });
3413
+
3414
+ // src/lib/parsers/parse-fetch.ts
3415
+ function parseFetchResult(stdOut, stdErr) {
3416
+ const result = {
3417
+ raw: stdOut,
3418
+ remote: null,
3419
+ branches: [],
3420
+ tags: [],
3421
+ updated: [],
3422
+ deleted: []
3423
+ };
3424
+ return parseStringResponse(result, parsers10, [stdOut, stdErr]);
3425
+ }
3426
+ var parsers10;
3427
+ var init_parse_fetch = __esm({
3428
+ "src/lib/parsers/parse-fetch.ts"() {
3429
+ "use strict";
3430
+ init_utils();
3431
+ parsers10 = [
3432
+ new LineParser(/From (.+)$/, (result, [remote]) => {
3433
+ result.remote = remote;
3434
+ }),
3435
+ new LineParser(/\* \[new branch]\s+(\S+)\s*-> (.+)$/, (result, [name, tracking]) => {
3436
+ result.branches.push({
3437
+ name,
3438
+ tracking
3439
+ });
3440
+ }),
3441
+ new LineParser(/\* \[new tag]\s+(\S+)\s*-> (.+)$/, (result, [name, tracking]) => {
3442
+ result.tags.push({
3443
+ name,
3444
+ tracking
3445
+ });
3446
+ }),
3447
+ new LineParser(/- \[deleted]\s+\S+\s*-> (.+)$/, (result, [tracking]) => {
3448
+ result.deleted.push({
3449
+ tracking
3450
+ });
3451
+ }),
3452
+ new LineParser(
3453
+ /\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,
3454
+ (result, [from, to, name, tracking]) => {
3455
+ result.updated.push({
3456
+ name,
3457
+ tracking,
3458
+ to,
3459
+ from
3460
+ });
3461
+ }
3462
+ )
3463
+ ];
3464
+ }
3465
+ });
3466
+
3467
+ // src/lib/tasks/fetch.ts
3468
+ var fetch_exports = {};
3469
+ __export(fetch_exports, {
3470
+ fetchTask: () => fetchTask
3471
+ });
3472
+ function disallowedCommand(command) {
3473
+ return /^--upload-pack(=|$)/.test(command);
3474
+ }
3475
+ function fetchTask(remote, branch, customArgs) {
3476
+ const commands = ["fetch", ...customArgs];
3477
+ if (remote && branch) {
3478
+ commands.push(remote, branch);
3479
+ }
3480
+ const banned = commands.find(disallowedCommand);
3481
+ if (banned) {
3482
+ return configurationErrorTask(`git.fetch: potential exploit argument blocked.`);
3483
+ }
3484
+ return {
3485
+ commands,
3486
+ format: "utf-8",
3487
+ parser: parseFetchResult
3488
+ };
3489
+ }
3490
+ var init_fetch = __esm({
3491
+ "src/lib/tasks/fetch.ts"() {
3492
+ "use strict";
3493
+ init_parse_fetch();
3494
+ init_task();
3495
+ }
3496
+ });
3497
+
3498
+ // src/lib/parsers/parse-move.ts
3499
+ function parseMoveResult(stdOut) {
3500
+ return parseStringResponse({ moves: [] }, parsers11, stdOut);
3501
+ }
3502
+ var parsers11;
3503
+ var init_parse_move = __esm({
3504
+ "src/lib/parsers/parse-move.ts"() {
3505
+ "use strict";
3506
+ init_utils();
3507
+ parsers11 = [
3508
+ new LineParser(/^Renaming (.+) to (.+)$/, (result, [from, to]) => {
3509
+ result.moves.push({ from, to });
3510
+ })
3511
+ ];
3512
+ }
3513
+ });
3514
+
3515
+ // src/lib/tasks/move.ts
3516
+ var move_exports = {};
3517
+ __export(move_exports, {
3518
+ moveTask: () => moveTask
3519
+ });
3520
+ function moveTask(from, to) {
3521
+ return {
3522
+ commands: ["mv", "-v", ...asArray(from), to],
3523
+ format: "utf-8",
3524
+ parser: parseMoveResult
3525
+ };
3526
+ }
3527
+ var init_move = __esm({
3528
+ "src/lib/tasks/move.ts"() {
3529
+ "use strict";
3530
+ init_parse_move();
3531
+ init_utils();
3532
+ }
3533
+ });
3534
+
3535
+ // src/lib/tasks/pull.ts
3536
+ var pull_exports = {};
3537
+ __export(pull_exports, {
3538
+ pullTask: () => pullTask
3539
+ });
3540
+ function pullTask(remote, branch, customArgs) {
3541
+ const commands = ["pull", ...customArgs];
3542
+ if (remote && branch) {
3543
+ commands.splice(1, 0, remote, branch);
3544
+ }
3545
+ return {
3546
+ commands,
3547
+ format: "utf-8",
3548
+ parser(stdOut, stdErr) {
3549
+ return parsePullResult(stdOut, stdErr);
3550
+ },
3551
+ onError(result, _error, _done, fail) {
3552
+ const pullError = parsePullErrorResult(
3553
+ bufferToString(result.stdOut),
3554
+ bufferToString(result.stdErr)
3555
+ );
3556
+ if (pullError) {
3557
+ return fail(new GitResponseError(pullError));
3558
+ }
3559
+ fail(_error);
3560
+ }
3561
+ };
3562
+ }
3563
+ var init_pull = __esm({
3564
+ "src/lib/tasks/pull.ts"() {
3565
+ "use strict";
3566
+ init_git_response_error();
3567
+ init_parse_pull();
3568
+ init_utils();
3569
+ }
3570
+ });
3571
+
3572
+ // src/lib/responses/GetRemoteSummary.ts
3573
+ function parseGetRemotes(text) {
3574
+ const remotes = {};
3575
+ forEach(text, ([name]) => remotes[name] = { name });
3576
+ return Object.values(remotes);
3577
+ }
3578
+ function parseGetRemotesVerbose(text) {
3579
+ const remotes = {};
3580
+ forEach(text, ([name, url, purpose]) => {
3581
+ if (!Object.hasOwn(remotes, name)) {
3582
+ remotes[name] = {
3583
+ name,
3584
+ refs: { fetch: "", push: "" }
3585
+ };
3586
+ }
3587
+ if (purpose && url) {
3588
+ remotes[name].refs[purpose.replace(/[^a-z]/g, "")] = url;
3589
+ }
3590
+ });
3591
+ return Object.values(remotes);
3592
+ }
3593
+ function forEach(text, handler) {
3594
+ forEachLineWithContent(text, (line) => handler(line.split(/\s+/)));
3595
+ }
3596
+ var init_GetRemoteSummary = __esm({
3597
+ "src/lib/responses/GetRemoteSummary.ts"() {
3598
+ "use strict";
3599
+ init_utils();
3600
+ }
3601
+ });
3602
+
3603
+ // src/lib/tasks/remote.ts
3604
+ var remote_exports = {};
3605
+ __export(remote_exports, {
3606
+ addRemoteTask: () => addRemoteTask,
3607
+ getRemotesTask: () => getRemotesTask,
3608
+ listRemotesTask: () => listRemotesTask,
3609
+ remoteTask: () => remoteTask,
3610
+ removeRemoteTask: () => removeRemoteTask
3611
+ });
3612
+ function addRemoteTask(remoteName, remoteRepo, customArgs) {
3613
+ return straightThroughStringTask(["remote", "add", ...customArgs, remoteName, remoteRepo]);
3614
+ }
3615
+ function getRemotesTask(verbose) {
3616
+ const commands = ["remote"];
3617
+ if (verbose) {
3618
+ commands.push("-v");
3619
+ }
3620
+ return {
3621
+ commands,
3622
+ format: "utf-8",
3623
+ parser: verbose ? parseGetRemotesVerbose : parseGetRemotes
3624
+ };
3625
+ }
3626
+ function listRemotesTask(customArgs) {
3627
+ const commands = [...customArgs];
3628
+ if (commands[0] !== "ls-remote") {
3629
+ commands.unshift("ls-remote");
3630
+ }
3631
+ return straightThroughStringTask(commands);
3632
+ }
3633
+ function remoteTask(customArgs) {
3634
+ const commands = [...customArgs];
3635
+ if (commands[0] !== "remote") {
3636
+ commands.unshift("remote");
3637
+ }
3638
+ return straightThroughStringTask(commands);
3639
+ }
3640
+ function removeRemoteTask(remoteName) {
3641
+ return straightThroughStringTask(["remote", "remove", remoteName]);
3642
+ }
3643
+ var init_remote = __esm({
3644
+ "src/lib/tasks/remote.ts"() {
3645
+ "use strict";
3646
+ init_GetRemoteSummary();
3647
+ init_task();
3648
+ }
3649
+ });
3650
+
3651
+ // src/lib/tasks/stash-list.ts
3652
+ var stash_list_exports = {};
3653
+ __export(stash_list_exports, {
3654
+ stashListTask: () => stashListTask
3655
+ });
3656
+ function stashListTask(opt = {}, customArgs) {
3657
+ const options = parseLogOptions(opt);
3658
+ const commands = ["stash", "list", ...options.commands, ...customArgs];
3659
+ const parser4 = createListLogSummaryParser(
3660
+ options.splitter,
3661
+ options.fields,
3662
+ logFormatFromCommand(commands)
3663
+ );
3664
+ return validateLogFormatConfig(commands) || {
3665
+ commands,
3666
+ format: "utf-8",
3667
+ parser: parser4
3668
+ };
3669
+ }
3670
+ var init_stash_list = __esm({
3671
+ "src/lib/tasks/stash-list.ts"() {
3672
+ "use strict";
3673
+ init_log_format();
3674
+ init_parse_list_log_summary();
3675
+ init_diff();
3676
+ init_log();
3677
+ }
3678
+ });
3679
+
3680
+ // src/lib/tasks/sub-module.ts
3681
+ var sub_module_exports = {};
3682
+ __export(sub_module_exports, {
3683
+ addSubModuleTask: () => addSubModuleTask,
3684
+ initSubModuleTask: () => initSubModuleTask,
3685
+ subModuleTask: () => subModuleTask,
3686
+ updateSubModuleTask: () => updateSubModuleTask
3687
+ });
3688
+ function addSubModuleTask(repo, path) {
3689
+ return subModuleTask(["add", repo, path]);
3690
+ }
3691
+ function initSubModuleTask(customArgs) {
3692
+ return subModuleTask(["init", ...customArgs]);
3693
+ }
3694
+ function subModuleTask(customArgs) {
3695
+ const commands = [...customArgs];
3696
+ if (commands[0] !== "submodule") {
3697
+ commands.unshift("submodule");
3698
+ }
3699
+ return straightThroughStringTask(commands);
3700
+ }
3701
+ function updateSubModuleTask(customArgs) {
3702
+ return subModuleTask(["update", ...customArgs]);
3703
+ }
3704
+ var init_sub_module = __esm({
3705
+ "src/lib/tasks/sub-module.ts"() {
3706
+ "use strict";
3707
+ init_task();
3708
+ }
3709
+ });
3710
+
3711
+ // src/lib/responses/TagList.ts
3712
+ function singleSorted(a, b) {
3713
+ const aIsNum = Number.isNaN(a);
3714
+ const bIsNum = Number.isNaN(b);
3715
+ if (aIsNum !== bIsNum) {
3716
+ return aIsNum ? 1 : -1;
3717
+ }
3718
+ return aIsNum ? sorted(a, b) : 0;
3719
+ }
3720
+ function sorted(a, b) {
3721
+ return a === b ? 0 : a > b ? 1 : -1;
3722
+ }
3723
+ function trimmed(input) {
3724
+ return input.trim();
3725
+ }
3726
+ function toNumber(input) {
3727
+ if (typeof input === "string") {
3728
+ return parseInt(input.replace(/^\D+/g, ""), 10) || 0;
3729
+ }
3730
+ return 0;
3731
+ }
3732
+ var TagList, parseTagList;
3733
+ var init_TagList = __esm({
3734
+ "src/lib/responses/TagList.ts"() {
3735
+ "use strict";
3736
+ TagList = class {
3737
+ constructor(all, latest) {
3738
+ this.all = all;
3739
+ this.latest = latest;
3740
+ }
3741
+ };
3742
+ parseTagList = function(data, customSort = false) {
3743
+ const tags = data.split("\n").map(trimmed).filter(Boolean);
3744
+ if (!customSort) {
3745
+ tags.sort(function(tagA, tagB) {
3746
+ const partsA = tagA.split(".");
3747
+ const partsB = tagB.split(".");
3748
+ if (partsA.length === 1 || partsB.length === 1) {
3749
+ return singleSorted(toNumber(partsA[0]), toNumber(partsB[0]));
3750
+ }
3751
+ for (let i = 0, l = Math.max(partsA.length, partsB.length); i < l; i++) {
3752
+ const diff = sorted(toNumber(partsA[i]), toNumber(partsB[i]));
3753
+ if (diff) {
3754
+ return diff;
3755
+ }
3756
+ }
3757
+ return 0;
3758
+ });
3759
+ }
3760
+ const latest = customSort ? tags[0] : [...tags].reverse().find((tag) => tag.indexOf(".") >= 0);
3761
+ return new TagList(tags, latest);
3762
+ };
3763
+ }
3764
+ });
3765
+
3766
+ // src/lib/tasks/tag.ts
3767
+ var tag_exports = {};
3768
+ __export(tag_exports, {
3769
+ addAnnotatedTagTask: () => addAnnotatedTagTask,
3770
+ addTagTask: () => addTagTask,
3771
+ tagListTask: () => tagListTask
3772
+ });
3773
+ function tagListTask(customArgs = []) {
3774
+ const hasCustomSort = customArgs.some((option) => /^--sort=/.test(option));
3775
+ return {
3776
+ format: "utf-8",
3777
+ commands: ["tag", "-l", ...customArgs],
3778
+ parser(text) {
3779
+ return parseTagList(text, hasCustomSort);
3780
+ }
3781
+ };
3782
+ }
3783
+ function addTagTask(name) {
3784
+ return {
3785
+ format: "utf-8",
3786
+ commands: ["tag", name],
3787
+ parser() {
3788
+ return { name };
3789
+ }
3790
+ };
3791
+ }
3792
+ function addAnnotatedTagTask(name, tagMessage) {
3793
+ return {
3794
+ format: "utf-8",
3795
+ commands: ["tag", "-a", "-m", tagMessage, name],
3796
+ parser() {
3797
+ return { name };
3798
+ }
3799
+ };
3800
+ }
3801
+ var init_tag = __esm({
3802
+ "src/lib/tasks/tag.ts"() {
3803
+ "use strict";
3804
+ init_TagList();
3805
+ }
3806
+ });
3807
+
3808
+ // src/git.js
3809
+ var require_git = __commonJS({
3810
+ "src/git.js"(exports, module) {
3811
+ "use strict";
3812
+ var { GitExecutor: GitExecutor2 } = (init_git_executor(), __toCommonJS(git_executor_exports));
3813
+ var { SimpleGitApi: SimpleGitApi2 } = (init_simple_git_api(), __toCommonJS(simple_git_api_exports));
3814
+ var { Scheduler: Scheduler2 } = (init_scheduler(), __toCommonJS(scheduler_exports));
3815
+ var { adhocExecTask: adhocExecTask2, configurationErrorTask: configurationErrorTask2 } = (init_task(), __toCommonJS(task_exports));
3816
+ var {
3817
+ asArray: asArray2,
3818
+ filterArray: filterArray2,
3819
+ filterPrimitives: filterPrimitives2,
3820
+ filterString: filterString2,
3821
+ filterStringOrStringArray: filterStringOrStringArray2,
3822
+ filterType: filterType2,
3823
+ getTrailingOptions: getTrailingOptions2,
3824
+ trailingFunctionArgument: trailingFunctionArgument2,
3825
+ trailingOptionsArgument: trailingOptionsArgument2
3826
+ } = (init_utils(), __toCommonJS(utils_exports));
3827
+ var { applyPatchTask: applyPatchTask2 } = (init_apply_patch(), __toCommonJS(apply_patch_exports));
3828
+ var {
3829
+ branchTask: branchTask2,
3830
+ branchLocalTask: branchLocalTask2,
3831
+ deleteBranchesTask: deleteBranchesTask2,
3832
+ deleteBranchTask: deleteBranchTask2
3833
+ } = (init_branch(), __toCommonJS(branch_exports));
3834
+ var { checkIgnoreTask: checkIgnoreTask2 } = (init_check_ignore(), __toCommonJS(check_ignore_exports));
3835
+ var { checkIsRepoTask: checkIsRepoTask2 } = (init_check_is_repo(), __toCommonJS(check_is_repo_exports));
3836
+ var { cleanWithOptionsTask: cleanWithOptionsTask2, isCleanOptionsArray: isCleanOptionsArray2 } = (init_clean(), __toCommonJS(clean_exports));
3837
+ var { diffSummaryTask: diffSummaryTask2 } = (init_diff(), __toCommonJS(diff_exports));
3838
+ var { fetchTask: fetchTask2 } = (init_fetch(), __toCommonJS(fetch_exports));
3839
+ var { moveTask: moveTask2 } = (init_move(), __toCommonJS(move_exports));
3840
+ var { pullTask: pullTask2 } = (init_pull(), __toCommonJS(pull_exports));
3841
+ var { pushTagsTask: pushTagsTask2 } = (init_push(), __toCommonJS(push_exports));
3842
+ var {
3843
+ addRemoteTask: addRemoteTask2,
3844
+ getRemotesTask: getRemotesTask2,
3845
+ listRemotesTask: listRemotesTask2,
3846
+ remoteTask: remoteTask2,
3847
+ removeRemoteTask: removeRemoteTask2
3848
+ } = (init_remote(), __toCommonJS(remote_exports));
3849
+ var { getResetMode: getResetMode2, resetTask: resetTask2 } = (init_reset(), __toCommonJS(reset_exports));
3850
+ var { stashListTask: stashListTask2 } = (init_stash_list(), __toCommonJS(stash_list_exports));
3851
+ var {
3852
+ addSubModuleTask: addSubModuleTask2,
3853
+ initSubModuleTask: initSubModuleTask2,
3854
+ subModuleTask: subModuleTask2,
3855
+ updateSubModuleTask: updateSubModuleTask2
3856
+ } = (init_sub_module(), __toCommonJS(sub_module_exports));
3857
+ var { addAnnotatedTagTask: addAnnotatedTagTask2, addTagTask: addTagTask2, tagListTask: tagListTask2 } = (init_tag(), __toCommonJS(tag_exports));
3858
+ var { straightThroughBufferTask: straightThroughBufferTask2, straightThroughStringTask: straightThroughStringTask2 } = (init_task(), __toCommonJS(task_exports));
3859
+ function Git2(options, plugins) {
3860
+ this._plugins = plugins;
3861
+ this._executor = new GitExecutor2(
3862
+ options.baseDir,
3863
+ new Scheduler2(options.maxConcurrentProcesses),
3864
+ plugins
3865
+ );
3866
+ this._trimmed = options.trimmed;
3867
+ }
3868
+ (Git2.prototype = Object.create(SimpleGitApi2.prototype)).constructor = Git2;
3869
+ Git2.prototype.customBinary = function(command) {
3870
+ this._plugins.reconfigure("binary", command);
3871
+ return this;
3872
+ };
3873
+ Git2.prototype.env = function(name, value) {
3874
+ if (arguments.length === 1 && typeof name === "object") {
3875
+ this._executor.env = name;
3876
+ } else {
3877
+ (this._executor.env = this._executor.env || {})[name] = value;
3878
+ }
3879
+ return this;
3880
+ };
3881
+ Git2.prototype.stashList = function(options) {
3882
+ return this._runTask(
3883
+ stashListTask2(
3884
+ trailingOptionsArgument2(arguments) || {},
3885
+ filterArray2(options) && options || []
3886
+ ),
3887
+ trailingFunctionArgument2(arguments)
3888
+ );
3889
+ };
3890
+ Git2.prototype.mv = function(from, to) {
3891
+ return this._runTask(moveTask2(from, to), trailingFunctionArgument2(arguments));
3892
+ };
3893
+ Git2.prototype.checkoutLatestTag = function(then) {
3894
+ var git = this;
3895
+ return this.pull(function() {
3896
+ git.tags(function(err, tags) {
3897
+ git.checkout(tags.latest, then);
3898
+ });
3899
+ });
3900
+ };
3901
+ Git2.prototype.pull = function(remote, branch, options, then) {
3902
+ return this._runTask(
3903
+ pullTask2(
3904
+ filterType2(remote, filterString2),
3905
+ filterType2(branch, filterString2),
3906
+ getTrailingOptions2(arguments)
3907
+ ),
3908
+ trailingFunctionArgument2(arguments)
3909
+ );
3910
+ };
3911
+ Git2.prototype.fetch = function(remote, branch) {
3912
+ return this._runTask(
3913
+ fetchTask2(
3914
+ filterType2(remote, filterString2),
3915
+ filterType2(branch, filterString2),
3916
+ getTrailingOptions2(arguments)
3917
+ ),
3918
+ trailingFunctionArgument2(arguments)
3919
+ );
3920
+ };
3921
+ Git2.prototype.silent = function(silence) {
3922
+ return this._runTask(
3923
+ adhocExecTask2(
3924
+ () => console.warn(
3925
+ "simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this method will be removed."
3926
+ )
3927
+ )
3928
+ );
3929
+ };
3930
+ Git2.prototype.tags = function(options, then) {
3931
+ return this._runTask(
3932
+ tagListTask2(getTrailingOptions2(arguments)),
3933
+ trailingFunctionArgument2(arguments)
3934
+ );
3935
+ };
3936
+ Git2.prototype.rebase = function() {
3937
+ return this._runTask(
3938
+ straightThroughStringTask2(["rebase", ...getTrailingOptions2(arguments)]),
3939
+ trailingFunctionArgument2(arguments)
3940
+ );
3941
+ };
3942
+ Git2.prototype.reset = function(mode) {
3943
+ return this._runTask(
3944
+ resetTask2(getResetMode2(mode), getTrailingOptions2(arguments)),
3945
+ trailingFunctionArgument2(arguments)
3946
+ );
3947
+ };
3948
+ Git2.prototype.revert = function(commit) {
3949
+ const next = trailingFunctionArgument2(arguments);
3950
+ if (typeof commit !== "string") {
3951
+ return this._runTask(configurationErrorTask2("Commit must be a string"), next);
3952
+ }
3953
+ return this._runTask(
3954
+ straightThroughStringTask2(["revert", ...getTrailingOptions2(arguments, 0, true), commit]),
3955
+ next
3956
+ );
3957
+ };
3958
+ Git2.prototype.addTag = function(name) {
3959
+ const task = typeof name === "string" ? addTagTask2(name) : configurationErrorTask2("Git.addTag requires a tag name");
3960
+ return this._runTask(task, trailingFunctionArgument2(arguments));
3961
+ };
3962
+ Git2.prototype.addAnnotatedTag = function(tagName, tagMessage) {
3963
+ return this._runTask(
3964
+ addAnnotatedTagTask2(tagName, tagMessage),
3965
+ trailingFunctionArgument2(arguments)
3966
+ );
3967
+ };
3968
+ Git2.prototype.deleteLocalBranch = function(branchName, forceDelete, then) {
3969
+ return this._runTask(
3970
+ deleteBranchTask2(branchName, typeof forceDelete === "boolean" ? forceDelete : false),
3971
+ trailingFunctionArgument2(arguments)
3972
+ );
3973
+ };
3974
+ Git2.prototype.deleteLocalBranches = function(branchNames, forceDelete, then) {
3975
+ return this._runTask(
3976
+ deleteBranchesTask2(branchNames, typeof forceDelete === "boolean" ? forceDelete : false),
3977
+ trailingFunctionArgument2(arguments)
3978
+ );
3979
+ };
3980
+ Git2.prototype.branch = function(options, then) {
3981
+ return this._runTask(
3982
+ branchTask2(getTrailingOptions2(arguments)),
3983
+ trailingFunctionArgument2(arguments)
3984
+ );
3985
+ };
3986
+ Git2.prototype.branchLocal = function(then) {
3987
+ return this._runTask(branchLocalTask2(), trailingFunctionArgument2(arguments));
3988
+ };
3989
+ Git2.prototype.raw = function(commands) {
3990
+ const createRestCommands = !Array.isArray(commands);
3991
+ const command = [].slice.call(createRestCommands ? arguments : commands, 0);
3992
+ for (let i = 0; i < command.length && createRestCommands; i++) {
3993
+ if (!filterPrimitives2(command[i])) {
3994
+ command.splice(i, command.length - i);
3995
+ break;
3996
+ }
3997
+ }
3998
+ command.push(...getTrailingOptions2(arguments, 0, true));
3999
+ var next = trailingFunctionArgument2(arguments);
4000
+ if (!command.length) {
4001
+ return this._runTask(
4002
+ configurationErrorTask2("Raw: must supply one or more command to execute"),
4003
+ next
4004
+ );
4005
+ }
4006
+ return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
4007
+ };
4008
+ Git2.prototype.submoduleAdd = function(repo, path, then) {
4009
+ return this._runTask(addSubModuleTask2(repo, path), trailingFunctionArgument2(arguments));
4010
+ };
4011
+ Git2.prototype.submoduleUpdate = function(args, then) {
4012
+ return this._runTask(
4013
+ updateSubModuleTask2(getTrailingOptions2(arguments, true)),
4014
+ trailingFunctionArgument2(arguments)
4015
+ );
4016
+ };
4017
+ Git2.prototype.submoduleInit = function(args, then) {
4018
+ return this._runTask(
4019
+ initSubModuleTask2(getTrailingOptions2(arguments, true)),
4020
+ trailingFunctionArgument2(arguments)
4021
+ );
4022
+ };
4023
+ Git2.prototype.subModule = function(options, then) {
4024
+ return this._runTask(
4025
+ subModuleTask2(getTrailingOptions2(arguments)),
4026
+ trailingFunctionArgument2(arguments)
4027
+ );
4028
+ };
4029
+ Git2.prototype.listRemote = function() {
4030
+ return this._runTask(
4031
+ listRemotesTask2(getTrailingOptions2(arguments)),
4032
+ trailingFunctionArgument2(arguments)
4033
+ );
4034
+ };
4035
+ Git2.prototype.addRemote = function(remoteName, remoteRepo, then) {
4036
+ return this._runTask(
4037
+ addRemoteTask2(remoteName, remoteRepo, getTrailingOptions2(arguments)),
4038
+ trailingFunctionArgument2(arguments)
4039
+ );
4040
+ };
4041
+ Git2.prototype.removeRemote = function(remoteName, then) {
4042
+ return this._runTask(removeRemoteTask2(remoteName), trailingFunctionArgument2(arguments));
4043
+ };
4044
+ Git2.prototype.getRemotes = function(verbose, then) {
4045
+ return this._runTask(getRemotesTask2(verbose === true), trailingFunctionArgument2(arguments));
4046
+ };
4047
+ Git2.prototype.remote = function(options, then) {
4048
+ return this._runTask(
4049
+ remoteTask2(getTrailingOptions2(arguments)),
4050
+ trailingFunctionArgument2(arguments)
4051
+ );
4052
+ };
4053
+ Git2.prototype.tag = function(options, then) {
4054
+ const command = getTrailingOptions2(arguments);
4055
+ if (command[0] !== "tag") {
4056
+ command.unshift("tag");
4057
+ }
4058
+ return this._runTask(straightThroughStringTask2(command), trailingFunctionArgument2(arguments));
4059
+ };
4060
+ Git2.prototype.updateServerInfo = function(then) {
4061
+ return this._runTask(
4062
+ straightThroughStringTask2(["update-server-info"]),
4063
+ trailingFunctionArgument2(arguments)
4064
+ );
4065
+ };
4066
+ Git2.prototype.pushTags = function(remote, then) {
4067
+ const task = pushTagsTask2(
4068
+ { remote: filterType2(remote, filterString2) },
4069
+ getTrailingOptions2(arguments)
4070
+ );
4071
+ return this._runTask(task, trailingFunctionArgument2(arguments));
4072
+ };
4073
+ Git2.prototype.rm = function(files) {
4074
+ return this._runTask(
4075
+ straightThroughStringTask2(["rm", "-f", ...asArray2(files)]),
4076
+ trailingFunctionArgument2(arguments)
4077
+ );
4078
+ };
4079
+ Git2.prototype.rmKeepLocal = function(files) {
4080
+ return this._runTask(
4081
+ straightThroughStringTask2(["rm", "--cached", ...asArray2(files)]),
4082
+ trailingFunctionArgument2(arguments)
4083
+ );
4084
+ };
4085
+ Git2.prototype.catFile = function(options, then) {
4086
+ return this._catFile("utf-8", arguments);
4087
+ };
4088
+ Git2.prototype.binaryCatFile = function() {
4089
+ return this._catFile("buffer", arguments);
4090
+ };
4091
+ Git2.prototype._catFile = function(format, args) {
4092
+ var handler = trailingFunctionArgument2(args);
4093
+ var command = ["cat-file"];
4094
+ var options = args[0];
4095
+ if (typeof options === "string") {
4096
+ return this._runTask(
4097
+ configurationErrorTask2("Git.catFile: options must be supplied as an array of strings"),
4098
+ handler
4099
+ );
4100
+ }
4101
+ if (Array.isArray(options)) {
4102
+ command.push.apply(command, options);
4103
+ }
4104
+ const task = format === "buffer" ? straightThroughBufferTask2(command) : straightThroughStringTask2(command);
4105
+ return this._runTask(task, handler);
4106
+ };
4107
+ Git2.prototype.diff = function(options, then) {
4108
+ const task = filterString2(options) ? configurationErrorTask2(
4109
+ "git.diff: supplying options as a single string is no longer supported, switch to an array of strings"
4110
+ ) : straightThroughStringTask2(["diff", ...getTrailingOptions2(arguments)]);
4111
+ return this._runTask(task, trailingFunctionArgument2(arguments));
4112
+ };
4113
+ Git2.prototype.diffSummary = function() {
4114
+ return this._runTask(
4115
+ diffSummaryTask2(getTrailingOptions2(arguments, 1)),
4116
+ trailingFunctionArgument2(arguments)
4117
+ );
4118
+ };
4119
+ Git2.prototype.applyPatch = function(patches) {
4120
+ const task = !filterStringOrStringArray2(patches) ? configurationErrorTask2(
4121
+ `git.applyPatch requires one or more string patches as the first argument`
4122
+ ) : applyPatchTask2(asArray2(patches), getTrailingOptions2([].slice.call(arguments, 1)));
4123
+ return this._runTask(task, trailingFunctionArgument2(arguments));
4124
+ };
4125
+ Git2.prototype.revparse = function() {
4126
+ const commands = ["rev-parse", ...getTrailingOptions2(arguments, true)];
4127
+ return this._runTask(
4128
+ straightThroughStringTask2(commands, true),
4129
+ trailingFunctionArgument2(arguments)
4130
+ );
4131
+ };
4132
+ Git2.prototype.clean = function(mode, options, then) {
4133
+ const usingCleanOptionsArray = isCleanOptionsArray2(mode);
4134
+ const cleanMode = usingCleanOptionsArray && mode.join("") || filterType2(mode, filterString2) || "";
4135
+ const customArgs = getTrailingOptions2([].slice.call(arguments, usingCleanOptionsArray ? 1 : 0));
4136
+ return this._runTask(
4137
+ cleanWithOptionsTask2(cleanMode, customArgs),
4138
+ trailingFunctionArgument2(arguments)
4139
+ );
4140
+ };
4141
+ Git2.prototype.exec = function(then) {
4142
+ const task = {
4143
+ commands: [],
4144
+ format: "utf-8",
4145
+ parser() {
4146
+ if (typeof then === "function") {
4147
+ then();
4148
+ }
4149
+ }
4150
+ };
4151
+ return this._runTask(task);
4152
+ };
4153
+ Git2.prototype.clearQueue = function() {
4154
+ return this._runTask(
4155
+ adhocExecTask2(
4156
+ () => console.warn(
4157
+ "simple-git deprecation notice: clearQueue() is deprecated and will be removed, switch to using the abortPlugin instead."
4158
+ )
4159
+ )
4160
+ );
4161
+ };
4162
+ Git2.prototype.checkIgnore = function(pathnames, then) {
4163
+ return this._runTask(
4164
+ checkIgnoreTask2(asArray2(filterType2(pathnames, filterStringOrStringArray2, []))),
4165
+ trailingFunctionArgument2(arguments)
4166
+ );
4167
+ };
4168
+ Git2.prototype.checkIsRepo = function(checkType, then) {
4169
+ return this._runTask(
4170
+ checkIsRepoTask2(filterType2(checkType, filterString2)),
4171
+ trailingFunctionArgument2(arguments)
4172
+ );
4173
+ };
4174
+ module.exports = Git2;
4175
+ }
4176
+ });
4177
+
4178
+ // src/lib/api.ts
4179
+ import { pathspec } from "@simple-git/args-pathspec";
4180
+
4181
+ // src/lib/errors/git-construct-error.ts
4182
+ init_git_error();
4183
+ var GitConstructError = class extends GitError {
4184
+ constructor(config, message) {
4185
+ super(void 0, message);
4186
+ this.config = config;
4187
+ }
4188
+ };
4189
+
4190
+ // src/lib/api.ts
4191
+ init_git_error();
4192
+
4193
+ // src/lib/errors/git-plugin-error.ts
4194
+ init_git_error();
4195
+ var GitPluginError = class extends GitError {
4196
+ constructor(task, plugin, message) {
4197
+ super(task, message);
4198
+ this.task = task;
4199
+ this.plugin = plugin;
4200
+ Object.setPrototypeOf(this, new.target.prototype);
4201
+ }
4202
+ };
4203
+
4204
+ // src/lib/api.ts
4205
+ init_git_response_error();
4206
+ init_task_configuration_error();
4207
+ init_check_is_repo();
4208
+ init_clean();
4209
+ init_config();
4210
+ init_diff_name_status();
4211
+ init_grep();
4212
+ init_reset();
4213
+
4214
+ // src/lib/plugins/abort-plugin.ts
4215
+ function abortPlugin(signal) {
4216
+ if (!signal) {
4217
+ return;
4218
+ }
4219
+ const onSpawnAfter = {
4220
+ type: "spawn.after",
4221
+ action(_data, context) {
4222
+ function kill() {
4223
+ context.kill(new GitPluginError(void 0, "abort", "Abort signal received"));
4224
+ }
4225
+ signal.addEventListener("abort", kill);
4226
+ context.spawned.on("close", () => signal.removeEventListener("abort", kill));
4227
+ }
4228
+ };
4229
+ const onSpawnBefore = {
4230
+ type: "spawn.before",
4231
+ action(_data, context) {
4232
+ if (signal.aborted) {
4233
+ context.kill(new GitPluginError(void 0, "abort", "Abort already signaled"));
4234
+ }
4235
+ }
4236
+ };
4237
+ return [onSpawnBefore, onSpawnAfter];
4238
+ }
4239
+
4240
+ // src/lib/plugins/block-unsafe-operations-plugin.ts
4241
+ import { vulnerabilityCheck } from "@simple-git/argv-parser";
4242
+ function blockUnsafeOperationsPlugin(options = {}) {
4243
+ return {
4244
+ type: "spawn.args",
4245
+ action(args, { env }) {
4246
+ for (const vulnerability of vulnerabilityCheck(args, env)) {
4247
+ if (options[vulnerability.category] !== true) {
4248
+ throw new GitPluginError(void 0, "unsafe", vulnerability.message);
4249
+ }
4250
+ }
4251
+ return args;
4252
+ }
4253
+ };
4254
+ }
4255
+
4256
+ // src/lib/plugins/command-config-prefixing-plugin.ts
4257
+ init_utils();
4258
+ function commandConfigPrefixingPlugin(configuration) {
4259
+ const prefix = prefixedArray(configuration, "-c");
4260
+ return {
4261
+ type: "spawn.args",
4262
+ action(data) {
4263
+ return [...prefix, ...data];
4264
+ }
4265
+ };
4266
+ }
4267
+
4268
+ // src/lib/plugins/completion-detection.plugin.ts
4269
+ init_utils();
4270
+ import { deferred } from "@kwsites/promise-deferred";
4271
+ var never = deferred().promise;
4272
+ function completionDetectionPlugin({
4273
+ onClose = true,
4274
+ onExit = 50
4275
+ } = {}) {
4276
+ function createEvents() {
4277
+ let exitCode = -1;
4278
+ const events = {
4279
+ close: deferred(),
4280
+ closeTimeout: deferred(),
4281
+ exit: deferred(),
4282
+ exitTimeout: deferred()
4283
+ };
4284
+ const result = Promise.race([
4285
+ onClose === false ? never : events.closeTimeout.promise,
4286
+ onExit === false ? never : events.exitTimeout.promise
4287
+ ]);
4288
+ configureTimeout(onClose, events.close, events.closeTimeout);
4289
+ configureTimeout(onExit, events.exit, events.exitTimeout);
4290
+ return {
4291
+ close(code) {
4292
+ exitCode = code;
4293
+ events.close.done();
4294
+ },
4295
+ exit(code) {
4296
+ exitCode = code;
4297
+ events.exit.done();
4298
+ },
4299
+ get exitCode() {
4300
+ return exitCode;
4301
+ },
4302
+ result
4303
+ };
4304
+ }
4305
+ function configureTimeout(flag, event, timeout) {
4306
+ if (flag === false) {
4307
+ return;
4308
+ }
4309
+ (flag === true ? event.promise : event.promise.then(() => delay(flag))).then(timeout.done);
4310
+ }
4311
+ return {
4312
+ type: "spawn.after",
4313
+ async action(_data, { spawned, close }) {
4314
+ const events = createEvents();
4315
+ let deferClose = true;
4316
+ let quickClose = () => void (deferClose = false);
4317
+ spawned.stdout?.on("data", quickClose);
4318
+ spawned.stderr?.on("data", quickClose);
4319
+ spawned.on("error", quickClose);
4320
+ spawned.on("close", (code) => events.close(code));
4321
+ spawned.on("exit", (code) => events.exit(code));
4322
+ try {
4323
+ await events.result;
4324
+ if (deferClose) {
4325
+ await delay(50);
4326
+ }
4327
+ close(events.exitCode);
4328
+ } catch (err) {
4329
+ close(events.exitCode, err);
4330
+ }
4331
+ }
4332
+ };
4333
+ }
4334
+
4335
+ // src/lib/plugins/custom-binary.plugin.ts
4336
+ init_utils();
4337
+ var WRONG_NUMBER_ERR = `Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`;
4338
+ var WRONG_CHARS_ERR = `Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;
4339
+ function isBadArgument(arg) {
4340
+ return !arg || !/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(arg);
4341
+ }
4342
+ function toBinaryConfig(input, allowUnsafe) {
4343
+ if (input.length < 1 || input.length > 2) {
4344
+ throw new GitPluginError(void 0, "binary", WRONG_NUMBER_ERR);
4345
+ }
4346
+ const isBad = input.some(isBadArgument);
4347
+ if (isBad) {
4348
+ if (allowUnsafe) {
4349
+ console.warn(WRONG_CHARS_ERR);
4350
+ } else {
4351
+ throw new GitPluginError(void 0, "binary", WRONG_CHARS_ERR);
4352
+ }
4353
+ }
4354
+ const [binary, prefix] = input;
4355
+ return {
4356
+ binary,
4357
+ prefix
4358
+ };
4359
+ }
4360
+ function customBinaryPlugin(plugins, input = ["git"], allowUnsafe = false) {
4361
+ let config = toBinaryConfig(asArray(input), allowUnsafe);
4362
+ plugins.on("binary", (input2) => {
4363
+ config = toBinaryConfig(asArray(input2), allowUnsafe);
4364
+ });
4365
+ plugins.append("spawn.binary", () => {
4366
+ return config.binary;
4367
+ });
4368
+ plugins.append("spawn.args", (data) => {
4369
+ return config.prefix ? [config.prefix, ...data] : data;
4370
+ });
4371
+ }
4372
+
4373
+ // src/lib/plugins/error-detection.plugin.ts
4374
+ init_git_error();
4375
+ function isTaskError(result) {
4376
+ return !!(result.exitCode && result.stdErr.length);
4377
+ }
4378
+ function getErrorMessage(result) {
4379
+ return Buffer.concat([...result.stdOut, ...result.stdErr]);
4380
+ }
4381
+ function errorDetectionHandler(overwrite = false, isError = isTaskError, errorMessage = getErrorMessage) {
4382
+ return (error, result) => {
4383
+ if (!overwrite && error || !isError(result)) {
4384
+ return error;
4385
+ }
4386
+ return errorMessage(result);
4387
+ };
4388
+ }
4389
+ function errorDetectionPlugin(config) {
4390
+ return {
4391
+ type: "task.error",
4392
+ action(data, context) {
4393
+ const error = config(data.error, {
4394
+ stdErr: context.stdErr,
4395
+ stdOut: context.stdOut,
4396
+ exitCode: context.exitCode
4397
+ });
4398
+ if (Buffer.isBuffer(error)) {
4399
+ return { error: new GitError(void 0, error.toString("utf-8")) };
4400
+ }
4401
+ return {
4402
+ error
4403
+ };
4404
+ }
4405
+ };
4406
+ }
4407
+
4408
+ // src/lib/plugins/plugin-store.ts
4409
+ init_utils();
4410
+ import { EventEmitter } from "node:events";
4411
+ var PluginStore = class {
4412
+ constructor() {
4413
+ this.plugins = /* @__PURE__ */ new Set();
4414
+ this.events = new EventEmitter();
4415
+ }
4416
+ on(type, listener) {
4417
+ this.events.on(type, listener);
4418
+ }
4419
+ reconfigure(type, data) {
4420
+ this.events.emit(type, data);
4421
+ }
4422
+ append(type, action) {
4423
+ const plugin = append(this.plugins, { type, action });
4424
+ return () => this.plugins.delete(plugin);
4425
+ }
4426
+ add(plugin) {
4427
+ const plugins = [];
4428
+ asArray(plugin).forEach((plugin2) => plugin2 && this.plugins.add(append(plugins, plugin2)));
4429
+ return () => {
4430
+ plugins.forEach((plugin2) => this.plugins.delete(plugin2));
4431
+ };
4432
+ }
4433
+ exec(type, data, context) {
4434
+ let output = data;
4435
+ const contextual = Object.freeze(Object.create(context));
4436
+ for (const plugin of this.plugins) {
4437
+ if (plugin.type === type) {
4438
+ output = plugin.action(output, contextual);
4439
+ }
4440
+ }
4441
+ return output;
4442
+ }
4443
+ };
4444
+
4445
+ // src/lib/plugins/progress-monitor-plugin.ts
4446
+ init_utils();
4447
+ function progressMonitorPlugin(progress) {
4448
+ const progressCommand = "--progress";
4449
+ const progressMethods = ["checkout", "clone", "fetch", "pull", "push"];
4450
+ const onProgress = {
4451
+ type: "spawn.after",
4452
+ action(_data, context) {
4453
+ if (!context.commands.includes(progressCommand)) {
4454
+ return;
4455
+ }
4456
+ context.spawned.stderr?.on("data", (chunk) => {
4457
+ const message = /^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(chunk.toString("utf8"));
4458
+ if (!message) {
4459
+ return;
4460
+ }
4461
+ progress({
4462
+ method: context.method,
4463
+ stage: progressEventStage(message[1]),
4464
+ progress: asNumber(message[2]),
4465
+ processed: asNumber(message[3]),
4466
+ total: asNumber(message[4])
4467
+ });
4468
+ });
4469
+ }
4470
+ };
4471
+ const onArgs = {
4472
+ type: "spawn.args",
4473
+ action(args, context) {
4474
+ if (!progressMethods.includes(context.method)) {
4475
+ return args;
4476
+ }
4477
+ return including(args, progressCommand);
4478
+ }
4479
+ };
4480
+ return [onArgs, onProgress];
4481
+ }
4482
+ function progressEventStage(input) {
4483
+ return String(input.toLowerCase().split(" ", 1)) || "unknown";
4484
+ }
4485
+
4486
+ // src/lib/plugins/spawn-options-plugin.ts
4487
+ init_utils();
4488
+ function spawnOptionsPlugin(spawnOptions) {
4489
+ const options = pick(spawnOptions, ["uid", "gid"]);
4490
+ return {
4491
+ type: "spawn.options",
4492
+ action(data) {
4493
+ return { ...options, ...data };
4494
+ }
4495
+ };
4496
+ }
4497
+
4498
+ // src/lib/plugins/timout-plugin.ts
4499
+ function timeoutPlugin({
4500
+ block,
4501
+ stdErr = true,
4502
+ stdOut = true
4503
+ }) {
4504
+ if (block > 0) {
4505
+ return {
4506
+ type: "spawn.after",
4507
+ action(_data, context) {
4508
+ let timeout;
4509
+ function wait() {
4510
+ timeout && clearTimeout(timeout);
4511
+ timeout = setTimeout(kill, block);
4512
+ }
4513
+ function stop() {
4514
+ context.spawned.stdout?.off("data", wait);
4515
+ context.spawned.stderr?.off("data", wait);
4516
+ context.spawned.off("exit", stop);
4517
+ context.spawned.off("close", stop);
4518
+ timeout && clearTimeout(timeout);
4519
+ }
4520
+ function kill() {
4521
+ stop();
4522
+ context.kill(new GitPluginError(void 0, "timeout", `block timeout reached`));
4523
+ }
4524
+ stdOut && context.spawned.stdout?.on("data", wait);
4525
+ stdErr && context.spawned.stderr?.on("data", wait);
4526
+ context.spawned.on("exit", stop);
4527
+ context.spawned.on("close", stop);
4528
+ wait();
4529
+ }
4530
+ };
4531
+ }
4532
+ }
4533
+
4534
+ // src/lib/plugins/suffix-paths.plugin.ts
4535
+ import { isPathSpec as isPathSpec3, toPaths } from "@simple-git/args-pathspec";
4536
+ function suffixPathsPlugin() {
4537
+ return {
4538
+ type: "spawn.args",
4539
+ action(data) {
4540
+ const prefix = [];
4541
+ let suffix;
4542
+ function append2(args) {
4543
+ (suffix = suffix || []).push(...args);
4544
+ }
4545
+ for (let i = 0; i < data.length; i++) {
4546
+ const param = data[i];
4547
+ if (isPathSpec3(param)) {
4548
+ append2(toPaths(param));
4549
+ continue;
4550
+ }
4551
+ if (param === "--") {
4552
+ append2(
4553
+ data.slice(i + 1).flatMap((item) => isPathSpec3(item) && toPaths(item) || item)
4554
+ );
4555
+ break;
4556
+ }
4557
+ prefix.push(param);
4558
+ }
4559
+ return !suffix ? prefix : [...prefix, "--", ...suffix.map(String)];
4560
+ }
4561
+ };
4562
+ }
4563
+
4564
+ // src/lib/git-factory.ts
4565
+ init_utils();
4566
+ var Git = require_git();
4567
+ function gitInstanceFactory(baseDir, options) {
4568
+ const plugins = new PluginStore();
4569
+ const config = createInstanceConfig(
4570
+ baseDir && (typeof baseDir === "string" ? { baseDir } : baseDir) || {},
4571
+ options
4572
+ );
4573
+ if (!folderExists(config.baseDir)) {
4574
+ throw new GitConstructError(
4575
+ config,
4576
+ `Cannot use simple-git on a directory that does not exist`
4577
+ );
4578
+ }
4579
+ if (Array.isArray(config.config)) {
4580
+ plugins.add(commandConfigPrefixingPlugin(config.config));
4581
+ }
4582
+ plugins.add(blockUnsafeOperationsPlugin(config.unsafe));
4583
+ plugins.add(completionDetectionPlugin(config.completion));
4584
+ config.abort && plugins.add(abortPlugin(config.abort));
4585
+ config.progress && plugins.add(progressMonitorPlugin(config.progress));
4586
+ config.timeout && plugins.add(timeoutPlugin(config.timeout));
4587
+ config.spawnOptions && plugins.add(spawnOptionsPlugin(config.spawnOptions));
4588
+ plugins.add(suffixPathsPlugin());
4589
+ plugins.add(errorDetectionPlugin(errorDetectionHandler(true)));
4590
+ config.errors && plugins.add(errorDetectionPlugin(config.errors));
4591
+ customBinaryPlugin(plugins, config.binary, config.unsafe?.allowUnsafeCustomBinary);
4592
+ return new Git(config, plugins);
4593
+ }
4594
+
4595
+ // src/lib/runners/promise-wrapped.ts
4596
+ init_git_response_error();
4597
+ var functionNamesBuilderApi = ["customBinary", "env", "outputHandler", "silent"];
4598
+ var functionNamesPromiseApi = [
4599
+ "add",
4600
+ "addAnnotatedTag",
4601
+ "addConfig",
4602
+ "addRemote",
4603
+ "addTag",
4604
+ "applyPatch",
4605
+ "binaryCatFile",
4606
+ "branch",
4607
+ "branchLocal",
4608
+ "catFile",
4609
+ "checkIgnore",
4610
+ "checkIsRepo",
4611
+ "checkout",
4612
+ "checkoutBranch",
4613
+ "checkoutLatestTag",
4614
+ "checkoutLocalBranch",
4615
+ "clean",
4616
+ "clone",
4617
+ "commit",
4618
+ "cwd",
4619
+ "deleteLocalBranch",
4620
+ "deleteLocalBranches",
4621
+ "diff",
4622
+ "diffSummary",
4623
+ "exec",
4624
+ "fetch",
4625
+ "getRemotes",
4626
+ "init",
4627
+ "listConfig",
4628
+ "listRemote",
4629
+ "log",
4630
+ "merge",
4631
+ "mergeFromTo",
4632
+ "mirror",
4633
+ "mv",
4634
+ "pull",
4635
+ "push",
4636
+ "pushTags",
4637
+ "raw",
4638
+ "rebase",
4639
+ "remote",
4640
+ "removeRemote",
4641
+ "reset",
4642
+ "revert",
4643
+ "revparse",
4644
+ "rm",
4645
+ "rmKeepLocal",
4646
+ "show",
4647
+ "stash",
4648
+ "stashList",
4649
+ "status",
4650
+ "subModule",
4651
+ "submoduleAdd",
4652
+ "submoduleInit",
4653
+ "submoduleUpdate",
4654
+ "tag",
4655
+ "tags",
4656
+ "updateServerInfo"
4657
+ ];
4658
+ function gitP(...args) {
4659
+ let git;
4660
+ let chain = Promise.resolve();
4661
+ try {
4662
+ git = gitInstanceFactory(...args);
4663
+ } catch (e) {
4664
+ chain = Promise.reject(e);
4665
+ }
4666
+ function builderReturn() {
4667
+ return promiseApi;
4668
+ }
4669
+ function chainReturn() {
4670
+ return chain;
4671
+ }
4672
+ const promiseApi = [...functionNamesBuilderApi, ...functionNamesPromiseApi].reduce(
4673
+ (api, name) => {
4674
+ const isAsync = functionNamesPromiseApi.includes(name);
4675
+ const valid = isAsync ? asyncWrapper(name, git) : syncWrapper(name, git, api);
4676
+ const alternative = isAsync ? chainReturn : builderReturn;
4677
+ Object.defineProperty(api, name, {
4678
+ enumerable: false,
4679
+ configurable: false,
4680
+ value: git ? valid : alternative
4681
+ });
4682
+ return api;
4683
+ },
4684
+ {}
4685
+ );
4686
+ return promiseApi;
4687
+ function asyncWrapper(fn, git2) {
4688
+ return function(...args2) {
4689
+ if (typeof args2[args2.length] === "function") {
4690
+ throw new TypeError(
4691
+ "Promise interface requires that handlers are not supplied inline, trailing function not allowed in call to " + fn
4692
+ );
4693
+ }
4694
+ return chain.then(function() {
4695
+ return new Promise(function(resolve, reject) {
4696
+ const callback = (err, result) => {
4697
+ if (err) {
4698
+ return reject(toError(err));
4699
+ }
4700
+ resolve(result);
4701
+ };
4702
+ args2.push(callback);
4703
+ git2[fn].apply(git2, args2);
4704
+ });
4705
+ });
4706
+ };
4707
+ }
4708
+ function syncWrapper(fn, git2, api) {
4709
+ return (...args2) => {
4710
+ git2[fn](...args2);
4711
+ return api;
4712
+ };
4713
+ }
4714
+ }
4715
+ function toError(error) {
4716
+ if (error instanceof Error) {
4717
+ return error;
4718
+ }
4719
+ if (typeof error === "string") {
4720
+ return new Error(error);
4721
+ }
4722
+ return new GitResponseError(error);
4723
+ }
4724
+
4725
+ // src/esm.mjs
4726
+ var simpleGit = gitInstanceFactory;
4727
+ var esm_default = gitInstanceFactory;
4728
+ export {
4729
+ CheckRepoActions,
4730
+ CleanOptions,
4731
+ DiffNameStatus,
4732
+ GitConfigScope,
4733
+ GitConstructError,
4734
+ GitError,
4735
+ GitPluginError,
4736
+ GitResponseError,
4737
+ ResetMode,
4738
+ TaskConfigurationError,
4739
+ esm_default as default,
4740
+ gitP,
4741
+ grepQueryBuilder,
4742
+ pathspec,
4743
+ simpleGit
4744
+ };
4745
+ //# sourceMappingURL=index.js.map