gitx.do 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/README.md +40 -353
  2. package/dist/do/logger.d.ts +50 -0
  3. package/dist/do/logger.d.ts.map +1 -0
  4. package/dist/do/logger.js +122 -0
  5. package/dist/do/logger.js.map +1 -0
  6. package/dist/{durable-object → do}/schema.d.ts +3 -3
  7. package/dist/do/schema.d.ts.map +1 -0
  8. package/dist/{durable-object → do}/schema.js +4 -3
  9. package/dist/do/schema.js.map +1 -0
  10. package/dist/do/types.d.ts +267 -0
  11. package/dist/do/types.d.ts.map +1 -0
  12. package/dist/do/types.js +62 -0
  13. package/dist/do/types.js.map +1 -0
  14. package/dist/index.d.ts +14 -469
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +31 -483
  17. package/dist/index.js.map +1 -1
  18. package/package.json +13 -21
  19. package/dist/cli/commands/add.d.ts +0 -176
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -979
  22. package/dist/cli/commands/add.js.map +0 -1
  23. package/dist/cli/commands/blame.d.ts +0 -259
  24. package/dist/cli/commands/blame.d.ts.map +0 -1
  25. package/dist/cli/commands/blame.js +0 -609
  26. package/dist/cli/commands/blame.js.map +0 -1
  27. package/dist/cli/commands/branch.d.ts +0 -249
  28. package/dist/cli/commands/branch.d.ts.map +0 -1
  29. package/dist/cli/commands/branch.js +0 -693
  30. package/dist/cli/commands/branch.js.map +0 -1
  31. package/dist/cli/commands/checkout.d.ts +0 -73
  32. package/dist/cli/commands/checkout.d.ts.map +0 -1
  33. package/dist/cli/commands/checkout.js +0 -725
  34. package/dist/cli/commands/checkout.js.map +0 -1
  35. package/dist/cli/commands/commit.d.ts +0 -182
  36. package/dist/cli/commands/commit.d.ts.map +0 -1
  37. package/dist/cli/commands/commit.js +0 -457
  38. package/dist/cli/commands/commit.js.map +0 -1
  39. package/dist/cli/commands/diff.d.ts +0 -464
  40. package/dist/cli/commands/diff.d.ts.map +0 -1
  41. package/dist/cli/commands/diff.js +0 -959
  42. package/dist/cli/commands/diff.js.map +0 -1
  43. package/dist/cli/commands/log.d.ts +0 -239
  44. package/dist/cli/commands/log.d.ts.map +0 -1
  45. package/dist/cli/commands/log.js +0 -535
  46. package/dist/cli/commands/log.js.map +0 -1
  47. package/dist/cli/commands/merge.d.ts +0 -106
  48. package/dist/cli/commands/merge.d.ts.map +0 -1
  49. package/dist/cli/commands/merge.js +0 -852
  50. package/dist/cli/commands/merge.js.map +0 -1
  51. package/dist/cli/commands/review.d.ts +0 -457
  52. package/dist/cli/commands/review.d.ts.map +0 -1
  53. package/dist/cli/commands/review.js +0 -558
  54. package/dist/cli/commands/review.js.map +0 -1
  55. package/dist/cli/commands/stash.d.ts +0 -157
  56. package/dist/cli/commands/stash.d.ts.map +0 -1
  57. package/dist/cli/commands/stash.js +0 -655
  58. package/dist/cli/commands/stash.js.map +0 -1
  59. package/dist/cli/commands/status.d.ts +0 -269
  60. package/dist/cli/commands/status.d.ts.map +0 -1
  61. package/dist/cli/commands/status.js +0 -492
  62. package/dist/cli/commands/status.js.map +0 -1
  63. package/dist/cli/commands/web.d.ts +0 -199
  64. package/dist/cli/commands/web.d.ts.map +0 -1
  65. package/dist/cli/commands/web.js +0 -697
  66. package/dist/cli/commands/web.js.map +0 -1
  67. package/dist/cli/fs-adapter.d.ts +0 -656
  68. package/dist/cli/fs-adapter.d.ts.map +0 -1
  69. package/dist/cli/fs-adapter.js +0 -1177
  70. package/dist/cli/fs-adapter.js.map +0 -1
  71. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  72. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  73. package/dist/cli/fsx-cli-adapter.js +0 -619
  74. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  75. package/dist/cli/index.d.ts +0 -387
  76. package/dist/cli/index.d.ts.map +0 -1
  77. package/dist/cli/index.js +0 -579
  78. package/dist/cli/index.js.map +0 -1
  79. package/dist/cli/ui/components/DiffView.d.ts +0 -12
  80. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  81. package/dist/cli/ui/components/DiffView.js +0 -11
  82. package/dist/cli/ui/components/DiffView.js.map +0 -1
  83. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -10
  84. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  85. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  86. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  87. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -15
  88. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  89. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  90. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  91. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -10
  92. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  93. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  94. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  95. package/dist/cli/ui/components/NavigationList.d.ts +0 -14
  96. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  97. package/dist/cli/ui/components/NavigationList.js +0 -11
  98. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  99. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -13
  100. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  101. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  102. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  103. package/dist/cli/ui/components/index.d.ts +0 -7
  104. package/dist/cli/ui/components/index.d.ts.map +0 -1
  105. package/dist/cli/ui/components/index.js +0 -9
  106. package/dist/cli/ui/components/index.js.map +0 -1
  107. package/dist/cli/ui/terminal-ui.d.ts +0 -85
  108. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  109. package/dist/cli/ui/terminal-ui.js +0 -121
  110. package/dist/cli/ui/terminal-ui.js.map +0 -1
  111. package/dist/do/BashModule.d.ts +0 -871
  112. package/dist/do/BashModule.d.ts.map +0 -1
  113. package/dist/do/BashModule.js +0 -1143
  114. package/dist/do/BashModule.js.map +0 -1
  115. package/dist/do/FsModule.d.ts +0 -612
  116. package/dist/do/FsModule.d.ts.map +0 -1
  117. package/dist/do/FsModule.js +0 -1120
  118. package/dist/do/FsModule.js.map +0 -1
  119. package/dist/do/GitModule.d.ts +0 -635
  120. package/dist/do/GitModule.d.ts.map +0 -1
  121. package/dist/do/GitModule.js +0 -784
  122. package/dist/do/GitModule.js.map +0 -1
  123. package/dist/do/GitRepoDO.d.ts +0 -281
  124. package/dist/do/GitRepoDO.d.ts.map +0 -1
  125. package/dist/do/GitRepoDO.js +0 -479
  126. package/dist/do/GitRepoDO.js.map +0 -1
  127. package/dist/do/bash-ast.d.ts +0 -246
  128. package/dist/do/bash-ast.d.ts.map +0 -1
  129. package/dist/do/bash-ast.js +0 -888
  130. package/dist/do/bash-ast.js.map +0 -1
  131. package/dist/do/container-executor.d.ts +0 -491
  132. package/dist/do/container-executor.d.ts.map +0 -1
  133. package/dist/do/container-executor.js +0 -731
  134. package/dist/do/container-executor.js.map +0 -1
  135. package/dist/do/index.d.ts +0 -53
  136. package/dist/do/index.d.ts.map +0 -1
  137. package/dist/do/index.js +0 -91
  138. package/dist/do/index.js.map +0 -1
  139. package/dist/do/tiered-storage.d.ts +0 -403
  140. package/dist/do/tiered-storage.d.ts.map +0 -1
  141. package/dist/do/tiered-storage.js +0 -689
  142. package/dist/do/tiered-storage.js.map +0 -1
  143. package/dist/do/withBash.d.ts +0 -231
  144. package/dist/do/withBash.d.ts.map +0 -1
  145. package/dist/do/withBash.js +0 -244
  146. package/dist/do/withBash.js.map +0 -1
  147. package/dist/do/withFs.d.ts +0 -237
  148. package/dist/do/withFs.d.ts.map +0 -1
  149. package/dist/do/withFs.js +0 -387
  150. package/dist/do/withFs.js.map +0 -1
  151. package/dist/do/withGit.d.ts +0 -180
  152. package/dist/do/withGit.d.ts.map +0 -1
  153. package/dist/do/withGit.js +0 -271
  154. package/dist/do/withGit.js.map +0 -1
  155. package/dist/durable-object/object-store.d.ts +0 -633
  156. package/dist/durable-object/object-store.d.ts.map +0 -1
  157. package/dist/durable-object/object-store.js +0 -1164
  158. package/dist/durable-object/object-store.js.map +0 -1
  159. package/dist/durable-object/schema.d.ts.map +0 -1
  160. package/dist/durable-object/schema.js.map +0 -1
  161. package/dist/durable-object/wal.d.ts +0 -416
  162. package/dist/durable-object/wal.d.ts.map +0 -1
  163. package/dist/durable-object/wal.js +0 -445
  164. package/dist/durable-object/wal.js.map +0 -1
  165. package/dist/mcp/adapter.d.ts +0 -772
  166. package/dist/mcp/adapter.d.ts.map +0 -1
  167. package/dist/mcp/adapter.js +0 -895
  168. package/dist/mcp/adapter.js.map +0 -1
  169. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  170. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  172. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  173. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  174. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  175. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  176. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  177. package/dist/mcp/sandbox/template.d.ts +0 -17
  178. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  179. package/dist/mcp/sandbox/template.js +0 -71
  180. package/dist/mcp/sandbox/template.js.map +0 -1
  181. package/dist/mcp/sandbox.d.ts +0 -764
  182. package/dist/mcp/sandbox.d.ts.map +0 -1
  183. package/dist/mcp/sandbox.js +0 -1362
  184. package/dist/mcp/sandbox.js.map +0 -1
  185. package/dist/mcp/sdk-adapter.d.ts +0 -835
  186. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  187. package/dist/mcp/sdk-adapter.js +0 -974
  188. package/dist/mcp/sdk-adapter.js.map +0 -1
  189. package/dist/mcp/tools/do.d.ts +0 -32
  190. package/dist/mcp/tools/do.d.ts.map +0 -1
  191. package/dist/mcp/tools/do.js +0 -117
  192. package/dist/mcp/tools/do.js.map +0 -1
  193. package/dist/mcp/tools.d.ts +0 -548
  194. package/dist/mcp/tools.d.ts.map +0 -1
  195. package/dist/mcp/tools.js +0 -3170
  196. package/dist/mcp/tools.js.map +0 -1
  197. package/dist/ops/blame.d.ts +0 -551
  198. package/dist/ops/blame.d.ts.map +0 -1
  199. package/dist/ops/blame.js +0 -1037
  200. package/dist/ops/blame.js.map +0 -1
  201. package/dist/ops/branch.d.ts +0 -766
  202. package/dist/ops/branch.d.ts.map +0 -1
  203. package/dist/ops/branch.js +0 -950
  204. package/dist/ops/branch.js.map +0 -1
  205. package/dist/ops/commit-traversal.d.ts +0 -349
  206. package/dist/ops/commit-traversal.d.ts.map +0 -1
  207. package/dist/ops/commit-traversal.js +0 -821
  208. package/dist/ops/commit-traversal.js.map +0 -1
  209. package/dist/ops/commit.d.ts +0 -555
  210. package/dist/ops/commit.d.ts.map +0 -1
  211. package/dist/ops/commit.js +0 -826
  212. package/dist/ops/commit.js.map +0 -1
  213. package/dist/ops/merge-base.d.ts +0 -397
  214. package/dist/ops/merge-base.d.ts.map +0 -1
  215. package/dist/ops/merge-base.js +0 -691
  216. package/dist/ops/merge-base.js.map +0 -1
  217. package/dist/ops/merge.d.ts +0 -855
  218. package/dist/ops/merge.d.ts.map +0 -1
  219. package/dist/ops/merge.js +0 -1551
  220. package/dist/ops/merge.js.map +0 -1
  221. package/dist/ops/tag.d.ts +0 -247
  222. package/dist/ops/tag.d.ts.map +0 -1
  223. package/dist/ops/tag.js +0 -649
  224. package/dist/ops/tag.js.map +0 -1
  225. package/dist/ops/tree-builder.d.ts +0 -178
  226. package/dist/ops/tree-builder.d.ts.map +0 -1
  227. package/dist/ops/tree-builder.js +0 -271
  228. package/dist/ops/tree-builder.js.map +0 -1
  229. package/dist/ops/tree-diff.d.ts +0 -291
  230. package/dist/ops/tree-diff.d.ts.map +0 -1
  231. package/dist/ops/tree-diff.js +0 -705
  232. package/dist/ops/tree-diff.js.map +0 -1
  233. package/dist/pack/delta.d.ts +0 -248
  234. package/dist/pack/delta.d.ts.map +0 -1
  235. package/dist/pack/delta.js +0 -740
  236. package/dist/pack/delta.js.map +0 -1
  237. package/dist/pack/format.d.ts +0 -446
  238. package/dist/pack/format.d.ts.map +0 -1
  239. package/dist/pack/format.js +0 -572
  240. package/dist/pack/format.js.map +0 -1
  241. package/dist/pack/full-generation.d.ts +0 -612
  242. package/dist/pack/full-generation.d.ts.map +0 -1
  243. package/dist/pack/full-generation.js +0 -1378
  244. package/dist/pack/full-generation.js.map +0 -1
  245. package/dist/pack/generation.d.ts +0 -441
  246. package/dist/pack/generation.d.ts.map +0 -1
  247. package/dist/pack/generation.js +0 -707
  248. package/dist/pack/generation.js.map +0 -1
  249. package/dist/pack/index.d.ts +0 -502
  250. package/dist/pack/index.d.ts.map +0 -1
  251. package/dist/pack/index.js +0 -833
  252. package/dist/pack/index.js.map +0 -1
  253. package/dist/refs/branch.d.ts +0 -683
  254. package/dist/refs/branch.d.ts.map +0 -1
  255. package/dist/refs/branch.js +0 -881
  256. package/dist/refs/branch.js.map +0 -1
  257. package/dist/refs/storage.d.ts +0 -833
  258. package/dist/refs/storage.d.ts.map +0 -1
  259. package/dist/refs/storage.js +0 -1023
  260. package/dist/refs/storage.js.map +0 -1
  261. package/dist/refs/tag.d.ts +0 -860
  262. package/dist/refs/tag.d.ts.map +0 -1
  263. package/dist/refs/tag.js +0 -996
  264. package/dist/refs/tag.js.map +0 -1
  265. package/dist/storage/backend.d.ts +0 -425
  266. package/dist/storage/backend.d.ts.map +0 -1
  267. package/dist/storage/backend.js +0 -41
  268. package/dist/storage/backend.js.map +0 -1
  269. package/dist/storage/fsx-adapter.d.ts +0 -204
  270. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  271. package/dist/storage/fsx-adapter.js +0 -518
  272. package/dist/storage/fsx-adapter.js.map +0 -1
  273. package/dist/storage/lru-cache.d.ts +0 -691
  274. package/dist/storage/lru-cache.d.ts.map +0 -1
  275. package/dist/storage/lru-cache.js +0 -813
  276. package/dist/storage/lru-cache.js.map +0 -1
  277. package/dist/storage/object-index.d.ts +0 -585
  278. package/dist/storage/object-index.d.ts.map +0 -1
  279. package/dist/storage/object-index.js +0 -532
  280. package/dist/storage/object-index.js.map +0 -1
  281. package/dist/storage/r2-pack.d.ts +0 -1257
  282. package/dist/storage/r2-pack.d.ts.map +0 -1
  283. package/dist/storage/r2-pack.js +0 -1773
  284. package/dist/storage/r2-pack.js.map +0 -1
  285. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  286. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  287. package/dist/tiered/cdc-pipeline.js +0 -1880
  288. package/dist/tiered/cdc-pipeline.js.map +0 -1
  289. package/dist/tiered/migration.d.ts +0 -1104
  290. package/dist/tiered/migration.d.ts.map +0 -1
  291. package/dist/tiered/migration.js +0 -1217
  292. package/dist/tiered/migration.js.map +0 -1
  293. package/dist/tiered/parquet-writer.d.ts +0 -1145
  294. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  295. package/dist/tiered/parquet-writer.js +0 -1183
  296. package/dist/tiered/parquet-writer.js.map +0 -1
  297. package/dist/tiered/read-path.d.ts +0 -835
  298. package/dist/tiered/read-path.d.ts.map +0 -1
  299. package/dist/tiered/read-path.js +0 -487
  300. package/dist/tiered/read-path.js.map +0 -1
  301. package/dist/types/capability.d.ts +0 -1385
  302. package/dist/types/capability.d.ts.map +0 -1
  303. package/dist/types/capability.js +0 -36
  304. package/dist/types/capability.js.map +0 -1
  305. package/dist/types/index.d.ts +0 -13
  306. package/dist/types/index.d.ts.map +0 -1
  307. package/dist/types/index.js +0 -18
  308. package/dist/types/index.js.map +0 -1
  309. package/dist/types/interfaces.d.ts +0 -673
  310. package/dist/types/interfaces.d.ts.map +0 -1
  311. package/dist/types/interfaces.js +0 -26
  312. package/dist/types/interfaces.js.map +0 -1
  313. package/dist/types/objects.d.ts +0 -692
  314. package/dist/types/objects.d.ts.map +0 -1
  315. package/dist/types/objects.js +0 -837
  316. package/dist/types/objects.js.map +0 -1
  317. package/dist/types/storage.d.ts +0 -603
  318. package/dist/types/storage.d.ts.map +0 -1
  319. package/dist/types/storage.js +0 -191
  320. package/dist/types/storage.js.map +0 -1
  321. package/dist/types/worker-loader.d.ts +0 -60
  322. package/dist/types/worker-loader.d.ts.map +0 -1
  323. package/dist/types/worker-loader.js +0 -62
  324. package/dist/types/worker-loader.js.map +0 -1
  325. package/dist/utils/hash.d.ts +0 -198
  326. package/dist/utils/hash.d.ts.map +0 -1
  327. package/dist/utils/hash.js +0 -272
  328. package/dist/utils/hash.js.map +0 -1
  329. package/dist/utils/sha1.d.ts +0 -325
  330. package/dist/utils/sha1.d.ts.map +0 -1
  331. package/dist/utils/sha1.js +0 -635
  332. package/dist/utils/sha1.js.map +0 -1
  333. package/dist/wire/capabilities.d.ts +0 -1044
  334. package/dist/wire/capabilities.d.ts.map +0 -1
  335. package/dist/wire/capabilities.js +0 -941
  336. package/dist/wire/capabilities.js.map +0 -1
  337. package/dist/wire/path-security.d.ts +0 -157
  338. package/dist/wire/path-security.d.ts.map +0 -1
  339. package/dist/wire/path-security.js +0 -307
  340. package/dist/wire/path-security.js.map +0 -1
  341. package/dist/wire/pkt-line.d.ts +0 -345
  342. package/dist/wire/pkt-line.d.ts.map +0 -1
  343. package/dist/wire/pkt-line.js +0 -381
  344. package/dist/wire/pkt-line.js.map +0 -1
  345. package/dist/wire/receive-pack.d.ts +0 -1059
  346. package/dist/wire/receive-pack.d.ts.map +0 -1
  347. package/dist/wire/receive-pack.js +0 -1414
  348. package/dist/wire/receive-pack.js.map +0 -1
  349. package/dist/wire/smart-http.d.ts +0 -799
  350. package/dist/wire/smart-http.d.ts.map +0 -1
  351. package/dist/wire/smart-http.js +0 -945
  352. package/dist/wire/smart-http.js.map +0 -1
  353. package/dist/wire/upload-pack.d.ts +0 -727
  354. package/dist/wire/upload-pack.d.ts.map +0 -1
  355. package/dist/wire/upload-pack.js +0 -1141
  356. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,821 +0,0 @@
1
- /**
2
- * @fileoverview Commit Graph Traversal
3
- *
4
- * Provides functionality for walking commit graphs, finding ancestors,
5
- * topological sorting, and revision range parsing.
6
- *
7
- * ## Features
8
- *
9
- * - Commit graph walking with various traversal strategies
10
- * - Topological and date-based sorting
11
- * - Revision range parsing (A..B, A...B syntax)
12
- * - Ancestor and merge base finding
13
- * - Path-based commit filtering
14
- * - Author/date/message filtering
15
- *
16
- * ## Usage Example
17
- *
18
- * ```typescript
19
- * import { walkCommits, CommitWalker } from './ops/commit-traversal'
20
- *
21
- * // Walk commits from HEAD
22
- * for await (const commit of walkCommits(provider, headSha, {
23
- * maxCount: 10,
24
- * sort: 'topological'
25
- * })) {
26
- * console.log(commit.sha, commit.commit.message)
27
- * }
28
- *
29
- * // Use CommitWalker for more control
30
- * const walker = new CommitWalker(provider)
31
- * walker.push(startSha)
32
- * walker.hide(excludeSha) // Exclude this commit and its ancestors
33
- *
34
- * while (walker.hasNext()) {
35
- * const commit = await walker.next()
36
- * // Process commit...
37
- * }
38
- * ```
39
- *
40
- * @module ops/commit-traversal
41
- */
42
- // ============================================================================
43
- // CommitWalker Class
44
- // ============================================================================
45
- /**
46
- * Walker for traversing commit graphs.
47
- *
48
- * Supports various traversal strategies including topological sorting,
49
- * date-based sorting, path filtering, and revision ranges.
50
- *
51
- * The walker maintains state and can be used for incremental traversal,
52
- * making it suitable for large repositories where you want to process
53
- * commits in batches.
54
- *
55
- * @class CommitWalker
56
- *
57
- * @example
58
- * ```typescript
59
- * // Create walker
60
- * const walker = new CommitWalker(provider, { firstParentOnly: true })
61
- *
62
- * // Add starting points
63
- * walker.push('abc123')
64
- * walker.push('def456')
65
- *
66
- * // Exclude certain commits
67
- * walker.hide('old-base-sha')
68
- *
69
- * // Iterate
70
- * let commit = await walker.next()
71
- * while (commit) {
72
- * console.log(commit.sha)
73
- * commit = await walker.next()
74
- * }
75
- *
76
- * // Or use async iteration
77
- * for await (const commit of walker) {
78
- * console.log(commit.sha)
79
- * }
80
- * ```
81
- */
82
- export class CommitWalker {
83
- provider;
84
- options;
85
- visited = new Set();
86
- hidden = new Set();
87
- queue = [];
88
- hiddenExpanded = false;
89
- constructor(provider, options = {}) {
90
- this.provider = provider;
91
- this.options = options;
92
- }
93
- /**
94
- * Reset the walker state
95
- */
96
- reset() {
97
- this.visited = new Set();
98
- this.hidden = new Set();
99
- this.queue = [];
100
- this.hiddenExpanded = false;
101
- }
102
- /**
103
- * Add a starting commit to the walker
104
- */
105
- push(sha) {
106
- if (!this.visited.has(sha) && !this.hidden.has(sha)) {
107
- this.queue.push({ sha, depth: 0 });
108
- }
109
- }
110
- /**
111
- * Hide a commit and its ancestors from the walk
112
- */
113
- hide(sha) {
114
- this.hidden.add(sha);
115
- }
116
- /**
117
- * Expand hidden commits to include all ancestors
118
- */
119
- async expandHidden() {
120
- if (this.hiddenExpanded)
121
- return;
122
- this.hiddenExpanded = true;
123
- const toExpand = [...this.hidden];
124
- const expanded = new Set(this.hidden);
125
- while (toExpand.length > 0) {
126
- const sha = toExpand.pop();
127
- const commit = await this.provider.getCommit(sha);
128
- if (!commit)
129
- continue;
130
- for (const parent of commit.parents) {
131
- if (!expanded.has(parent)) {
132
- expanded.add(parent);
133
- toExpand.push(parent);
134
- }
135
- }
136
- }
137
- this.hidden = expanded;
138
- }
139
- /**
140
- * Get the next commit in the walk
141
- */
142
- async next() {
143
- // Expand hidden commits on first call
144
- await this.expandHidden();
145
- while (this.queue.length > 0) {
146
- const { sha, depth } = this.queue.shift();
147
- // Skip if visited or hidden
148
- if (this.visited.has(sha) || this.hidden.has(sha)) {
149
- continue;
150
- }
151
- const commit = await this.provider.getCommit(sha);
152
- if (!commit)
153
- continue;
154
- this.visited.add(sha);
155
- // Add parents to queue
156
- const parentsToAdd = this.options.firstParentOnly
157
- ? commit.parents.slice(0, 1)
158
- : commit.parents;
159
- for (const parent of parentsToAdd) {
160
- if (!this.visited.has(parent) && !this.hidden.has(parent)) {
161
- this.queue.push({ sha: parent, depth: depth + 1 });
162
- }
163
- }
164
- return {
165
- sha,
166
- commit,
167
- depth,
168
- isMerge: commit.parents.length > 1
169
- };
170
- }
171
- return null;
172
- }
173
- /**
174
- * Check if there are more commits to walk
175
- */
176
- hasNext() {
177
- // Check if there are any unvisited, non-hidden commits in the queue
178
- return this.queue.some(({ sha }) => !this.visited.has(sha) && !this.hidden.has(sha));
179
- }
180
- /**
181
- * Iterate over all commits matching the options
182
- */
183
- async *[Symbol.asyncIterator]() {
184
- let commit = await this.next();
185
- while (commit !== null) {
186
- yield commit;
187
- commit = await this.next();
188
- }
189
- }
190
- }
191
- // ============================================================================
192
- // Generator Function
193
- // ============================================================================
194
- /**
195
- * Walk commits starting from the given SHA(s)
196
- *
197
- * @param provider - The commit provider for fetching commits
198
- * @param start - Starting commit SHA or array of SHAs
199
- * @param options - Traversal options
200
- * @yields TraversalCommit objects in the requested order
201
- */
202
- export async function* walkCommits(provider, start, options = {}) {
203
- const startShas = Array.isArray(start) ? start : [start];
204
- const { maxCount, skip = 0, paths, sort = 'none', reverse = false, exclude, includeMerges = true, firstParentOnly = false, author, committer, after, before, grep } = options;
205
- // If maxCount is 0, return immediately
206
- if (maxCount === 0) {
207
- return;
208
- }
209
- // Get commits that match path filters
210
- let pathMatchingCommits = null;
211
- if (paths && paths.length > 0 && provider.getCommitsForPath) {
212
- pathMatchingCommits = new Set();
213
- for (const path of paths) {
214
- const commits = await provider.getCommitsForPath(path);
215
- for (const sha of commits) {
216
- pathMatchingCommits.add(sha);
217
- }
218
- }
219
- // If no commits match paths, return empty
220
- if (pathMatchingCommits.size === 0) {
221
- return;
222
- }
223
- }
224
- // Build set of hidden commits (exclude and their ancestors)
225
- const hidden = new Set();
226
- if (exclude && exclude.length > 0) {
227
- const toExpand = [...exclude];
228
- while (toExpand.length > 0) {
229
- const sha = toExpand.pop();
230
- if (hidden.has(sha))
231
- continue;
232
- hidden.add(sha);
233
- const commit = await provider.getCommit(sha);
234
- if (commit) {
235
- for (const parent of commit.parents) {
236
- toExpand.push(parent);
237
- }
238
- }
239
- }
240
- }
241
- // Collect all commits first for sorting
242
- const allCommits = [];
243
- const visited = new Set();
244
- const queue = startShas.map(sha => ({
245
- sha,
246
- depth: 0
247
- }));
248
- while (queue.length > 0) {
249
- // For date-based sorting, we need to process in date order
250
- if (sort === 'date' || sort === 'author-date') {
251
- // Sort queue by date (most recent first)
252
- queue.sort((_a, _b) => {
253
- // We need to fetch commits to sort - use simple queue position for now
254
- return 0;
255
- });
256
- }
257
- const { sha, depth } = queue.shift();
258
- if (visited.has(sha) || hidden.has(sha)) {
259
- continue;
260
- }
261
- const commit = await provider.getCommit(sha);
262
- if (!commit)
263
- continue;
264
- visited.add(sha);
265
- // Add parents to queue
266
- const parentsToAdd = firstParentOnly
267
- ? commit.parents.slice(0, 1)
268
- : commit.parents;
269
- for (const parent of parentsToAdd) {
270
- if (!visited.has(parent) && !hidden.has(parent)) {
271
- queue.push({ sha: parent, depth: depth + 1 });
272
- }
273
- }
274
- const traversalCommit = {
275
- sha,
276
- commit,
277
- depth,
278
- isMerge: commit.parents.length > 1
279
- };
280
- allCommits.push(traversalCommit);
281
- }
282
- // Apply sorting
283
- let sortedCommits = [...allCommits];
284
- if (sort === 'topological') {
285
- // Topological sort - children before parents
286
- const shas = sortedCommits.map(c => c.sha);
287
- const sortedShas = await topologicalSort(provider, shas);
288
- const shaToCommit = new Map(sortedCommits.map(c => [c.sha, c]));
289
- sortedCommits = sortedShas.map(sha => shaToCommit.get(sha)).filter(Boolean);
290
- }
291
- else if (sort === 'date') {
292
- // Sort by committer date (newest first)
293
- sortedCommits.sort((a, b) => b.commit.committer.timestamp - a.commit.committer.timestamp);
294
- }
295
- else if (sort === 'author-date') {
296
- // Sort by author date (newest first)
297
- sortedCommits.sort((a, b) => b.commit.author.timestamp - a.commit.author.timestamp);
298
- }
299
- // Reverse if requested
300
- if (reverse) {
301
- sortedCommits.reverse();
302
- }
303
- // Apply filters and yield commits
304
- let skipped = 0;
305
- let yielded = 0;
306
- for (const traversalCommit of sortedCommits) {
307
- const { commit, sha } = traversalCommit;
308
- // Path filter
309
- if (pathMatchingCommits && !pathMatchingCommits.has(sha)) {
310
- continue;
311
- }
312
- // Merge filter
313
- if (!includeMerges && commit.parents.length > 1) {
314
- continue;
315
- }
316
- // Author filter
317
- if (author && commit.author.name !== author) {
318
- continue;
319
- }
320
- // Committer filter
321
- if (committer && commit.committer.name !== committer) {
322
- continue;
323
- }
324
- // Date filters
325
- const commitTimestamp = commit.committer.timestamp * 1000;
326
- if (after && commitTimestamp <= after.getTime()) {
327
- continue;
328
- }
329
- if (before && commitTimestamp >= before.getTime()) {
330
- continue;
331
- }
332
- // Grep filter
333
- if (grep) {
334
- const pattern = typeof grep === 'string' ? new RegExp(grep) : grep;
335
- if (!pattern.test(commit.message)) {
336
- continue;
337
- }
338
- }
339
- // Skip handling
340
- if (skipped < skip) {
341
- skipped++;
342
- continue;
343
- }
344
- // MaxCount handling
345
- if (maxCount !== undefined && yielded >= maxCount) {
346
- return;
347
- }
348
- yield traversalCommit;
349
- yielded++;
350
- }
351
- }
352
- // ============================================================================
353
- // Ancestor Functions
354
- // ============================================================================
355
- /**
356
- * Check if commit A is an ancestor of commit B
357
- *
358
- * @param provider - The commit provider for fetching commits
359
- * @param ancestor - Potential ancestor commit SHA
360
- * @param descendant - Potential descendant commit SHA
361
- * @returns true if ancestor is reachable from descendant
362
- */
363
- export async function isAncestor(provider, ancestor, descendant) {
364
- // Same commit is considered its own ancestor
365
- if (ancestor === descendant) {
366
- return true;
367
- }
368
- const visited = new Set();
369
- const queue = [descendant];
370
- while (queue.length > 0) {
371
- const sha = queue.shift();
372
- if (visited.has(sha))
373
- continue;
374
- visited.add(sha);
375
- if (sha === ancestor) {
376
- return true;
377
- }
378
- const commit = await provider.getCommit(sha);
379
- if (!commit)
380
- continue;
381
- for (const parent of commit.parents) {
382
- if (!visited.has(parent)) {
383
- queue.push(parent);
384
- }
385
- }
386
- }
387
- return false;
388
- }
389
- /**
390
- * Find the common ancestor(s) of two commits
391
- *
392
- * @param provider - The commit provider for fetching commits
393
- * @param commit1 - First commit SHA
394
- * @param commit2 - Second commit SHA
395
- * @param all - If true, return all common ancestors; if false, return only the best one
396
- * @returns The common ancestor SHA(s), or null if none found
397
- */
398
- export async function findCommonAncestor(provider, commit1, commit2, all) {
399
- // Get all ancestors of commit1
400
- const ancestors1 = new Set();
401
- const queue1 = [commit1];
402
- while (queue1.length > 0) {
403
- const sha = queue1.shift();
404
- if (ancestors1.has(sha))
405
- continue;
406
- ancestors1.add(sha);
407
- const commit = await provider.getCommit(sha);
408
- if (commit) {
409
- for (const parent of commit.parents) {
410
- queue1.push(parent);
411
- }
412
- }
413
- }
414
- // Find common ancestors by walking from commit2
415
- const commonAncestors = [];
416
- const visited2 = new Set();
417
- const queue2 = [commit2];
418
- while (queue2.length > 0) {
419
- const sha = queue2.shift();
420
- if (visited2.has(sha))
421
- continue;
422
- visited2.add(sha);
423
- if (ancestors1.has(sha)) {
424
- commonAncestors.push(sha);
425
- if (!all) {
426
- // For single result, return the first common ancestor (best merge base)
427
- return sha;
428
- }
429
- // Don't explore further ancestors of common ancestors
430
- continue;
431
- }
432
- const commit = await provider.getCommit(sha);
433
- if (commit) {
434
- for (const parent of commit.parents) {
435
- queue2.push(parent);
436
- }
437
- }
438
- }
439
- if (commonAncestors.length === 0) {
440
- return null;
441
- }
442
- if (all) {
443
- return commonAncestors;
444
- }
445
- return commonAncestors[0] || null;
446
- }
447
- /**
448
- * Find the merge base(s) of multiple commits
449
- *
450
- * @param provider - The commit provider for fetching commits
451
- * @param commits - Array of commit SHAs
452
- * @returns The merge base SHA(s)
453
- */
454
- export async function findMergeBase(provider, commits) {
455
- if (commits.length === 0) {
456
- return [];
457
- }
458
- if (commits.length === 1) {
459
- return [commits[0]];
460
- }
461
- // Find common ancestor of first two commits
462
- let result = await findCommonAncestor(provider, commits[0], commits[1], true);
463
- if (result === null) {
464
- return [];
465
- }
466
- let bases = Array.isArray(result) ? result : [result];
467
- // For each additional commit, find common ancestor with current bases
468
- for (let i = 2; i < commits.length; i++) {
469
- const newBases = [];
470
- for (const base of bases) {
471
- const ancestor = await findCommonAncestor(provider, base, commits[i], true);
472
- if (ancestor !== null) {
473
- const ancestors = Array.isArray(ancestor) ? ancestor : [ancestor];
474
- for (const a of ancestors) {
475
- if (!newBases.includes(a)) {
476
- newBases.push(a);
477
- }
478
- }
479
- }
480
- }
481
- if (newBases.length === 0) {
482
- return [];
483
- }
484
- bases = newBases;
485
- }
486
- return bases;
487
- }
488
- // ============================================================================
489
- // Revision Range Parsing
490
- // ============================================================================
491
- /**
492
- * Parse a revision range specification
493
- *
494
- * Supports:
495
- * - Single commit: "abc123"
496
- * - Two-dot range: "A..B" (commits reachable from B but not from A)
497
- * - Three-dot range: "A...B" (symmetric difference)
498
- * - Caret exclusion: "^A B" (B excluding A)
499
- *
500
- * @param spec - The revision specification string
501
- * @returns Parsed revision range
502
- */
503
- export function parseRevisionRange(spec) {
504
- // Check for three-dot range first (to avoid matching .. before ...)
505
- if (spec.includes('...')) {
506
- const [left, right] = spec.split('...');
507
- return {
508
- type: 'three-dot',
509
- left,
510
- right
511
- };
512
- }
513
- // Check for two-dot range
514
- if (spec.includes('..')) {
515
- const [left, right] = spec.split('..');
516
- return {
517
- type: 'two-dot',
518
- left,
519
- right
520
- };
521
- }
522
- // Single commit reference
523
- return {
524
- type: 'single',
525
- left: spec
526
- };
527
- }
528
- /**
529
- * Expand a revision range into include/exclude commit sets
530
- *
531
- * @param provider - The commit provider for fetching commits
532
- * @param range - The parsed revision range
533
- * @returns Object with include and exclude commit arrays
534
- */
535
- export async function expandRevisionRange(provider, range) {
536
- if (range.type === 'single') {
537
- return {
538
- include: [range.left],
539
- exclude: []
540
- };
541
- }
542
- if (range.type === 'two-dot') {
543
- // A..B means commits reachable from B but not from A
544
- // Include: all commits reachable from B
545
- // Exclude: all commits reachable from A (including A)
546
- const include = [];
547
- const exclude = [];
548
- // Get commits reachable from right (B)
549
- const visited = new Set();
550
- const queue = [range.right];
551
- while (queue.length > 0) {
552
- const sha = queue.shift();
553
- if (visited.has(sha))
554
- continue;
555
- visited.add(sha);
556
- include.push(sha);
557
- const commit = await provider.getCommit(sha);
558
- if (commit) {
559
- for (const parent of commit.parents) {
560
- queue.push(parent);
561
- }
562
- }
563
- }
564
- // Get commits reachable from left (A) to exclude
565
- const excludeVisited = new Set();
566
- const excludeQueue = [range.left];
567
- while (excludeQueue.length > 0) {
568
- const sha = excludeQueue.shift();
569
- if (excludeVisited.has(sha))
570
- continue;
571
- excludeVisited.add(sha);
572
- exclude.push(sha);
573
- const commit = await provider.getCommit(sha);
574
- if (commit) {
575
- for (const parent of commit.parents) {
576
- excludeQueue.push(parent);
577
- }
578
- }
579
- }
580
- return { include, exclude };
581
- }
582
- if (range.type === 'three-dot') {
583
- // A...B means symmetric difference (commits in either A or B but not both)
584
- // Find merge base and include commits from both sides up to merge base
585
- const mergeBase = await findCommonAncestor(provider, range.left, range.right);
586
- const exclude = [];
587
- if (mergeBase) {
588
- // Exclude merge base and its ancestors
589
- const baseCommits = Array.isArray(mergeBase) ? mergeBase : [mergeBase];
590
- for (const base of baseCommits) {
591
- exclude.push(base);
592
- const visited = new Set();
593
- const queue = [base];
594
- while (queue.length > 0) {
595
- const sha = queue.shift();
596
- if (visited.has(sha))
597
- continue;
598
- visited.add(sha);
599
- const commit = await provider.getCommit(sha);
600
- if (commit) {
601
- for (const parent of commit.parents) {
602
- if (!visited.has(parent)) {
603
- exclude.push(parent);
604
- queue.push(parent);
605
- }
606
- }
607
- }
608
- }
609
- }
610
- }
611
- return {
612
- include: [range.left, range.right],
613
- exclude
614
- };
615
- }
616
- return { include: [], exclude: [] };
617
- }
618
- // ============================================================================
619
- // Sorting Functions
620
- // ============================================================================
621
- /**
622
- * Sort commits topologically (children before parents)
623
- *
624
- * @param provider - The commit provider for fetching commits
625
- * @param commits - Array of commit SHAs to sort
626
- * @returns Sorted array of commit SHAs
627
- */
628
- export async function topologicalSort(provider, commits) {
629
- if (commits.length === 0) {
630
- return [];
631
- }
632
- const commitSet = new Set(commits);
633
- const commitData = new Map();
634
- // Fetch all commit data
635
- for (const sha of commits) {
636
- const commit = await provider.getCommit(sha);
637
- if (commit) {
638
- commitData.set(sha, commit);
639
- }
640
- }
641
- // Build in-degree map (count of children within the set)
642
- const inDegree = new Map();
643
- for (const sha of commits) {
644
- inDegree.set(sha, 0);
645
- }
646
- // Calculate in-degrees: for each parent, increment its in-degree
647
- for (const sha of commits) {
648
- const commit = commitData.get(sha);
649
- if (commit) {
650
- for (const parent of commit.parents) {
651
- if (commitSet.has(parent)) {
652
- inDegree.set(parent, (inDegree.get(parent) || 0) + 1);
653
- }
654
- }
655
- }
656
- }
657
- // Find all commits with no children (in-degree 0) - these are the starting points
658
- const queue = [];
659
- for (const [sha, degree] of inDegree) {
660
- if (degree === 0) {
661
- queue.push(sha);
662
- }
663
- }
664
- // Sort queue by timestamp (newest first) for consistent ordering
665
- queue.sort((a, b) => {
666
- const commitA = commitData.get(a);
667
- const commitB = commitData.get(b);
668
- if (!commitA || !commitB)
669
- return 0;
670
- return commitB.committer.timestamp - commitA.committer.timestamp;
671
- });
672
- const result = [];
673
- while (queue.length > 0) {
674
- // Take the first from queue (sorted by timestamp)
675
- const sha = queue.shift();
676
- result.push(sha);
677
- const commit = commitData.get(sha);
678
- if (commit) {
679
- for (const parent of commit.parents) {
680
- if (commitSet.has(parent)) {
681
- const newDegree = (inDegree.get(parent) || 0) - 1;
682
- inDegree.set(parent, newDegree);
683
- if (newDegree === 0) {
684
- // Insert in sorted order by timestamp
685
- const parentCommit = commitData.get(parent);
686
- if (parentCommit) {
687
- let insertIndex = 0;
688
- for (let i = 0; i < queue.length; i++) {
689
- const queueCommit = commitData.get(queue[i]);
690
- if (queueCommit &&
691
- parentCommit.committer.timestamp <=
692
- queueCommit.committer.timestamp) {
693
- insertIndex = i + 1;
694
- }
695
- else {
696
- break;
697
- }
698
- }
699
- queue.splice(insertIndex, 0, parent);
700
- }
701
- else {
702
- queue.push(parent);
703
- }
704
- }
705
- }
706
- }
707
- }
708
- }
709
- return result;
710
- }
711
- /**
712
- * Sort commits by date
713
- *
714
- * @param provider - The commit provider for fetching commits
715
- * @param commits - Array of commit SHAs to sort
716
- * @param useAuthorDate - If true, use author date; otherwise use committer date
717
- * @returns Sorted array of commit SHAs (newest first)
718
- */
719
- export async function sortByDate(provider, commits, useAuthorDate) {
720
- const commitData = [];
721
- for (const sha of commits) {
722
- const commit = await provider.getCommit(sha);
723
- if (commit) {
724
- const timestamp = useAuthorDate
725
- ? commit.author.timestamp
726
- : commit.committer.timestamp;
727
- commitData.push({ sha, timestamp });
728
- }
729
- }
730
- // Sort by timestamp (newest first)
731
- commitData.sort((a, b) => b.timestamp - a.timestamp);
732
- return commitData.map(c => c.sha);
733
- }
734
- // ============================================================================
735
- // Utility Functions
736
- // ============================================================================
737
- /**
738
- * Get all commits between two commits (exclusive of start, inclusive of end)
739
- *
740
- * @param provider - The commit provider for fetching commits
741
- * @param start - Starting commit SHA (exclusive)
742
- * @param end - Ending commit SHA (inclusive)
743
- * @returns Array of commit SHAs
744
- */
745
- export async function getCommitsBetween(provider, start, end) {
746
- // If start equals end, return empty
747
- if (start === end) {
748
- return [];
749
- }
750
- // Check if end is an ancestor of start (wrong direction)
751
- if (await isAncestor(provider, end, start)) {
752
- // end is ancestor of start, so there are no commits "between" them in this direction
753
- // Actually we need to check if start is NOT an ancestor of end
754
- if (!(await isAncestor(provider, start, end))) {
755
- return [];
756
- }
757
- }
758
- // Walk from end back to start, collecting commits
759
- const result = [];
760
- const visited = new Set();
761
- const queue = [end];
762
- // First check if start is reachable from end
763
- const startReachable = await isAncestor(provider, start, end);
764
- if (!startReachable) {
765
- return [];
766
- }
767
- while (queue.length > 0) {
768
- const sha = queue.shift();
769
- if (visited.has(sha))
770
- continue;
771
- visited.add(sha);
772
- // Stop at start (exclusive)
773
- if (sha === start) {
774
- continue;
775
- }
776
- result.push(sha);
777
- const commit = await provider.getCommit(sha);
778
- if (commit) {
779
- for (const parent of commit.parents) {
780
- if (!visited.has(parent)) {
781
- queue.push(parent);
782
- }
783
- }
784
- }
785
- }
786
- return result;
787
- }
788
- /**
789
- * Count the number of commits reachable from a commit
790
- *
791
- * @param provider - The commit provider for fetching commits
792
- * @param sha - Starting commit SHA
793
- * @param maxDepth - Maximum depth to count
794
- * @returns Number of reachable commits
795
- */
796
- export async function countCommits(provider, sha, maxDepth) {
797
- const visited = new Set();
798
- const queue = [{ sha, depth: 0 }];
799
- let count = 0;
800
- while (queue.length > 0) {
801
- const { sha: currentSha, depth } = queue.shift();
802
- if (visited.has(currentSha))
803
- continue;
804
- const commit = await provider.getCommit(currentSha);
805
- if (!commit)
806
- continue;
807
- visited.add(currentSha);
808
- count++;
809
- // Check depth limit
810
- if (maxDepth !== undefined && depth >= maxDepth) {
811
- continue;
812
- }
813
- for (const parent of commit.parents) {
814
- if (!visited.has(parent)) {
815
- queue.push({ sha: parent, depth: depth + 1 });
816
- }
817
- }
818
- }
819
- return count;
820
- }
821
- //# sourceMappingURL=commit-traversal.js.map