@ref0/git 0.0.0 → 0.2.0
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.
- package/dist/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +150 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +10 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +174 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +24 -0
- package/dist/core/seam.mjs +41 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +3 -0
- package/dist/extend.mjs +1 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1036 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +17 -0
- package/dist/rest/handler.mjs +106 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +13 -0
- package/dist/storage/fetch.mjs +792 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +120 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +779 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +990 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +295 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +29 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +80 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +554 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +126 -0
- package/package.json +86 -5
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// src/http/paths.ts
|
|
2
|
+
const pushUploadPath = /^(.+)\/push-uploads(?:\/([A-Za-z0-9_-]{16,64})\/(?:parts\/([1-9][0-9]{0,4})|(complete)))?$/;
|
|
3
|
+
const services = ["git-upload-pack", "git-receive-pack"];
|
|
4
|
+
const isGitService = (service) => services.some((one) => one === service);
|
|
5
|
+
/** `basePath` as one leading slash and no trailing one, or `''` for the root. */
|
|
6
|
+
const normalBase = (basePath) => {
|
|
7
|
+
const trimmed = basePath.replace(/^\/+|\/+$/g, "");
|
|
8
|
+
return trimmed === "" ? "" : `/${trimmed}`;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The path Git answers `url` at under `basePath`, or `undefined` for a URL that isn't Git's: its
|
|
12
|
+
* own path, under the base path, as the URL parser left it, with dot segments, `%2e%2e` and `\`
|
|
13
|
+
* resolved. A mount beside an app calls it with the URL Git is handed, so it never decides on a
|
|
14
|
+
* raw path that Git reads as another: a path it doesn't name falls through to the app. A path
|
|
15
|
+
* that starts `//` is none of Git's, since a parser that reads it as a host would name another.
|
|
16
|
+
*/
|
|
17
|
+
const gitPathOf = (url, basePath) => {
|
|
18
|
+
const base = normalBase(basePath);
|
|
19
|
+
if (url.pathname.startsWith("//")) return void 0;
|
|
20
|
+
return base === "" || url.pathname.startsWith(`${base}/`) ? url.pathname : void 0;
|
|
21
|
+
};
|
|
22
|
+
const ends = [
|
|
23
|
+
{
|
|
24
|
+
end: "/info/refs",
|
|
25
|
+
kind: "info-refs"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
end: "/git-upload-pack",
|
|
29
|
+
kind: "git-upload-pack"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
end: "/git-receive-pack",
|
|
33
|
+
kind: "git-receive-pack"
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
/** What `url` asks of Git under `base`, a `normalBase`; `undefined` for a URL Git doesn't own. */
|
|
37
|
+
const gitUrlOf = (url, base) => {
|
|
38
|
+
if (!url.pathname.startsWith(`${base}/`)) return void 0;
|
|
39
|
+
let rest;
|
|
40
|
+
try {
|
|
41
|
+
rest = decodeURIComponent(url.pathname.slice(base.length + 1));
|
|
42
|
+
} catch {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const matched = ends.find(({ end }) => rest.endsWith(end));
|
|
46
|
+
if (matched === void 0) {
|
|
47
|
+
const upload = pushUploadOf(rest);
|
|
48
|
+
if (upload !== void 0) return upload;
|
|
49
|
+
const lfs = rest.lastIndexOf(lfsPart);
|
|
50
|
+
return lfs === -1 ? void 0 : lfsUrlOf(url, rest.slice(0, lfs), rest.slice(lfs + lfsPart.length));
|
|
51
|
+
}
|
|
52
|
+
const { path, dotGit } = repoPathOf(rest.slice(0, -matched.end.length));
|
|
53
|
+
if (path === "") return void 0;
|
|
54
|
+
if (matched.kind === "info-refs") return {
|
|
55
|
+
kind: "info-refs",
|
|
56
|
+
path,
|
|
57
|
+
dotGit,
|
|
58
|
+
service: url.searchParams.get("service") ?? void 0
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
kind: "service",
|
|
62
|
+
path,
|
|
63
|
+
dotGit,
|
|
64
|
+
service: matched.kind
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/** A path less its `.git`, and whether it had one. */
|
|
68
|
+
const repoPathOf = (named) => {
|
|
69
|
+
const dotGit = named.endsWith(".git");
|
|
70
|
+
return {
|
|
71
|
+
path: dotGit ? named.slice(0, -4) : named,
|
|
72
|
+
dotGit
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/** A push upload's URL, or `undefined` when `rest` isn't one. */
|
|
76
|
+
const pushUploadOf = (rest) => {
|
|
77
|
+
const found = pushUploadPath.exec(rest);
|
|
78
|
+
if (found === null) return void 0;
|
|
79
|
+
const [, named = "", upload, part] = found;
|
|
80
|
+
const { path, dotGit } = repoPathOf(named);
|
|
81
|
+
if (path === "") return void 0;
|
|
82
|
+
if (upload === void 0) return {
|
|
83
|
+
kind: "push-upload",
|
|
84
|
+
path,
|
|
85
|
+
dotGit,
|
|
86
|
+
route: { kind: "begin" }
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
kind: "push-upload",
|
|
90
|
+
path,
|
|
91
|
+
dotGit,
|
|
92
|
+
route: part === void 0 ? {
|
|
93
|
+
kind: "complete",
|
|
94
|
+
upload
|
|
95
|
+
} : {
|
|
96
|
+
kind: "part",
|
|
97
|
+
upload,
|
|
98
|
+
part: Number(part)
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const lfsPart = "/info/lfs/";
|
|
103
|
+
/** Git LFS's URL, which git-lfs makes from the remote's as `<remote>/info/lfs`. */
|
|
104
|
+
const lfsUrlOf = (url, named, route) => {
|
|
105
|
+
const { path, dotGit } = repoPathOf(named);
|
|
106
|
+
if (path === "" || route === "") return void 0;
|
|
107
|
+
const raw = url.pathname.slice(0, url.pathname.lastIndexOf(lfsPart));
|
|
108
|
+
return {
|
|
109
|
+
kind: "lfs",
|
|
110
|
+
path,
|
|
111
|
+
dotGit,
|
|
112
|
+
route,
|
|
113
|
+
repoUrl: `${url.origin}${raw}`
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/** `info/refs`'s URL for `path` under `base`, keeping `.git` as the request had it. */
|
|
117
|
+
const infoRefsPath = (base, path, dotGit, service) => `${base}/${path.split("/").map(encodeURIComponent).join("/")}${dotGit ? ".git" : ""}/info/refs?service=${service}`;
|
|
118
|
+
export { gitPathOf, gitUrlOf, infoRefsPath, isGitService, normalBase };
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { openFor } from "../lfs/repo.mjs";
|
|
2
|
+
import { pushOptionsRefusal } from "../protocol/wire/receive-pack.mjs";
|
|
3
|
+
import { BeginPushUploadBody, FinishPushUploadBody } from "../protocol/wire/push-uploads.mjs";
|
|
4
|
+
import { bucketCall, bucketTry } from "../storage/calls.mjs";
|
|
5
|
+
import { PushUploadRow, completeMost, endUpload, partBytes, partLinkLife, partSizeOf, partsOf, pushUploadGrace, pushUploadKey, pushUploadLife, pushUploadMost, pushUploadRead, pushUploadRowKey } from "../storage/push-uploads.mjs";
|
|
6
|
+
import { bestEffort, decodeRow, fail, gitError, storeCall } from "../store/errors.mjs";
|
|
7
|
+
import { randomText } from "../store/random.mjs";
|
|
8
|
+
import { newChangeId, repoScope } from "../store/scopes.mjs";
|
|
9
|
+
import { gitAnswer, resultType } from "./answers.mjs";
|
|
10
|
+
import { brokenBody, plainBody, readWhole } from "./bodies.mjs";
|
|
11
|
+
import { reportOf, routeCounted } from "./receive-pack.mjs";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Result from "effect/Result";
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
import * as Option from "effect/Option";
|
|
16
|
+
// src/http/push-uploads.ts
|
|
17
|
+
/** A begin's or complete's JSON: at most 1 MiB. */
|
|
18
|
+
const bodyMost = 1048576;
|
|
19
|
+
/** A pack's header: `PACK`, its version, and how many objects it holds. */
|
|
20
|
+
const packHeader = 12;
|
|
21
|
+
const zero = "0".repeat(40);
|
|
22
|
+
/** Push uploads over `core`, staged in `bucket`, offered above `above` bytes. */
|
|
23
|
+
const pushUploads = (core, bucket, above) => {
|
|
24
|
+
const uploads = {
|
|
25
|
+
core,
|
|
26
|
+
bucket
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
above,
|
|
30
|
+
serve: (parts, call) => {
|
|
31
|
+
const { route } = call;
|
|
32
|
+
if (route.kind === "begin") return routeCounted(parts, begin(uploads, call));
|
|
33
|
+
if (route.kind === "part") return routeCounted(parts, part(uploads, call, route.upload, route.part));
|
|
34
|
+
return routeCounted(parts, complete(uploads, parts, call, route.upload));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const jsonAnswer = (body) => new Response(JSON.stringify(body), {
|
|
39
|
+
status: 200,
|
|
40
|
+
headers: {
|
|
41
|
+
"content-type": "application/json",
|
|
42
|
+
"cache-control": "no-store"
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
/** `request`'s JSON, decoded as `schema`. */
|
|
46
|
+
const bodyOf = (request, schema) => Effect.gen(function* () {
|
|
47
|
+
const bytes = yield* readWhole(yield* plainBody(request), bodyMost, brokenBody(request));
|
|
48
|
+
const text = new TextDecoder().decode(bytes);
|
|
49
|
+
const decoded = Schema.decodeUnknownOption(Schema.fromJsonString(schema))(text);
|
|
50
|
+
return yield* Option.match(decoded, {
|
|
51
|
+
onNone: () => fail("INVALID_ARGUMENT", "The push upload's body isn't the JSON it takes"),
|
|
52
|
+
onSome: (value) => Effect.succeed(value)
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
/** The caller's actor ID: an upload is its own. */
|
|
56
|
+
const actorOf = (caller) => caller.actor.anonymous === true ? fail("UNAUTHENTICATED", "Sign in to push") : Effect.succeed(caller.actor.id);
|
|
57
|
+
const ended = (upload) => fail("FAILED_PRECONDITION", `The push upload ${upload} has ended, or isn't yours`, { hint: "Push again" });
|
|
58
|
+
/** Why a begin is refused before anything is staged, or `undefined`. */
|
|
59
|
+
const beginRefusal = (body) => {
|
|
60
|
+
if (body.bytes < 1) return gitError("INVALID_ARGUMENT", "A push upload holds a pack");
|
|
61
|
+
if (body.bytes > pushUploadMost) return gitError("RESOURCE_EXHAUSTED", `A push's pack holds at most ${pushUploadMost} bytes`, {
|
|
62
|
+
hint: "Push fewer commits at a time, or track large files with Git LFS",
|
|
63
|
+
context: { reason: "too-large" }
|
|
64
|
+
});
|
|
65
|
+
if (!body.updates.some((update) => update.to !== null)) return gitError("INVALID_ARGUMENT", "A push upload moves a ref to a commit", { hint: "Delete refs with a plain push" });
|
|
66
|
+
if ((body.pushOptions ?? []).some((option) => /[\n\0]/.test(option))) return gitError("INVALID_ARGUMENT", "A push option is one line, with no NUL");
|
|
67
|
+
const options = pushOptionsRefusal(body.pushOptions ?? []);
|
|
68
|
+
return options === void 0 ? void 0 : gitError("INVALID_ARGUMENT", options);
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* `POST <repo>/push-uploads`: a multipart upload at the upload's own key, then its row, with
|
|
72
|
+
* `git.repack` due at its `removeAt` to end it. A crash between leaves an upload no link was
|
|
73
|
+
* given for, which the bucket's lifecycle drops.
|
|
74
|
+
*/
|
|
75
|
+
const begin = Effect.fnUntraced(function* ({ core, bucket }, call) {
|
|
76
|
+
const body = yield* bodyOf(call.request, BeginPushUploadBody);
|
|
77
|
+
const refused = beginRefusal(body);
|
|
78
|
+
if (refused !== void 0) return yield* Effect.fail(refused);
|
|
79
|
+
const repo = yield* openFor(core, call.caller, call.repo, true);
|
|
80
|
+
const actor = yield* actorOf(call.caller);
|
|
81
|
+
const at = yield* core.now;
|
|
82
|
+
const upload = randomText(16);
|
|
83
|
+
const key = pushUploadKey(repo.internalId, upload);
|
|
84
|
+
const uploadId = yield* bucketCall((signal) => bucket.beginUpload(key, { signal }));
|
|
85
|
+
const expiresAt = at + pushUploadLife;
|
|
86
|
+
const removeAt = expiresAt + pushUploadGrace;
|
|
87
|
+
const row = {
|
|
88
|
+
key,
|
|
89
|
+
uploadId,
|
|
90
|
+
actor,
|
|
91
|
+
bytes: body.bytes,
|
|
92
|
+
updates: body.updates,
|
|
93
|
+
pushOptions: body.pushOptions ?? [],
|
|
94
|
+
atomic: body.atomic ?? false,
|
|
95
|
+
expiresAt,
|
|
96
|
+
removeAt,
|
|
97
|
+
state: "open"
|
|
98
|
+
};
|
|
99
|
+
yield* storeCall(() => core.store.add(repoScope(repo.internalId), {
|
|
100
|
+
put: [{
|
|
101
|
+
...pushUploadRowKey(upload),
|
|
102
|
+
value: row
|
|
103
|
+
}],
|
|
104
|
+
jobs: [core.repackJobRow(removeAt)]
|
|
105
|
+
}));
|
|
106
|
+
return jsonAnswer({
|
|
107
|
+
upload,
|
|
108
|
+
partSize: partSizeOf(body.bytes, bucket.maxParts),
|
|
109
|
+
expiresAt
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
/** The upload's row and the version it was read at, when it's `actor`'s. */
|
|
113
|
+
const rowOf = Effect.fnUntraced(function* (core, repo, upload, actor) {
|
|
114
|
+
const snapshot = yield* storeCall(() => core.store.read(repoScope(repo), [pushUploadRead(upload)]));
|
|
115
|
+
const found = snapshot.results[0]?.[0];
|
|
116
|
+
const row = found === void 0 ? void 0 : yield* decodeRow(PushUploadRow, found, `push upload ${upload}`);
|
|
117
|
+
if (row === void 0 || row.actor !== actor) return yield* ended(upload);
|
|
118
|
+
return {
|
|
119
|
+
row,
|
|
120
|
+
version: snapshot.version
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
/** `POST <repo>/push-uploads/{upload}/parts/{part}`: a PUT link for the part, while it's open. */
|
|
124
|
+
const part = Effect.fnUntraced(function* ({ core, bucket }, call, upload, number) {
|
|
125
|
+
const repo = yield* openFor(core, call.caller, call.repo, true);
|
|
126
|
+
const actor = yield* actorOf(call.caller);
|
|
127
|
+
const { row } = yield* rowOf(core, repo.internalId, upload, actor);
|
|
128
|
+
const at = yield* core.now;
|
|
129
|
+
if (row.state !== "open" || at >= row.expiresAt) return yield* ended(upload);
|
|
130
|
+
const size = partSizeOf(row.bytes, bucket.maxParts);
|
|
131
|
+
const count = partsOf(row.bytes, size);
|
|
132
|
+
if (number > count) return yield* fail("INVALID_ARGUMENT", `The upload has ${count} parts`);
|
|
133
|
+
const expiresAt = Math.min(at + partLinkLife, row.expiresAt);
|
|
134
|
+
const bytes = partBytes(row.bytes, number, size);
|
|
135
|
+
const url = yield* bucketCall((signal) => bucket.uploadUrl(row.key, {
|
|
136
|
+
expiresAt,
|
|
137
|
+
uploadId: row.uploadId,
|
|
138
|
+
part: number,
|
|
139
|
+
bytes,
|
|
140
|
+
signal
|
|
141
|
+
}));
|
|
142
|
+
return jsonAnswer({ url });
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* The upload, `completing` from now: committed at the version its row was read, so of two
|
|
146
|
+
* completes only one pushes, and no part link is given after.
|
|
147
|
+
*/
|
|
148
|
+
const claim = Effect.fnUntraced(function* (core, repo, upload, actor, parts, maxParts) {
|
|
149
|
+
for (let tries = 0; tries < 5; tries += 1) {
|
|
150
|
+
const { row, version } = yield* rowOf(core, repo, upload, actor);
|
|
151
|
+
const at = yield* core.now;
|
|
152
|
+
if (row.state !== "open" || at >= row.removeAt - completeMost) return yield* ended(upload);
|
|
153
|
+
const count = partsOf(row.bytes, partSizeOf(row.bytes, maxParts));
|
|
154
|
+
if (!(parts.length === count && parts.every((one, at) => one.part === at + 1))) return yield* fail("INVALID_ARGUMENT", `Name each of its ${count} parts, in order`);
|
|
155
|
+
const claimed = {
|
|
156
|
+
...row,
|
|
157
|
+
state: "completing"
|
|
158
|
+
};
|
|
159
|
+
if ((yield* storeCall(() => core.store.commit(repoScope(repo), {
|
|
160
|
+
id: newChangeId(),
|
|
161
|
+
expect: version,
|
|
162
|
+
put: [{
|
|
163
|
+
...pushUploadRowKey(upload),
|
|
164
|
+
value: claimed
|
|
165
|
+
}]
|
|
166
|
+
}))).ok) return claimed;
|
|
167
|
+
}
|
|
168
|
+
return yield* fail("UNAVAILABLE", "The push upload is busy", { hint: "Push again" });
|
|
169
|
+
});
|
|
170
|
+
/** How many objects the staged pack's header says, or `undefined` when it isn't a pack. */
|
|
171
|
+
const objectsOf = Effect.fnUntraced(function* (bucket, key) {
|
|
172
|
+
const stream = yield* bucketCall((signal) => bucket.read(key, {
|
|
173
|
+
offset: 0,
|
|
174
|
+
length: packHeader
|
|
175
|
+
}, { signal }));
|
|
176
|
+
if (stream === void 0) return void 0;
|
|
177
|
+
const bytes = new Uint8Array(yield* bucketTry(() => new Response(stream).arrayBuffer()));
|
|
178
|
+
if (bytes.length < packHeader) return void 0;
|
|
179
|
+
const header = new DataView(bytes.buffer, bytes.byteOffset, packHeader);
|
|
180
|
+
return header.getUint32(0) === 1346454347 ? header.getUint32(8) : void 0;
|
|
181
|
+
});
|
|
182
|
+
/** The push start complete answers for: what the upload's begin named, on side-band-64k. */
|
|
183
|
+
const startOf = (row) => ({
|
|
184
|
+
shallow: [],
|
|
185
|
+
commands: row.updates.map((update) => ({
|
|
186
|
+
ref: update.ref,
|
|
187
|
+
before: update.from ?? zero,
|
|
188
|
+
after: update.to ?? zero
|
|
189
|
+
})),
|
|
190
|
+
capabilities: [
|
|
191
|
+
"report-status-v2",
|
|
192
|
+
"side-band-64k",
|
|
193
|
+
...row.atomic ? ["atomic"] : []
|
|
194
|
+
],
|
|
195
|
+
pushOptions: row.pushOptions,
|
|
196
|
+
packOffset: 0
|
|
197
|
+
});
|
|
198
|
+
/**
|
|
199
|
+
* `POST <repo>/push-uploads/{upload}/complete`: the upload claimed, its parts joined, and its pack
|
|
200
|
+
* streamed from the bucket into the push, which checks the caller's grant again, as any push. It
|
|
201
|
+
* answers `git-receive-pack`'s report; then the upload ends, its key deleted and its row `ended`,
|
|
202
|
+
* and upkeep at its `removeAt` deletes both.
|
|
203
|
+
*/
|
|
204
|
+
const complete = Effect.fnUntraced(function* ({ core, bucket }, parts, call, upload) {
|
|
205
|
+
const finish = yield* bodyOf(call.request, FinishPushUploadBody);
|
|
206
|
+
const repo = yield* openFor(core, call.caller, call.repo, true);
|
|
207
|
+
const actor = yield* actorOf(call.caller);
|
|
208
|
+
const receiving = yield* parts.receive(call.caller, call.repo);
|
|
209
|
+
const row = yield* claim(core, repo.internalId, upload, actor, finish.parts, bucket.maxParts);
|
|
210
|
+
const pushed = yield* pushStaged(bucket, receiving.push, call.request, row, finish.parts).pipe(Effect.ensuring(ending(core, bucket, repo.internalId, upload, row)));
|
|
211
|
+
return gitAnswer(resultType("git-receive-pack"), yield* reportOf(startOf(row), pushed));
|
|
212
|
+
});
|
|
213
|
+
/** The upload's parts as the bucket lists them, each the length signed and the one named. */
|
|
214
|
+
const checkedParts = (row, size, named, listed) => {
|
|
215
|
+
const count = partsOf(row.bytes, size);
|
|
216
|
+
if (listed.length !== count) return Result.fail(gitError("INVALID_ARGUMENT", `The upload holds ${listed.length} parts, not the ${count} begun`));
|
|
217
|
+
const bare = (etag) => etag.replaceAll("\"", "");
|
|
218
|
+
for (const [at, one] of listed.entries()) {
|
|
219
|
+
const signed = partBytes(row.bytes, at + 1, size);
|
|
220
|
+
const sent = named[at]?.etag ?? "";
|
|
221
|
+
if (one.part !== at + 1 || bare(one.etag) !== bare(sent)) return Result.fail(gitError("INVALID_ARGUMENT", `Part ${at + 1} isn't the one sent`));
|
|
222
|
+
if (one.size !== signed) return Result.fail(gitError("INVALID_ARGUMENT", `Part ${one.part} holds ${one.size} bytes, not the ${signed} its link signed`));
|
|
223
|
+
}
|
|
224
|
+
return Result.succeed(listed.map(({ part, etag }) => ({
|
|
225
|
+
part,
|
|
226
|
+
etag
|
|
227
|
+
})));
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* The parts checked and joined, then the pack they make pushed, or why it can't be. The join names
|
|
231
|
+
* the ETags the bucket listed, so a part sent again after the check makes the bucket refuse it.
|
|
232
|
+
*/
|
|
233
|
+
const pushStaged = Effect.fnUntraced(function* (bucket, push, request, row, named) {
|
|
234
|
+
const listed = yield* Effect.result(bucketCall((signal) => bucket.listParts(row.key, row.uploadId, { signal })));
|
|
235
|
+
const size = partSizeOf(row.bytes, bucket.maxParts);
|
|
236
|
+
const parts = Result.flatMap(listed, (listing) => checkedParts(row, size, named, listing));
|
|
237
|
+
if (Result.isFailure(parts)) return Result.fail(parts.failure);
|
|
238
|
+
const stored = yield* Effect.result(bucketCall((signal) => bucket.completeUpload(row.key, {
|
|
239
|
+
uploadId: row.uploadId,
|
|
240
|
+
parts: parts.success
|
|
241
|
+
}, { signal })));
|
|
242
|
+
if (Result.isFailure(stored)) return Result.fail(stored.failure);
|
|
243
|
+
const objects = yield* objectsOf(bucket, row.key);
|
|
244
|
+
const bytes = objects === void 0 ? void 0 : yield* bucketCall((signal) => bucket.read(row.key, void 0, { signal }));
|
|
245
|
+
if (objects === void 0 || bytes === void 0) return Result.fail(gitError("INVALID_ARGUMENT", "the push's pack is missing or isn't a pack"));
|
|
246
|
+
const input = {
|
|
247
|
+
request,
|
|
248
|
+
edits: row.updates,
|
|
249
|
+
atomic: row.atomic,
|
|
250
|
+
pushOptions: row.pushOptions,
|
|
251
|
+
pack: {
|
|
252
|
+
bytes,
|
|
253
|
+
objects,
|
|
254
|
+
length: row.bytes
|
|
255
|
+
},
|
|
256
|
+
signal: request.signal
|
|
257
|
+
};
|
|
258
|
+
return yield* Effect.result(push(input));
|
|
259
|
+
});
|
|
260
|
+
/**
|
|
261
|
+
* The upload ended: its parts aborted and its key deleted, then its row marked `ended`. Upkeep at
|
|
262
|
+
* its `removeAt` deletes the key again, and the row, so a PUT that lands while a link lives goes too.
|
|
263
|
+
* A row upkeep already deleted, under a complete stalled past `removeAt`, stays deleted. An end
|
|
264
|
+
* refused, as past a spent count, is logged at warning, and upkeep ends it instead.
|
|
265
|
+
*/
|
|
266
|
+
const ending = (core, bucket, repo, upload, row) => Effect.gen(function* () {
|
|
267
|
+
yield* endUpload(bucket, row);
|
|
268
|
+
const snapshot = yield* storeCall(() => core.store.read(repoScope(repo), [pushUploadRead(upload)]));
|
|
269
|
+
if ((snapshot.results[0] ?? []).length === 0) return;
|
|
270
|
+
yield* storeCall(() => core.store.commit(repoScope(repo), {
|
|
271
|
+
id: newChangeId(),
|
|
272
|
+
expect: snapshot.version,
|
|
273
|
+
put: [{
|
|
274
|
+
...pushUploadRowKey(upload),
|
|
275
|
+
value: {
|
|
276
|
+
...row,
|
|
277
|
+
state: "ended"
|
|
278
|
+
}
|
|
279
|
+
}]
|
|
280
|
+
}));
|
|
281
|
+
}).pipe((ended) => bestEffort(ended, (error) => Effect.logWarning("An upload's end was refused: upkeep ends it at its removeAt").pipe(Effect.annotateLogs({
|
|
282
|
+
upload,
|
|
283
|
+
code: error.code,
|
|
284
|
+
reason: error.message
|
|
285
|
+
}))));
|
|
286
|
+
export { pushUploads };
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { RequestCalls, countedAs } from "../store/call-count.mjs";
|
|
2
|
+
import { answerSpent, gitError } from "../store/errors.mjs";
|
|
3
|
+
import { joinedBytes } from "../protocol/bytes/joined.mjs";
|
|
4
|
+
import { onBand } from "../protocol/framing/band.mjs";
|
|
5
|
+
import { maxPktData } from "../protocol/framing/pkt-line.mjs";
|
|
6
|
+
import { encodeAdvertisement, receivePackCapabilities } from "../protocol/wire/advertisement.mjs";
|
|
7
|
+
import { pushOptionsRefusal, readPushStart } from "../protocol/wire/receive-pack.mjs";
|
|
8
|
+
import { encodePushReport } from "../protocol/wire/report-status.mjs";
|
|
9
|
+
import { advertisementType, gitAnswer, resultType } from "./answers.mjs";
|
|
10
|
+
import { brokenBody, drainLimit, plainBody, pushStartLimit, readStart } from "./bodies.mjs";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import * as Result from "effect/Result";
|
|
13
|
+
// src/http/receive-pack.ts
|
|
14
|
+
/**
|
|
15
|
+
* `git-receive-pack` over smart HTTP, as `gitprotocol-http` and `gitprotocol-pack` say, in v0
|
|
16
|
+
* alone, since v2 has no push. A POST's start is read, and its pack streams on into the push. Once
|
|
17
|
+
* the push is the server's to answer, every refusal is a report in a 200, `ng` for each ref with
|
|
18
|
+
* the reason on band 2, so Git prints why; what's left of a refused push's body is read away first.
|
|
19
|
+
*/
|
|
20
|
+
const service = "git-receive-pack";
|
|
21
|
+
const zero = "0".repeat(40);
|
|
22
|
+
/** A pack's header: `PACK`, its version, and how many objects it holds. */
|
|
23
|
+
const packHeader = 12;
|
|
24
|
+
const encoder = new TextEncoder();
|
|
25
|
+
const decoder = new TextDecoder("utf-8", {
|
|
26
|
+
fatal: false,
|
|
27
|
+
ignoreBOM: true
|
|
28
|
+
});
|
|
29
|
+
/** `…`'s length in UTF-8. */
|
|
30
|
+
const ellipsis = 3;
|
|
31
|
+
const unwritable = (error) => gitError("INTERNAL", `Git's answer can't be written: ${error.message}`);
|
|
32
|
+
/**
|
|
33
|
+
* `info/refs?service=git-receive-pack`: the refs a push starts from. Its calls, its tags' peels
|
|
34
|
+
* among them, count into one new count, bound by `parts.pushCalls`, as a push's do (Q799).
|
|
35
|
+
*/
|
|
36
|
+
const receivePackRefs = (parts, caller, repo, missing) => routeCounted(parts, Effect.gen(function* () {
|
|
37
|
+
const receiving = yield* parts.receive(caller, repo);
|
|
38
|
+
const body = yield* encodeAdvertisement(service, receiving.refs, receivePackCapabilities(parts.agent, parts.uploads?.above));
|
|
39
|
+
return gitAnswer(advertisementType(service), body);
|
|
40
|
+
}).pipe(Effect.catchTag("WireEncodeError", (error) => Effect.fail(unwritable(error))), Effect.catch(missing)));
|
|
41
|
+
/**
|
|
42
|
+
* Reads a push's start, and its pack's header when a command needs one: the start ends where
|
|
43
|
+
* the pack's bytes begin, so the pack streams on whole.
|
|
44
|
+
*/
|
|
45
|
+
const arrived = (bytes, ended) => Effect.map(readPushStart(bytes), (read) => {
|
|
46
|
+
if (read.kind === "incomplete") return void 0;
|
|
47
|
+
if (read.kind === "probe") return {
|
|
48
|
+
start: {
|
|
49
|
+
start: "probe",
|
|
50
|
+
objects: void 0
|
|
51
|
+
},
|
|
52
|
+
end: bytes.length
|
|
53
|
+
};
|
|
54
|
+
const { start } = read;
|
|
55
|
+
const deletesOnly = start.commands.every((command) => command.after === zero);
|
|
56
|
+
const end = start.packOffset;
|
|
57
|
+
if (deletesOnly) return {
|
|
58
|
+
start: {
|
|
59
|
+
start,
|
|
60
|
+
objects: void 0
|
|
61
|
+
},
|
|
62
|
+
end
|
|
63
|
+
};
|
|
64
|
+
if (bytes.length < end + packHeader) return ended ? {
|
|
65
|
+
start: {
|
|
66
|
+
start,
|
|
67
|
+
objects: void 0
|
|
68
|
+
},
|
|
69
|
+
end
|
|
70
|
+
} : void 0;
|
|
71
|
+
const header = new DataView(bytes.buffer, bytes.byteOffset + end, packHeader);
|
|
72
|
+
return {
|
|
73
|
+
start: {
|
|
74
|
+
start,
|
|
75
|
+
objects: header.getUint32(0) === 1346454347 ? header.getUint32(8) : void 0
|
|
76
|
+
},
|
|
77
|
+
end
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* The pack a push sends, with its body's Content-Length as the most it can be: the request's
|
|
82
|
+
* length bounds its pack's, which follows the start. A chunked body says none.
|
|
83
|
+
*/
|
|
84
|
+
const packOf = (request, bytes, objects) => {
|
|
85
|
+
const length = Number(request.headers.get("content-length") ?? NaN);
|
|
86
|
+
return Number.isSafeInteger(length) && length >= 0 ? {
|
|
87
|
+
bytes,
|
|
88
|
+
objects,
|
|
89
|
+
atMost: length
|
|
90
|
+
} : {
|
|
91
|
+
bytes,
|
|
92
|
+
objects
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* A POST to `git-receive-pack`: one push, or Git's probe before a big one. Every store and bucket
|
|
97
|
+
* call it makes from its receive on counts into one new count, bound by `parts.pushCalls`: a call
|
|
98
|
+
* past it never starts, and the push is refused with push's hint (Q799).
|
|
99
|
+
*/
|
|
100
|
+
const receivePack = (parts, caller, repo, request) => routeCounted(parts, pushOf(parts, caller, repo, request));
|
|
101
|
+
/**
|
|
102
|
+
* `effect`, a push or LFS route's whole request, with every store and bucket call it makes counted
|
|
103
|
+
* into one new count, bound by `parts.pushCalls`: a call past it never starts (Q799), and the
|
|
104
|
+
* route, an edge, answers the spent bound as its refusal.
|
|
105
|
+
*/
|
|
106
|
+
const routeCounted = (parts, effect) => Effect.suspend(() => answerSpent(countedAs(effect, new RequestCalls(parts.pushCalls))));
|
|
107
|
+
const pushOf = (parts, caller, repo, request) => Effect.gen(function* () {
|
|
108
|
+
const receiving = yield* parts.receive(caller, repo);
|
|
109
|
+
const body = yield* plainBody(request);
|
|
110
|
+
const started = yield* readStart(body, pushStartLimit, arrived, brokenBody(request)).pipe(Effect.catchTag("WireDecodeError", (error) => Effect.fail(gitError("INVALID_ARGUMENT", `A push that can't be read: ${error.message}`))));
|
|
111
|
+
const { start, objects } = started.start;
|
|
112
|
+
if (start === "probe") return gitAnswer(resultType(service), /* @__PURE__ */ new Uint8Array());
|
|
113
|
+
const edits = start.commands.map((command) => ({
|
|
114
|
+
ref: command.ref,
|
|
115
|
+
from: command.before === zero ? null : command.before,
|
|
116
|
+
to: command.after === zero ? null : command.after
|
|
117
|
+
}));
|
|
118
|
+
const needsPack = edits.some((edit) => edit.to !== null);
|
|
119
|
+
const refused = refusedStart(start, needsPack, objects);
|
|
120
|
+
const input = {
|
|
121
|
+
request,
|
|
122
|
+
edits,
|
|
123
|
+
atomic: start.capabilities.includes("atomic"),
|
|
124
|
+
pushOptions: start.pushOptions,
|
|
125
|
+
signal: request.signal
|
|
126
|
+
};
|
|
127
|
+
if (needsPack && objects !== void 0) input.pack = packOf(request, started.rest, objects);
|
|
128
|
+
if (start.shallow.length > 0) input.shallow = start.shallow;
|
|
129
|
+
const pushed = refused === void 0 ? yield* Effect.result(receiving.push(input)) : Result.fail(refused);
|
|
130
|
+
yield* started.drain(drainLimit);
|
|
131
|
+
return gitAnswer(resultType(service), yield* reportOf(start, pushed));
|
|
132
|
+
});
|
|
133
|
+
/** Why a push is refused before it's tried, or `undefined`. */
|
|
134
|
+
const refusedStart = (start, needsPack, objects) => {
|
|
135
|
+
if (needsPack && objects === void 0) return gitError("INVALID_ARGUMENT", "the push's pack is missing or isn't a pack");
|
|
136
|
+
const options = pushOptionsRefusal(start.pushOptions);
|
|
137
|
+
return options === void 0 ? void 0 : gitError("INVALID_ARGUMENT", options);
|
|
138
|
+
};
|
|
139
|
+
/** The most of a reason or a message the report tells, in UTF-8: room in any pkt-line, and in the
|
|
140
|
+
* 4 KiB Git prints a line of `error:` in. */
|
|
141
|
+
const maxTold = 1024;
|
|
142
|
+
/**
|
|
143
|
+
* Text for one line of the report, as Git's reasons and messages are: no newline, and at most
|
|
144
|
+
* `room` bytes of UTF-8, cut on a code point and ended with `…`, since a refusal may quote what
|
|
145
|
+
* was pushed, such as a `.gitmodules` url, and a line longer than a pkt-line can't be sent.
|
|
146
|
+
*/
|
|
147
|
+
const oneLine = (text, room = maxTold) => {
|
|
148
|
+
const bytes = encoder.encode(text.replaceAll(/[\r\n]+/g, " "));
|
|
149
|
+
if (bytes.length <= room) return decoder.decode(bytes);
|
|
150
|
+
let end = room - ellipsis;
|
|
151
|
+
while (end > 0 && ((bytes[end] ?? 0) & 192) === 128) end -= 1;
|
|
152
|
+
return `${decoder.decode(bytes.subarray(0, end))}…`;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* The report for `pushed`, as the start asked: on `side-band-64k` with any messages on band 2
|
|
156
|
+
* first, each a whole line, with `report-status-v2`'s options or not, and none at all without `report-status`.
|
|
157
|
+
*/
|
|
158
|
+
const reportOf = (start, pushed) => Effect.gen(function* () {
|
|
159
|
+
const asked = start.capabilities;
|
|
160
|
+
const sideBand = asked.includes("side-band-64k");
|
|
161
|
+
const v2 = asked.includes("report-status-v2");
|
|
162
|
+
if (!v2 && !asked.includes("report-status")) return /* @__PURE__ */ new Uint8Array();
|
|
163
|
+
const refs = start.commands.map((command) => command.ref);
|
|
164
|
+
const { unpack, results, messages } = outcome(refs, pushed);
|
|
165
|
+
const report = yield* Effect.mapError(encodePushReport({
|
|
166
|
+
unpack,
|
|
167
|
+
refs: results
|
|
168
|
+
}, {
|
|
169
|
+
sideBand,
|
|
170
|
+
v2
|
|
171
|
+
}), unwritable);
|
|
172
|
+
const told = messages.map((message) => encoder.encode(`${oneLine(message)}\n`));
|
|
173
|
+
return sideBand ? joinedBytes([...told.map((message) => onBand(2, message)), report]) : report;
|
|
174
|
+
});
|
|
175
|
+
/** The room an `ng` line for `ref` leaves for its reason: `ng <ref> <reason>\n` is one pkt-line. */
|
|
176
|
+
const roomBeside = (ref) => Math.min(maxTold, maxPktData - encoder.encode(`ng ${ref} \n`).length);
|
|
177
|
+
/**
|
|
178
|
+
* A refused ref's lines for band 2, which Git prints as `remote:` lines: why, and what to do,
|
|
179
|
+
* once for each reason however many refs it refused. A hint of several lines, such as
|
|
180
|
+
* `refs.files`' fix and its listing, is a `hint:` line each; every line goes through `oneLine`.
|
|
181
|
+
*/
|
|
182
|
+
const refusalLines = (refused) => {
|
|
183
|
+
const lines = /* @__PURE__ */ new Set();
|
|
184
|
+
for (const error of refused) {
|
|
185
|
+
lines.add(error.message);
|
|
186
|
+
for (const hint of error.hint?.split(/\r?\n/) ?? []) lines.add(`hint: ${hint}`);
|
|
187
|
+
}
|
|
188
|
+
return [...lines];
|
|
189
|
+
};
|
|
190
|
+
/** A refusal of the whole push, as lines for band 2: why, then what to do, if it says. */
|
|
191
|
+
const errorLines = ({ message, hint }) => hint === void 0 ? [`error: ${message}`] : [`error: ${message}`, `hint: ${hint}`];
|
|
192
|
+
/** Each ref's line, the `unpack` status, and the lines for band 2. */
|
|
193
|
+
const outcome = (refs, pushed) => {
|
|
194
|
+
const each = (ok, reason) => ok ? (ref) => ({
|
|
195
|
+
ref,
|
|
196
|
+
ok,
|
|
197
|
+
options: {}
|
|
198
|
+
}) : (ref) => ({
|
|
199
|
+
ref,
|
|
200
|
+
ok,
|
|
201
|
+
reason: oneLine(reason ?? "rejected", roomBeside(ref)),
|
|
202
|
+
options: {}
|
|
203
|
+
});
|
|
204
|
+
if (Result.isFailure(pushed)) {
|
|
205
|
+
const { message } = pushed.failure;
|
|
206
|
+
return {
|
|
207
|
+
unpack: "ok",
|
|
208
|
+
results: refs.map(each(false, message)),
|
|
209
|
+
messages: errorLines(pushed.failure)
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (pushed.success.kind === "unpack-failed") {
|
|
213
|
+
const { message } = pushed.success.error;
|
|
214
|
+
return {
|
|
215
|
+
unpack: oneLine(message),
|
|
216
|
+
results: refs.map(each(false, "unpacker error")),
|
|
217
|
+
messages: errorLines(pushed.success.error)
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const { updates } = pushed.success.updated;
|
|
221
|
+
const byRef = new Map(updates.map((update) => [update.ref, update]));
|
|
222
|
+
const results = refs.map((ref) => {
|
|
223
|
+
const update = byRef.get(ref);
|
|
224
|
+
if (update === void 0) return each(false, "not updated")(ref);
|
|
225
|
+
return update.kind === "applied" ? each(true)(ref) : each(false, update.error.message)(ref);
|
|
226
|
+
});
|
|
227
|
+
const refused = updates.flatMap((update) => update.kind === "rejected" ? [update.error] : []);
|
|
228
|
+
const notes = pushed.success.notes ?? [];
|
|
229
|
+
return {
|
|
230
|
+
unpack: "ok",
|
|
231
|
+
results,
|
|
232
|
+
messages: [...refusalLines(refused), ...notes]
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
export { receivePack, receivePackRefs, reportOf, routeCounted };
|