gitx.do 0.1.0 → 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 (344) 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 +15 -415
  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 -174
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -131
  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/commit.d.ts +0 -182
  32. package/dist/cli/commands/commit.d.ts.map +0 -1
  33. package/dist/cli/commands/commit.js +0 -437
  34. package/dist/cli/commands/commit.js.map +0 -1
  35. package/dist/cli/commands/diff.d.ts +0 -464
  36. package/dist/cli/commands/diff.d.ts.map +0 -1
  37. package/dist/cli/commands/diff.js +0 -958
  38. package/dist/cli/commands/diff.js.map +0 -1
  39. package/dist/cli/commands/log.d.ts +0 -239
  40. package/dist/cli/commands/log.d.ts.map +0 -1
  41. package/dist/cli/commands/log.js +0 -535
  42. package/dist/cli/commands/log.js.map +0 -1
  43. package/dist/cli/commands/merge.d.ts +0 -106
  44. package/dist/cli/commands/merge.d.ts.map +0 -1
  45. package/dist/cli/commands/merge.js +0 -55
  46. package/dist/cli/commands/merge.js.map +0 -1
  47. package/dist/cli/commands/review.d.ts +0 -457
  48. package/dist/cli/commands/review.d.ts.map +0 -1
  49. package/dist/cli/commands/review.js +0 -533
  50. package/dist/cli/commands/review.js.map +0 -1
  51. package/dist/cli/commands/status.d.ts +0 -269
  52. package/dist/cli/commands/status.d.ts.map +0 -1
  53. package/dist/cli/commands/status.js +0 -493
  54. package/dist/cli/commands/status.js.map +0 -1
  55. package/dist/cli/commands/web.d.ts +0 -199
  56. package/dist/cli/commands/web.d.ts.map +0 -1
  57. package/dist/cli/commands/web.js +0 -696
  58. package/dist/cli/commands/web.js.map +0 -1
  59. package/dist/cli/fs-adapter.d.ts +0 -656
  60. package/dist/cli/fs-adapter.d.ts.map +0 -1
  61. package/dist/cli/fs-adapter.js +0 -1179
  62. package/dist/cli/fs-adapter.js.map +0 -1
  63. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  64. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  65. package/dist/cli/fsx-cli-adapter.js +0 -619
  66. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  67. package/dist/cli/index.d.ts +0 -387
  68. package/dist/cli/index.d.ts.map +0 -1
  69. package/dist/cli/index.js +0 -523
  70. package/dist/cli/index.js.map +0 -1
  71. package/dist/cli/ui/components/DiffView.d.ts +0 -7
  72. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  73. package/dist/cli/ui/components/DiffView.js +0 -11
  74. package/dist/cli/ui/components/DiffView.js.map +0 -1
  75. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -6
  76. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  77. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  78. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  79. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -9
  80. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  81. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  82. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  83. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -6
  84. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  85. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  86. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  87. package/dist/cli/ui/components/NavigationList.d.ts +0 -9
  88. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  89. package/dist/cli/ui/components/NavigationList.js +0 -11
  90. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  91. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -8
  92. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  93. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  94. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  95. package/dist/cli/ui/components/index.d.ts +0 -7
  96. package/dist/cli/ui/components/index.d.ts.map +0 -1
  97. package/dist/cli/ui/components/index.js +0 -9
  98. package/dist/cli/ui/components/index.js.map +0 -1
  99. package/dist/cli/ui/terminal-ui.d.ts +0 -52
  100. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  101. package/dist/cli/ui/terminal-ui.js +0 -121
  102. package/dist/cli/ui/terminal-ui.js.map +0 -1
  103. package/dist/do/BashModule.d.ts +0 -871
  104. package/dist/do/BashModule.d.ts.map +0 -1
  105. package/dist/do/BashModule.js +0 -1143
  106. package/dist/do/BashModule.js.map +0 -1
  107. package/dist/do/FsModule.d.ts +0 -601
  108. package/dist/do/FsModule.d.ts.map +0 -1
  109. package/dist/do/FsModule.js +0 -1120
  110. package/dist/do/FsModule.js.map +0 -1
  111. package/dist/do/GitModule.d.ts +0 -635
  112. package/dist/do/GitModule.d.ts.map +0 -1
  113. package/dist/do/GitModule.js +0 -781
  114. package/dist/do/GitModule.js.map +0 -1
  115. package/dist/do/GitRepoDO.d.ts +0 -281
  116. package/dist/do/GitRepoDO.d.ts.map +0 -1
  117. package/dist/do/GitRepoDO.js +0 -479
  118. package/dist/do/GitRepoDO.js.map +0 -1
  119. package/dist/do/bash-ast.d.ts +0 -246
  120. package/dist/do/bash-ast.d.ts.map +0 -1
  121. package/dist/do/bash-ast.js +0 -888
  122. package/dist/do/bash-ast.js.map +0 -1
  123. package/dist/do/container-executor.d.ts +0 -491
  124. package/dist/do/container-executor.d.ts.map +0 -1
  125. package/dist/do/container-executor.js +0 -730
  126. package/dist/do/container-executor.js.map +0 -1
  127. package/dist/do/index.d.ts +0 -53
  128. package/dist/do/index.d.ts.map +0 -1
  129. package/dist/do/index.js +0 -91
  130. package/dist/do/index.js.map +0 -1
  131. package/dist/do/tiered-storage.d.ts +0 -403
  132. package/dist/do/tiered-storage.d.ts.map +0 -1
  133. package/dist/do/tiered-storage.js +0 -689
  134. package/dist/do/tiered-storage.js.map +0 -1
  135. package/dist/do/withBash.d.ts +0 -231
  136. package/dist/do/withBash.d.ts.map +0 -1
  137. package/dist/do/withBash.js +0 -244
  138. package/dist/do/withBash.js.map +0 -1
  139. package/dist/do/withFs.d.ts +0 -237
  140. package/dist/do/withFs.d.ts.map +0 -1
  141. package/dist/do/withFs.js +0 -387
  142. package/dist/do/withFs.js.map +0 -1
  143. package/dist/do/withGit.d.ts +0 -180
  144. package/dist/do/withGit.d.ts.map +0 -1
  145. package/dist/do/withGit.js +0 -271
  146. package/dist/do/withGit.js.map +0 -1
  147. package/dist/durable-object/object-store.d.ts +0 -633
  148. package/dist/durable-object/object-store.d.ts.map +0 -1
  149. package/dist/durable-object/object-store.js +0 -1161
  150. package/dist/durable-object/object-store.js.map +0 -1
  151. package/dist/durable-object/schema.d.ts.map +0 -1
  152. package/dist/durable-object/schema.js.map +0 -1
  153. package/dist/durable-object/wal.d.ts +0 -416
  154. package/dist/durable-object/wal.d.ts.map +0 -1
  155. package/dist/durable-object/wal.js +0 -445
  156. package/dist/durable-object/wal.js.map +0 -1
  157. package/dist/mcp/adapter.d.ts +0 -772
  158. package/dist/mcp/adapter.d.ts.map +0 -1
  159. package/dist/mcp/adapter.js +0 -895
  160. package/dist/mcp/adapter.js.map +0 -1
  161. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  162. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  163. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  164. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  165. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  166. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  167. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  168. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  169. package/dist/mcp/sandbox/template.d.ts +0 -17
  170. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/template.js +0 -71
  172. package/dist/mcp/sandbox/template.js.map +0 -1
  173. package/dist/mcp/sandbox.d.ts +0 -764
  174. package/dist/mcp/sandbox.d.ts.map +0 -1
  175. package/dist/mcp/sandbox.js +0 -1362
  176. package/dist/mcp/sandbox.js.map +0 -1
  177. package/dist/mcp/sdk-adapter.d.ts +0 -835
  178. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  179. package/dist/mcp/sdk-adapter.js +0 -974
  180. package/dist/mcp/sdk-adapter.js.map +0 -1
  181. package/dist/mcp/tools/do.d.ts +0 -32
  182. package/dist/mcp/tools/do.d.ts.map +0 -1
  183. package/dist/mcp/tools/do.js +0 -115
  184. package/dist/mcp/tools/do.js.map +0 -1
  185. package/dist/mcp/tools.d.ts +0 -548
  186. package/dist/mcp/tools.d.ts.map +0 -1
  187. package/dist/mcp/tools.js +0 -1934
  188. package/dist/mcp/tools.js.map +0 -1
  189. package/dist/ops/blame.d.ts +0 -551
  190. package/dist/ops/blame.d.ts.map +0 -1
  191. package/dist/ops/blame.js +0 -1037
  192. package/dist/ops/blame.js.map +0 -1
  193. package/dist/ops/branch.d.ts +0 -766
  194. package/dist/ops/branch.d.ts.map +0 -1
  195. package/dist/ops/branch.js +0 -950
  196. package/dist/ops/branch.js.map +0 -1
  197. package/dist/ops/commit-traversal.d.ts +0 -349
  198. package/dist/ops/commit-traversal.d.ts.map +0 -1
  199. package/dist/ops/commit-traversal.js +0 -821
  200. package/dist/ops/commit-traversal.js.map +0 -1
  201. package/dist/ops/commit.d.ts +0 -555
  202. package/dist/ops/commit.d.ts.map +0 -1
  203. package/dist/ops/commit.js +0 -826
  204. package/dist/ops/commit.js.map +0 -1
  205. package/dist/ops/merge-base.d.ts +0 -397
  206. package/dist/ops/merge-base.d.ts.map +0 -1
  207. package/dist/ops/merge-base.js +0 -691
  208. package/dist/ops/merge-base.js.map +0 -1
  209. package/dist/ops/merge.d.ts +0 -855
  210. package/dist/ops/merge.d.ts.map +0 -1
  211. package/dist/ops/merge.js +0 -1551
  212. package/dist/ops/merge.js.map +0 -1
  213. package/dist/ops/tag.d.ts +0 -247
  214. package/dist/ops/tag.d.ts.map +0 -1
  215. package/dist/ops/tag.js +0 -649
  216. package/dist/ops/tag.js.map +0 -1
  217. package/dist/ops/tree-builder.d.ts +0 -178
  218. package/dist/ops/tree-builder.d.ts.map +0 -1
  219. package/dist/ops/tree-builder.js +0 -271
  220. package/dist/ops/tree-builder.js.map +0 -1
  221. package/dist/ops/tree-diff.d.ts +0 -291
  222. package/dist/ops/tree-diff.d.ts.map +0 -1
  223. package/dist/ops/tree-diff.js +0 -705
  224. package/dist/ops/tree-diff.js.map +0 -1
  225. package/dist/pack/delta.d.ts +0 -248
  226. package/dist/pack/delta.d.ts.map +0 -1
  227. package/dist/pack/delta.js +0 -736
  228. package/dist/pack/delta.js.map +0 -1
  229. package/dist/pack/format.d.ts +0 -446
  230. package/dist/pack/format.d.ts.map +0 -1
  231. package/dist/pack/format.js +0 -572
  232. package/dist/pack/format.js.map +0 -1
  233. package/dist/pack/full-generation.d.ts +0 -612
  234. package/dist/pack/full-generation.d.ts.map +0 -1
  235. package/dist/pack/full-generation.js +0 -1378
  236. package/dist/pack/full-generation.js.map +0 -1
  237. package/dist/pack/generation.d.ts +0 -441
  238. package/dist/pack/generation.d.ts.map +0 -1
  239. package/dist/pack/generation.js +0 -707
  240. package/dist/pack/generation.js.map +0 -1
  241. package/dist/pack/index.d.ts +0 -502
  242. package/dist/pack/index.d.ts.map +0 -1
  243. package/dist/pack/index.js +0 -833
  244. package/dist/pack/index.js.map +0 -1
  245. package/dist/refs/branch.d.ts +0 -668
  246. package/dist/refs/branch.d.ts.map +0 -1
  247. package/dist/refs/branch.js +0 -897
  248. package/dist/refs/branch.js.map +0 -1
  249. package/dist/refs/storage.d.ts +0 -833
  250. package/dist/refs/storage.d.ts.map +0 -1
  251. package/dist/refs/storage.js +0 -1023
  252. package/dist/refs/storage.js.map +0 -1
  253. package/dist/refs/tag.d.ts +0 -860
  254. package/dist/refs/tag.d.ts.map +0 -1
  255. package/dist/refs/tag.js +0 -996
  256. package/dist/refs/tag.js.map +0 -1
  257. package/dist/storage/backend.d.ts +0 -425
  258. package/dist/storage/backend.d.ts.map +0 -1
  259. package/dist/storage/backend.js +0 -41
  260. package/dist/storage/backend.js.map +0 -1
  261. package/dist/storage/fsx-adapter.d.ts +0 -204
  262. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  263. package/dist/storage/fsx-adapter.js +0 -470
  264. package/dist/storage/fsx-adapter.js.map +0 -1
  265. package/dist/storage/lru-cache.d.ts +0 -691
  266. package/dist/storage/lru-cache.d.ts.map +0 -1
  267. package/dist/storage/lru-cache.js +0 -813
  268. package/dist/storage/lru-cache.js.map +0 -1
  269. package/dist/storage/object-index.d.ts +0 -585
  270. package/dist/storage/object-index.d.ts.map +0 -1
  271. package/dist/storage/object-index.js +0 -532
  272. package/dist/storage/object-index.js.map +0 -1
  273. package/dist/storage/r2-pack.d.ts +0 -1257
  274. package/dist/storage/r2-pack.d.ts.map +0 -1
  275. package/dist/storage/r2-pack.js +0 -1770
  276. package/dist/storage/r2-pack.js.map +0 -1
  277. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  278. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  279. package/dist/tiered/cdc-pipeline.js +0 -1880
  280. package/dist/tiered/cdc-pipeline.js.map +0 -1
  281. package/dist/tiered/migration.d.ts +0 -1104
  282. package/dist/tiered/migration.d.ts.map +0 -1
  283. package/dist/tiered/migration.js +0 -1214
  284. package/dist/tiered/migration.js.map +0 -1
  285. package/dist/tiered/parquet-writer.d.ts +0 -1145
  286. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  287. package/dist/tiered/parquet-writer.js +0 -1183
  288. package/dist/tiered/parquet-writer.js.map +0 -1
  289. package/dist/tiered/read-path.d.ts +0 -835
  290. package/dist/tiered/read-path.d.ts.map +0 -1
  291. package/dist/tiered/read-path.js +0 -487
  292. package/dist/tiered/read-path.js.map +0 -1
  293. package/dist/types/capability.d.ts +0 -1385
  294. package/dist/types/capability.d.ts.map +0 -1
  295. package/dist/types/capability.js +0 -36
  296. package/dist/types/capability.js.map +0 -1
  297. package/dist/types/index.d.ts +0 -13
  298. package/dist/types/index.d.ts.map +0 -1
  299. package/dist/types/index.js +0 -18
  300. package/dist/types/index.js.map +0 -1
  301. package/dist/types/objects.d.ts +0 -692
  302. package/dist/types/objects.d.ts.map +0 -1
  303. package/dist/types/objects.js +0 -837
  304. package/dist/types/objects.js.map +0 -1
  305. package/dist/types/storage.d.ts +0 -603
  306. package/dist/types/storage.d.ts.map +0 -1
  307. package/dist/types/storage.js +0 -191
  308. package/dist/types/storage.js.map +0 -1
  309. package/dist/types/worker-loader.d.ts +0 -60
  310. package/dist/types/worker-loader.d.ts.map +0 -1
  311. package/dist/types/worker-loader.js +0 -62
  312. package/dist/types/worker-loader.js.map +0 -1
  313. package/dist/utils/hash.d.ts +0 -197
  314. package/dist/utils/hash.d.ts.map +0 -1
  315. package/dist/utils/hash.js +0 -268
  316. package/dist/utils/hash.js.map +0 -1
  317. package/dist/utils/sha1.d.ts +0 -290
  318. package/dist/utils/sha1.d.ts.map +0 -1
  319. package/dist/utils/sha1.js +0 -582
  320. package/dist/utils/sha1.js.map +0 -1
  321. package/dist/wire/capabilities.d.ts +0 -1044
  322. package/dist/wire/capabilities.d.ts.map +0 -1
  323. package/dist/wire/capabilities.js +0 -941
  324. package/dist/wire/capabilities.js.map +0 -1
  325. package/dist/wire/path-security.d.ts +0 -157
  326. package/dist/wire/path-security.d.ts.map +0 -1
  327. package/dist/wire/path-security.js +0 -307
  328. package/dist/wire/path-security.js.map +0 -1
  329. package/dist/wire/pkt-line.d.ts +0 -345
  330. package/dist/wire/pkt-line.d.ts.map +0 -1
  331. package/dist/wire/pkt-line.js +0 -381
  332. package/dist/wire/pkt-line.js.map +0 -1
  333. package/dist/wire/receive-pack.d.ts +0 -1059
  334. package/dist/wire/receive-pack.d.ts.map +0 -1
  335. package/dist/wire/receive-pack.js +0 -1414
  336. package/dist/wire/receive-pack.js.map +0 -1
  337. package/dist/wire/smart-http.d.ts +0 -799
  338. package/dist/wire/smart-http.d.ts.map +0 -1
  339. package/dist/wire/smart-http.js +0 -945
  340. package/dist/wire/smart-http.js.map +0 -1
  341. package/dist/wire/upload-pack.d.ts +0 -727
  342. package/dist/wire/upload-pack.d.ts.map +0 -1
  343. package/dist/wire/upload-pack.js +0 -1138
  344. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,1059 +0,0 @@
1
- /**
2
- * @fileoverview Git receive-pack Protocol Implementation
3
- *
4
- * This module implements the server-side of Git's receive-pack service, which
5
- * handles `git-push` operations. It receives ref updates and packfile data
6
- * from clients and applies them to the repository.
7
- *
8
- * @module wire/receive-pack
9
- *
10
- * ## Protocol Flow
11
- *
12
- * 1. **Ref Advertisement**: Server advertises current refs and capabilities
13
- * 2. **Command Reception**: Client sends ref update commands (old-sha new-sha refname)
14
- * 3. **Packfile Reception**: Client sends packfile with new objects (if needed)
15
- * 4. **Validation**: Server validates packfile and ref updates
16
- * 5. **Application**: Server applies updates and sends status report
17
- *
18
- * ## Security Considerations
19
- *
20
- * - Validates all SHA-1 hashes before processing
21
- * - Checks fast-forward constraints for updates
22
- * - Supports atomic pushes for consistency
23
- * - Validates ref names according to Git rules
24
- * - Supports pre-receive, update, and post-receive hooks
25
- *
26
- * @see {@link https://git-scm.com/docs/pack-protocol} Git Pack Protocol
27
- * @see {@link https://git-scm.com/docs/git-receive-pack} git-receive-pack Documentation
28
- *
29
- * @example Basic push handling
30
- * ```typescript
31
- * import {
32
- * createReceiveSession,
33
- * advertiseReceiveRefs,
34
- * handleReceivePack
35
- * } from './wire/receive-pack'
36
- *
37
- * // Create session and advertise refs
38
- * const session = createReceiveSession('my-repo')
39
- * const advertisement = await advertiseReceiveRefs(store, { atomic: true })
40
- *
41
- * // Handle push request
42
- * const response = await handleReceivePack(session, requestBody, store)
43
- * ```
44
- */
45
- import type { ObjectType } from '../types/objects';
46
- /**
47
- * Zero SHA - used for ref creation and deletion.
48
- *
49
- * @description
50
- * This 40-character string of zeros is used as a placeholder:
51
- * - In `oldSha`: indicates a ref is being created (doesn't exist yet)
52
- * - In `newSha`: indicates a ref is being deleted
53
- *
54
- * @example
55
- * ```typescript
56
- * // Check if this is a create operation
57
- * const isCreate = cmd.oldSha === ZERO_SHA
58
- *
59
- * // Check if this is a delete operation
60
- * const isDelete = cmd.newSha === ZERO_SHA
61
- * ```
62
- */
63
- export declare const ZERO_SHA: string;
64
- /**
65
- * A reference (branch, tag, etc.) with its SHA and optional peeled value.
66
- *
67
- * @description
68
- * Represents a Git reference that can be advertised to clients.
69
- * For annotated tags, the `peeled` field contains the SHA of the
70
- * underlying commit/object.
71
- *
72
- * @example
73
- * ```typescript
74
- * const branch: Ref = {
75
- * name: 'refs/heads/main',
76
- * sha: 'abc123def456...'
77
- * }
78
- *
79
- * const tag: Ref = {
80
- * name: 'refs/tags/v1.0.0',
81
- * sha: 'tag-object-sha...',
82
- * peeled: 'target-commit-sha...'
83
- * }
84
- * ```
85
- */
86
- export interface Ref {
87
- /** Full ref name (e.g., 'refs/heads/main') */
88
- name: string;
89
- /** SHA-1 hash of the object this ref points to */
90
- sha: string;
91
- /** For annotated tags, the SHA of the target object */
92
- peeled?: string;
93
- }
94
- /**
95
- * Capabilities supported by receive-pack.
96
- *
97
- * @description
98
- * These capabilities are advertised during ref advertisement and
99
- * negotiated with the client. They control what features are
100
- * available during the push operation.
101
- *
102
- * @example
103
- * ```typescript
104
- * const caps: ReceivePackCapabilities = {
105
- * reportStatus: true,
106
- * deleteRefs: true,
107
- * atomic: true,
108
- * agent: 'my-server/1.0'
109
- * }
110
- * ```
111
- */
112
- export interface ReceivePackCapabilities {
113
- /** Client wants status report after push */
114
- reportStatus?: boolean;
115
- /** Client wants v2 status report (extended format) */
116
- reportStatusV2?: boolean;
117
- /** Allow ref deletion via push */
118
- deleteRefs?: boolean;
119
- /** Suppress progress messages */
120
- quiet?: boolean;
121
- /** Atomic push - all refs update or none */
122
- atomic?: boolean;
123
- /** Support push options (custom metadata) */
124
- pushOptions?: boolean;
125
- /** Side-band multiplexing for output */
126
- sideBand64k?: boolean;
127
- /** Push certificate nonce for signed pushes */
128
- pushCert?: string;
129
- /** Server agent identification string */
130
- agent?: string;
131
- }
132
- /**
133
- * Ref update command from client.
134
- *
135
- * @description
136
- * Each command describes a single ref update operation:
137
- * - **create**: oldSha is ZERO_SHA, newSha is the new value
138
- * - **update**: oldSha is current value, newSha is new value
139
- * - **delete**: oldSha is current value, newSha is ZERO_SHA
140
- *
141
- * The type is derived from the SHA values.
142
- *
143
- * @example
144
- * ```typescript
145
- * // Create a new branch
146
- * const createCmd: RefUpdateCommand = {
147
- * oldSha: ZERO_SHA,
148
- * newSha: 'abc123...',
149
- * refName: 'refs/heads/feature',
150
- * type: 'create'
151
- * }
152
- *
153
- * // Update existing branch
154
- * const updateCmd: RefUpdateCommand = {
155
- * oldSha: 'abc123...',
156
- * newSha: 'def456...',
157
- * refName: 'refs/heads/main',
158
- * type: 'update'
159
- * }
160
- * ```
161
- */
162
- export interface RefUpdateCommand {
163
- /** Old SHA (ZERO_SHA for create operations) */
164
- oldSha: string;
165
- /** New SHA (ZERO_SHA for delete operations) */
166
- newSha: string;
167
- /** Full ref name (e.g., 'refs/heads/main') */
168
- refName: string;
169
- /** Command type: create, update, or delete */
170
- type: 'create' | 'update' | 'delete';
171
- /** Capabilities from first command line (if any) */
172
- capabilities?: string[];
173
- }
174
- /**
175
- * Result of a ref update operation.
176
- *
177
- * @description
178
- * Contains the outcome of a single ref update, including
179
- * success/failure status and any error message.
180
- *
181
- * @example
182
- * ```typescript
183
- * const result: RefUpdateResult = {
184
- * refName: 'refs/heads/main',
185
- * success: true,
186
- * oldTarget: 'abc123...',
187
- * newTarget: 'def456...'
188
- * }
189
- * ```
190
- */
191
- export interface RefUpdateResult {
192
- /** The ref that was updated */
193
- refName: string;
194
- /** Whether the update succeeded */
195
- success: boolean;
196
- /** Error message if update failed */
197
- error?: string;
198
- /** Previous ref value (for logging/hooks) */
199
- oldTarget?: string;
200
- /** New ref value (for logging/hooks) */
201
- newTarget?: string;
202
- /** Whether this was a force update (non-fast-forward) */
203
- forced?: boolean;
204
- }
205
- /**
206
- * Packfile validation result.
207
- *
208
- * @description
209
- * Contains the result of validating a packfile's structure,
210
- * checksum, and object count.
211
- */
212
- export interface PackfileValidation {
213
- /** Whether the packfile is valid */
214
- valid: boolean;
215
- /** Number of objects in the packfile */
216
- objectCount?: number;
217
- /** Error message if validation failed */
218
- error?: string;
219
- }
220
- /**
221
- * Hook execution point.
222
- *
223
- * @description
224
- * The different points where hooks can be executed during receive-pack:
225
- * - `pre-receive`: Before any refs are updated (can reject entire push)
226
- * - `update`: Before each individual ref update (can reject per-ref)
227
- * - `post-receive`: After all refs are updated (for notifications)
228
- * - `post-update`: After refs are updated (simpler than post-receive)
229
- */
230
- export type HookExecutionPoint = 'pre-receive' | 'update' | 'post-receive' | 'post-update';
231
- /**
232
- * Hook execution result.
233
- *
234
- * @description
235
- * Contains the result of executing a server-side hook. For pre-receive
236
- * and update hooks, failure will reject the push.
237
- */
238
- export interface HookResult {
239
- /** Whether the hook succeeded */
240
- success: boolean;
241
- /** Message from the hook (displayed to client) */
242
- message?: string;
243
- /** Whether the push operation succeeded (post-receive) */
244
- pushSuccess?: boolean;
245
- /** Whether the hook execution succeeded (post-receive) */
246
- hookSuccess?: boolean;
247
- /** Per-ref results from update hook */
248
- results?: RefUpdateResult[];
249
- }
250
- /**
251
- * Session state for receive-pack operation.
252
- *
253
- * @description
254
- * Maintains state across the receive-pack protocol phases.
255
- * This includes capabilities and commands received from the client.
256
- *
257
- * @example
258
- * ```typescript
259
- * const session = createReceiveSession('my-repo')
260
- * // session.capabilities and session.commands are populated
261
- * // as the request is processed
262
- * ```
263
- */
264
- export interface ReceivePackSession {
265
- /** Repository identifier for logging/tracking */
266
- repoId: string;
267
- /** Negotiated capabilities */
268
- capabilities: ReceivePackCapabilities;
269
- /** Ref update commands from client */
270
- commands: RefUpdateCommand[];
271
- }
272
- /**
273
- * Object store interface for receive-pack operations.
274
- *
275
- * @description
276
- * Defines the methods required from an object store to support
277
- * receive-pack operations. Implementations typically wrap a Git
278
- * object database or similar storage.
279
- *
280
- * @example
281
- * ```typescript
282
- * class MyObjectStore implements ObjectStore {
283
- * async getObject(sha: string) {
284
- * return this.database.get(sha)
285
- * }
286
- * async hasObject(sha: string) {
287
- * return this.database.has(sha)
288
- * }
289
- * async setRef(name: string, sha: string) {
290
- * await this.database.updateRef(name, sha)
291
- * }
292
- * // ... other methods
293
- * }
294
- * ```
295
- */
296
- export interface ObjectStore {
297
- /**
298
- * Get an object by its SHA.
299
- * @param sha - The SHA-1 hash of the object
300
- * @returns The object type and data, or null if not found
301
- */
302
- getObject(sha: string): Promise<{
303
- type: ObjectType;
304
- data: Uint8Array;
305
- } | null>;
306
- /**
307
- * Check if an object exists in the store.
308
- * @param sha - The SHA-1 hash to check
309
- * @returns true if the object exists
310
- */
311
- hasObject(sha: string): Promise<boolean>;
312
- /**
313
- * Get the parent commit SHAs for a commit.
314
- * @param sha - The commit SHA
315
- * @returns Array of parent commit SHAs
316
- */
317
- getCommitParents(sha: string): Promise<string[]>;
318
- /**
319
- * Get all refs in the repository.
320
- * @returns Array of Ref objects
321
- */
322
- getRefs(): Promise<Ref[]>;
323
- /**
324
- * Get a specific ref by name.
325
- * @param name - Full ref name (e.g., 'refs/heads/main')
326
- * @returns The ref, or null if not found
327
- */
328
- getRef(name: string): Promise<Ref | null>;
329
- /**
330
- * Set/update a ref to point to a SHA.
331
- * @param name - Full ref name
332
- * @param sha - SHA-1 hash to point to
333
- */
334
- setRef(name: string, sha: string): Promise<void>;
335
- /**
336
- * Delete a ref.
337
- * @param name - Full ref name to delete
338
- */
339
- deleteRef(name: string): Promise<void>;
340
- /**
341
- * Store an object in the database.
342
- * @param sha - The SHA-1 hash of the object
343
- * @param type - Object type (commit, tree, blob, tag)
344
- * @param data - Object data
345
- */
346
- storeObject(sha: string, type: string, data: Uint8Array): Promise<void>;
347
- /**
348
- * Check if one commit is an ancestor of another.
349
- * @param ancestor - Potential ancestor commit SHA
350
- * @param descendant - Potential descendant commit SHA
351
- * @returns true if ancestor is reachable from descendant
352
- */
353
- isAncestor(ancestor: string, descendant: string): Promise<boolean>;
354
- }
355
- /**
356
- * Parsed receive-pack request.
357
- *
358
- * @description
359
- * Contains all data parsed from a receive-pack request, including
360
- * ref update commands, capabilities, packfile data, and push options.
361
- */
362
- export interface ReceivePackRequest {
363
- /** Ref update commands */
364
- commands: RefUpdateCommand[];
365
- /** Capabilities from first command */
366
- capabilities: string[];
367
- /** Packfile binary data */
368
- packfile: Uint8Array;
369
- /** Push options (if push-options capability enabled) */
370
- pushOptions: string[];
371
- }
372
- /**
373
- * Report status input.
374
- *
375
- * @description
376
- * Data needed to generate a status report response to the client.
377
- */
378
- export interface ReportStatusInput {
379
- /** Status of packfile unpacking ('ok' or error message) */
380
- unpackStatus: string;
381
- /** Results for each ref update */
382
- refResults: RefUpdateResult[];
383
- /** Additional options (for report-status-v2) */
384
- options?: Record<string, string>;
385
- }
386
- /**
387
- * Unpack result.
388
- *
389
- * @description
390
- * Result of unpacking objects from a packfile into the object store.
391
- */
392
- export interface UnpackResult {
393
- /** Whether unpacking succeeded */
394
- success: boolean;
395
- /** Number of objects unpacked */
396
- objectsUnpacked: number;
397
- /** SHAs of unpacked objects */
398
- unpackedShas: string[];
399
- /** Error message if unpacking failed */
400
- error?: string;
401
- }
402
- /**
403
- * Process commands result.
404
- *
405
- * @description
406
- * Result of processing ref update commands.
407
- */
408
- export interface ProcessCommandsResult {
409
- /** Results for each ref update */
410
- results: RefUpdateResult[];
411
- }
412
- /**
413
- * Atomic ref update result.
414
- *
415
- * @description
416
- * Result of an atomic push operation where all refs update
417
- * together or none do.
418
- */
419
- export interface AtomicRefUpdateResult {
420
- /** Whether all updates succeeded */
421
- success: boolean;
422
- /** Results for each ref */
423
- results: RefUpdateResult[];
424
- }
425
- /**
426
- * Permission check result.
427
- *
428
- * @description
429
- * Result of checking whether an operation is permitted.
430
- */
431
- export interface PermissionCheckResult {
432
- /** Whether the operation is allowed */
433
- allowed: boolean;
434
- /** Reason for rejection (if not allowed) */
435
- reason?: string;
436
- }
437
- /**
438
- * Permission check options.
439
- *
440
- * @description
441
- * Options for configuring permission checks.
442
- */
443
- export interface PermissionCheckOptions {
444
- /** Refs that cannot be modified */
445
- protectedRefs?: string[];
446
- /** Glob patterns of allowed refs */
447
- allowedRefPatterns?: string[];
448
- }
449
- /**
450
- * Process commands options.
451
- *
452
- * @description
453
- * Options for processing ref update commands.
454
- */
455
- export interface ProcessCommandsOptions {
456
- /** Allow non-fast-forward updates */
457
- forcePush?: boolean;
458
- }
459
- /**
460
- * Packfile validation options.
461
- *
462
- * @description
463
- * Options for validating packfile structure and content.
464
- */
465
- export interface PackfileValidationOptions {
466
- /** Verify SHA-1 checksum */
467
- verifyChecksum?: boolean;
468
- /** Allow empty packfile */
469
- allowEmpty?: boolean;
470
- }
471
- /**
472
- * Unpack options.
473
- *
474
- * @description
475
- * Options for unpacking objects from a packfile.
476
- */
477
- export interface UnpackOptions {
478
- /** Resolve delta objects */
479
- resolveDelta?: boolean;
480
- /** Progress callback */
481
- onProgress?: (message: string) => void;
482
- }
483
- /**
484
- * Hook options.
485
- *
486
- * @description
487
- * Options for hook execution.
488
- */
489
- export interface HookOptions {
490
- /** Timeout in milliseconds */
491
- timeout?: number;
492
- /** Push options to pass to hooks */
493
- pushOptions?: string[];
494
- }
495
- /**
496
- * Build capability string for receive-pack advertisement.
497
- *
498
- * @description
499
- * Converts a capabilities object into a space-separated string suitable
500
- * for inclusion in the ref advertisement. Boolean capabilities become
501
- * simple names, while capabilities with values become "name=value".
502
- *
503
- * @param capabilities - Capabilities to advertise
504
- * @returns Space-separated capability string
505
- *
506
- * @example
507
- * ```typescript
508
- * const caps: ReceivePackCapabilities = {
509
- * reportStatus: true,
510
- * deleteRefs: true,
511
- * atomic: true,
512
- * agent: 'my-server/1.0'
513
- * }
514
- * const str = buildReceiveCapabilityString(caps)
515
- * // 'report-status delete-refs atomic agent=my-server/1.0'
516
- * ```
517
- */
518
- export declare function buildReceiveCapabilityString(capabilities: ReceivePackCapabilities): string;
519
- /**
520
- * Parse capabilities from string.
521
- *
522
- * @description
523
- * Parses a space-separated capability string into a structured
524
- * capabilities object.
525
- *
526
- * @param capsString - Space-separated capabilities
527
- * @returns Parsed capabilities object
528
- *
529
- * @example
530
- * ```typescript
531
- * const caps = parseReceiveCapabilities(
532
- * 'report-status delete-refs atomic agent=git/2.30.0'
533
- * )
534
- * // caps.reportStatus === true
535
- * // caps.deleteRefs === true
536
- * // caps.atomic === true
537
- * // caps.agent === 'git/2.30.0'
538
- * ```
539
- */
540
- export declare function parseReceiveCapabilities(capsString: string): ReceivePackCapabilities;
541
- /**
542
- * Create a new receive-pack session.
543
- *
544
- * @description
545
- * Initializes a new session for a receive-pack operation. The session
546
- * tracks state across the protocol phases.
547
- *
548
- * @param repoId - Repository identifier for logging/tracking
549
- * @returns New session object
550
- *
551
- * @example
552
- * ```typescript
553
- * const session = createReceiveSession('my-repo')
554
- * // session.capabilities === {}
555
- * // session.commands === []
556
- * ```
557
- */
558
- export declare function createReceiveSession(repoId: string): ReceivePackSession;
559
- /**
560
- * Advertise refs to client.
561
- *
562
- * @description
563
- * Generates the ref advertisement response for the initial phase of
564
- * receive-pack. This includes:
565
- * - HEAD reference with capabilities (or zero SHA for empty repos)
566
- * - All refs sorted alphabetically
567
- * - Peeled refs for annotated tags
568
- *
569
- * @param store - Object store to get refs from
570
- * @param capabilities - Optional server capabilities to advertise
571
- * @returns Pkt-line formatted ref advertisement
572
- *
573
- * @example
574
- * ```typescript
575
- * const advertisement = await advertiseReceiveRefs(store, {
576
- * reportStatus: true,
577
- * deleteRefs: true,
578
- * atomic: true
579
- * })
580
- * // Send as response to GET /info/refs?service=git-receive-pack
581
- * ```
582
- */
583
- export declare function advertiseReceiveRefs(store: ObjectStore, capabilities?: ReceivePackCapabilities): Promise<string>;
584
- /**
585
- * Parse a single command line.
586
- *
587
- * @description
588
- * Parses a ref update command line in the format:
589
- * `<old-sha> <new-sha> <refname>[NUL<capabilities>]`
590
- *
591
- * The first command line may include capabilities after a NUL byte.
592
- *
593
- * @param line - Command line to parse
594
- * @returns Parsed command object
595
- *
596
- * @throws {Error} If the line format is invalid or SHAs are malformed
597
- *
598
- * @example
599
- * ```typescript
600
- * // Simple command
601
- * const cmd = parseCommandLine(
602
- * 'abc123... def456... refs/heads/main'
603
- * )
604
- *
605
- * // Command with capabilities (first line)
606
- * const cmdWithCaps = parseCommandLine(
607
- * 'abc123... def456... refs/heads/main\0report-status atomic'
608
- * )
609
- * ```
610
- */
611
- export declare function parseCommandLine(line: string): RefUpdateCommand;
612
- /**
613
- * Parse complete receive-pack request.
614
- *
615
- * @description
616
- * Parses the full receive-pack request body, extracting:
617
- * - Ref update commands
618
- * - Capabilities (from first command)
619
- * - Push options (if enabled)
620
- * - Packfile data
621
- *
622
- * @param data - Raw request body as Uint8Array
623
- * @returns Parsed request object
624
- *
625
- * @throws {Error} If the request format is invalid
626
- *
627
- * @example
628
- * ```typescript
629
- * const request = parseReceivePackRequest(requestBody)
630
- * // request.commands - array of RefUpdateCommand
631
- * // request.capabilities - capabilities from first command
632
- * // request.packfile - packfile binary data
633
- * // request.pushOptions - push options (if enabled)
634
- * ```
635
- */
636
- export declare function parseReceivePackRequest(data: Uint8Array): ReceivePackRequest;
637
- /**
638
- * Validate packfile structure.
639
- *
640
- * @description
641
- * Validates a packfile's structure, including:
642
- * - PACK signature (4 bytes)
643
- * - Version number (must be 2 or 3)
644
- * - Object count
645
- * - Checksum (if verifyChecksum option is true)
646
- *
647
- * @param packfile - Packfile binary data
648
- * @param options - Validation options
649
- * @returns Validation result
650
- *
651
- * @example
652
- * ```typescript
653
- * const result = await validatePackfile(packData, { verifyChecksum: true })
654
- * if (!result.valid) {
655
- * console.error('Invalid packfile:', result.error)
656
- * } else {
657
- * console.log('Objects in pack:', result.objectCount)
658
- * }
659
- * ```
660
- */
661
- export declare function validatePackfile(packfile: Uint8Array, options?: PackfileValidationOptions): Promise<PackfileValidation>;
662
- /**
663
- * Unpack objects from packfile.
664
- *
665
- * @description
666
- * Extracts and stores objects from a packfile into the object store.
667
- * Handles both regular objects and delta-compressed objects.
668
- *
669
- * @param packfile - Packfile binary data
670
- * @param _store - Object store to store unpacked objects
671
- * @param options - Unpack options
672
- * @returns Unpack result
673
- *
674
- * @example
675
- * ```typescript
676
- * const result = await unpackObjects(packfile, store, {
677
- * resolveDelta: true,
678
- * onProgress: (msg) => console.log(msg)
679
- * })
680
- * if (result.success) {
681
- * console.log('Unpacked', result.objectsUnpacked, 'objects')
682
- * }
683
- * ```
684
- */
685
- export declare function unpackObjects(packfile: Uint8Array, _store: ObjectStore, options?: UnpackOptions): Promise<UnpackResult>;
686
- /**
687
- * Validate ref name according to git rules.
688
- *
689
- * @description
690
- * Validates a ref name against Git's naming rules:
691
- * - Must not be empty
692
- * - Must not start or end with `/`
693
- * - Must not contain `//` or `..`
694
- * - Must not contain control characters
695
- * - Must not contain spaces, `~`, `^`, `:`, or `@{`
696
- * - Must not end with `.lock`
697
- * - Components must not start with `.`
698
- *
699
- * Security considerations:
700
- * - Prevents path traversal attacks via `../` sequences
701
- * - Rejects absolute paths
702
- * - Validates ref is within refs/ namespace or is HEAD
703
- * - Blocks URL-encoded traversal attempts
704
- *
705
- * @param refName - Ref name to validate
706
- * @returns true if the ref name is valid
707
- *
708
- * @example
709
- * ```typescript
710
- * validateRefName('refs/heads/main') // true
711
- * validateRefName('refs/heads/feature') // true
712
- * validateRefName('refs/heads/.hidden') // false (starts with .)
713
- * validateRefName('refs/heads/a..b') // false (contains ..)
714
- * validateRefName('refs/heads/a b') // false (contains space)
715
- * validateRefName('refs/../../../etc/passwd') // false (path traversal)
716
- * ```
717
- */
718
- export declare function validateRefName(refName: string): boolean;
719
- /**
720
- * Validate fast-forward update.
721
- *
722
- * @description
723
- * Checks if updating a ref from oldSha to newSha is a fast-forward.
724
- * A fast-forward means oldSha is an ancestor of newSha.
725
- *
726
- * Creation and deletion are always allowed (not fast-forward questions).
727
- *
728
- * @param oldSha - Current ref value (or ZERO_SHA for create)
729
- * @param newSha - New ref value (or ZERO_SHA for delete)
730
- * @param store - Object store to check ancestry
731
- * @returns true if the update is allowed
732
- *
733
- * @example
734
- * ```typescript
735
- * // Fast-forward update
736
- * const ok = await validateFastForward(parent, child, store) // true
737
- *
738
- * // Non-fast-forward update
739
- * const notOk = await validateFastForward(child, parent, store) // false
740
- *
741
- * // Creation always allowed
742
- * const create = await validateFastForward(ZERO_SHA, sha, store) // true
743
- * ```
744
- */
745
- export declare function validateFastForward(oldSha: string, newSha: string, store: ObjectStore): Promise<boolean>;
746
- /**
747
- * Check ref permissions.
748
- *
749
- * @description
750
- * Checks whether a ref operation is allowed based on:
751
- * - Protected refs (cannot be modified)
752
- * - Allowed ref patterns (must match at least one)
753
- * - Force push restrictions on protected branches
754
- *
755
- * @param refName - Ref being modified
756
- * @param operation - Type of operation
757
- * @param options - Permission check options
758
- * @returns Permission check result
759
- *
760
- * @example
761
- * ```typescript
762
- * const result = await checkRefPermissions(
763
- * 'refs/heads/main',
764
- * 'force-update',
765
- * { protectedRefs: ['refs/heads/main'] }
766
- * )
767
- * // result.allowed === false
768
- * // result.reason === 'force push not allowed on protected branch'
769
- * ```
770
- */
771
- export declare function checkRefPermissions(refName: string, operation: 'create' | 'update' | 'delete' | 'force-update', options: PermissionCheckOptions): Promise<PermissionCheckResult>;
772
- /**
773
- * Process ref update commands.
774
- *
775
- * @description
776
- * Validates and processes ref update commands without actually
777
- * applying them. Checks:
778
- * - Ref name validity
779
- * - Current ref state matches expected old SHA
780
- * - Fast-forward constraints (unless force push)
781
- * - Delete-refs capability for deletions
782
- *
783
- * @param session - Current session state
784
- * @param commands - Commands to process
785
- * @param store - Object store
786
- * @param options - Processing options
787
- * @returns Processing result with per-ref status
788
- *
789
- * @example
790
- * ```typescript
791
- * const result = await processCommands(session, commands, store)
792
- * for (const refResult of result.results) {
793
- * if (!refResult.success) {
794
- * console.error(`Failed to update ${refResult.refName}: ${refResult.error}`)
795
- * }
796
- * }
797
- * ```
798
- */
799
- export declare function processCommands(session: ReceivePackSession, commands: RefUpdateCommand[], store: ObjectStore, options?: ProcessCommandsOptions): Promise<ProcessCommandsResult>;
800
- /**
801
- * Update refs in the store.
802
- *
803
- * @description
804
- * Actually applies ref updates to the object store. Should only be
805
- * called after validation via processCommands.
806
- *
807
- * @param commands - Commands to apply
808
- * @param store - Object store
809
- *
810
- * @example
811
- * ```typescript
812
- * // After validation
813
- * await updateRefs(commands, store)
814
- * ```
815
- */
816
- export declare function updateRefs(commands: RefUpdateCommand[], store: ObjectStore): Promise<void>;
817
- /**
818
- * Atomic ref update - all or nothing.
819
- *
820
- * @description
821
- * Applies all ref updates atomically. If any update fails, all
822
- * changes are rolled back to the original state.
823
- *
824
- * @param commands - Commands to apply
825
- * @param store - Object store
826
- * @returns Atomic update result
827
- *
828
- * @example
829
- * ```typescript
830
- * const result = await atomicRefUpdate(commands, store)
831
- * if (result.success) {
832
- * console.log('All refs updated successfully')
833
- * } else {
834
- * console.error('Atomic push failed, all changes rolled back')
835
- * }
836
- * ```
837
- */
838
- export declare function atomicRefUpdate(commands: RefUpdateCommand[], store: ObjectStore): Promise<AtomicRefUpdateResult>;
839
- type PreReceiveHookFn = (commands: RefUpdateCommand[], env: Record<string, string>) => Promise<HookResult>;
840
- type UpdateHookFn = (refName: string, oldSha: string, newSha: string, env: Record<string, string>) => Promise<HookResult>;
841
- type PostReceiveHookFn = (commands: RefUpdateCommand[], results: RefUpdateResult[], env: Record<string, string>) => Promise<HookResult>;
842
- type PostUpdateHookFn = (refNames: string[]) => Promise<HookResult>;
843
- /**
844
- * Execute pre-receive hook.
845
- *
846
- * @description
847
- * Runs the pre-receive hook before any refs are updated.
848
- * The hook receives all commands and can reject the entire push.
849
- *
850
- * @param commands - Commands to be executed
851
- * @param _store - Object store
852
- * @param hookFn - Hook function to execute
853
- * @param env - Environment variables for the hook
854
- * @param options - Hook options
855
- * @returns Hook result
856
- *
857
- * @example
858
- * ```typescript
859
- * const result = await executePreReceiveHook(
860
- * commands,
861
- * store,
862
- * async (cmds, env) => {
863
- * // Validate commands
864
- * return { success: true }
865
- * },
866
- * { GIT_DIR: '/path/to/repo' },
867
- * { timeout: 30000 }
868
- * )
869
- * ```
870
- */
871
- export declare function executePreReceiveHook(commands: RefUpdateCommand[], _store: ObjectStore, hookFn: PreReceiveHookFn, env?: Record<string, string>, options?: HookOptions): Promise<HookResult>;
872
- /**
873
- * Execute update hook for each ref.
874
- *
875
- * @description
876
- * Runs the update hook for each ref being updated.
877
- * Unlike pre-receive, this hook can reject individual refs.
878
- *
879
- * @param commands - Commands being executed
880
- * @param _store - Object store
881
- * @param hookFn - Hook function to execute per-ref
882
- * @param env - Environment variables for the hook
883
- * @returns Results for each ref
884
- *
885
- * @example
886
- * ```typescript
887
- * const { results } = await executeUpdateHook(
888
- * commands,
889
- * store,
890
- * async (refName, oldSha, newSha, env) => {
891
- * // Check if update is allowed for this ref
892
- * return { success: true }
893
- * },
894
- * { GIT_DIR: '/path/to/repo' }
895
- * )
896
- * ```
897
- */
898
- export declare function executeUpdateHook(commands: RefUpdateCommand[], _store: ObjectStore, hookFn: UpdateHookFn, env?: Record<string, string>): Promise<{
899
- results: RefUpdateResult[];
900
- }>;
901
- /**
902
- * Execute post-receive hook.
903
- *
904
- * @description
905
- * Runs the post-receive hook after all refs are updated.
906
- * This hook cannot affect the push result but is useful for
907
- * notifications, CI triggers, etc.
908
- *
909
- * @param commands - Commands that were executed
910
- * @param results - Results of ref updates
911
- * @param _store - Object store
912
- * @param hookFn - Hook function to execute
913
- * @param options - Hook options
914
- * @returns Hook execution result
915
- *
916
- * @example
917
- * ```typescript
918
- * const { hookSuccess } = await executePostReceiveHook(
919
- * commands,
920
- * results,
921
- * store,
922
- * async (cmds, results, env) => {
923
- * // Trigger CI, send notifications, etc.
924
- * return { success: true }
925
- * },
926
- * { pushOptions: ['ci.skip'] }
927
- * )
928
- * ```
929
- */
930
- export declare function executePostReceiveHook(commands: RefUpdateCommand[], results: RefUpdateResult[], _store: ObjectStore, hookFn: PostReceiveHookFn, options?: HookOptions): Promise<{
931
- pushSuccess: boolean;
932
- hookSuccess: boolean;
933
- }>;
934
- /**
935
- * Execute post-update hook.
936
- *
937
- * @description
938
- * Runs the post-update hook with the names of successfully updated refs.
939
- * Simpler than post-receive, takes only ref names as arguments.
940
- *
941
- * @param _commands - Commands that were executed
942
- * @param results - Results of ref updates
943
- * @param hookFn - Hook function to execute
944
- *
945
- * @example
946
- * ```typescript
947
- * await executePostUpdateHook(
948
- * commands,
949
- * results,
950
- * async (refNames) => {
951
- * console.log('Updated refs:', refNames)
952
- * return { success: true }
953
- * }
954
- * )
955
- * ```
956
- */
957
- export declare function executePostUpdateHook(_commands: RefUpdateCommand[], results: RefUpdateResult[], hookFn: PostUpdateHookFn): Promise<void>;
958
- /**
959
- * Format report-status response.
960
- *
961
- * @description
962
- * Creates a pkt-line formatted status report response to send
963
- * to the client after processing the push. The format is:
964
- * 1. Unpack status: "unpack ok" or "unpack <error>"
965
- * 2. Ref status lines: "ok <refname>" or "ng <refname> <error>"
966
- * 3. Flush packet
967
- *
968
- * @param input - Status report data
969
- * @returns Pkt-line formatted status report
970
- *
971
- * @example
972
- * ```typescript
973
- * const report = formatReportStatus({
974
- * unpackStatus: 'ok',
975
- * refResults: [
976
- * { refName: 'refs/heads/main', success: true },
977
- * { refName: 'refs/heads/feature', success: false, error: 'non-fast-forward' }
978
- * ]
979
- * })
980
- * // "0010unpack ok\n0019ok refs/heads/main\n002cng refs/heads/feature non-fast-forward\n0000"
981
- * ```
982
- */
983
- export declare function formatReportStatus(input: ReportStatusInput): string;
984
- /**
985
- * Format report-status-v2 response.
986
- *
987
- * @description
988
- * Creates an extended status report for report-status-v2 capability.
989
- * Adds option lines before the unpack status and supports forced
990
- * update indication.
991
- *
992
- * @param input - Status report data
993
- * @returns Pkt-line formatted v2 status report
994
- *
995
- * @example
996
- * ```typescript
997
- * const report = formatReportStatusV2({
998
- * unpackStatus: 'ok',
999
- * refResults: [
1000
- * { refName: 'refs/heads/main', success: true, forced: true }
1001
- * ],
1002
- * options: { 'object-format': 'sha1' }
1003
- * })
1004
- * ```
1005
- */
1006
- export declare function formatReportStatusV2(input: ReportStatusInput): string;
1007
- /**
1008
- * Format rejection message.
1009
- *
1010
- * @description
1011
- * Creates a rejection message in the appropriate format based
1012
- * on the client's capabilities (side-band or report-status).
1013
- *
1014
- * @param refName - Ref that was rejected
1015
- * @param reason - Reason for rejection
1016
- * @param options - Formatting options
1017
- * @returns Formatted rejection message
1018
- *
1019
- * @example
1020
- * ```typescript
1021
- * // Side-band format
1022
- * const msg = rejectPush('refs/heads/main', 'protected branch', { sideBand: true })
1023
- * // Returns Uint8Array with side-band channel 3 message
1024
- *
1025
- * // Report-status format
1026
- * const msg = rejectPush('refs/heads/main', 'protected branch', { reportStatus: true })
1027
- * // Returns "ng refs/heads/main protected branch"
1028
- * ```
1029
- */
1030
- export declare function rejectPush(refName: string, reason: string, options: {
1031
- reportStatus?: boolean;
1032
- sideBand?: boolean;
1033
- }): string | Uint8Array;
1034
- /**
1035
- * Handle complete receive-pack request.
1036
- *
1037
- * @description
1038
- * This is the main entry point that handles the full receive-pack
1039
- * protocol flow:
1040
- * 1. Parse request (commands, capabilities, packfile)
1041
- * 2. Validate and unpack packfile (if present)
1042
- * 3. Process each ref update command
1043
- * 4. Return status report (if requested)
1044
- *
1045
- * @param session - Receive pack session
1046
- * @param request - Raw request data
1047
- * @param store - Object store
1048
- * @returns Response data (status report or empty)
1049
- *
1050
- * @example
1051
- * ```typescript
1052
- * const session = createReceiveSession('my-repo')
1053
- * const response = await handleReceivePack(session, requestBody, store)
1054
- * // response contains status report if report-status was enabled
1055
- * ```
1056
- */
1057
- export declare function handleReceivePack(session: ReceivePackSession, request: Uint8Array, store: ObjectStore): Promise<Uint8Array>;
1058
- export {};
1059
- //# sourceMappingURL=receive-pack.d.ts.map