@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,31 @@
|
|
|
1
|
+
import "../index.mjs";
|
|
2
|
+
import "./pack-reads.mjs";
|
|
3
|
+
import "../protocol.mjs";
|
|
4
|
+
import "../contracts/objects.mjs";
|
|
5
|
+
import { RepoStats } from "../contracts/repos.mjs";
|
|
6
|
+
import "../contracts/services.mjs";
|
|
7
|
+
import "../contracts/store.mjs";
|
|
8
|
+
import "./index-remap.mjs";
|
|
9
|
+
import "./object-rows.mjs";
|
|
10
|
+
import "./rows.mjs";
|
|
11
|
+
import "../contracts/promises.mjs";
|
|
12
|
+
import { Duration, Key, Moment, Row } from "@ref0/infra";
|
|
13
|
+
import "effect/Effect";
|
|
14
|
+
import "effect/Types";
|
|
15
|
+
/**
|
|
16
|
+
* How `packs()` merges a repo's packs: as Git's `repack --geometric=<geometric>`, by object
|
|
17
|
+
* count, so each pack holds at least `geometric` times the objects of all smaller ones together;
|
|
18
|
+
* no merged pack past `maxPackSize` bytes.
|
|
19
|
+
*/
|
|
20
|
+
export interface RepackOptions {
|
|
21
|
+
readonly geometric: number;
|
|
22
|
+
readonly maxPackSize?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The most CPU a merge's remap of the reachability index may forecast, in ms: 30 s, 10% of a
|
|
25
|
+
* Worker's 300 s `cpu_ms`, unless set. Past it, the merge commits without the remap, and the
|
|
26
|
+
* next `git.index` builds again.
|
|
27
|
+
*/
|
|
28
|
+
readonly remapCpuMost?: number;
|
|
29
|
+
}
|
|
30
|
+
/** An option as a value, `false` for none, or chosen from the repo's stats each time it's used. */
|
|
31
|
+
export type Option<T> = T | false | ((stats: RepoStats) => T | false);
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { fixedRoom } from "../protocol/packs/indexer.mjs";
|
|
2
|
+
import { repoScope } from "../store/scopes.mjs";
|
|
3
|
+
import { remapRow } from "./index-remap.mjs";
|
|
4
|
+
import { isPackId, objectCollections } from "./layout.mjs";
|
|
5
|
+
import { writeMerged } from "./merge.mjs";
|
|
6
|
+
import { largeBatch, objectKey, objectOfRow, tooLargeRead } from "./object-rows.mjs";
|
|
7
|
+
import { PackBlocks, blockBytes, blockHeld } from "./pack-reads.mjs";
|
|
8
|
+
import { leavingRow, pruneFloor } from "./rows.mjs";
|
|
9
|
+
import { limits } from "@ref0/infra";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Predicate from "effect/Predicate";
|
|
12
|
+
// src/storage/repack.ts
|
|
13
|
+
/** Git's `repack.geometric` of 2, and no pack past 1 GiB. */
|
|
14
|
+
const defaultRepack = {
|
|
15
|
+
geometric: 2,
|
|
16
|
+
maxPackSize: 1024 ** 3
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* `option` for a repo with `stats`, `fallback` when the host set none. A caller that read no
|
|
20
|
+
* stats, as none of its options is a function, gets `fallback` for one that is.
|
|
21
|
+
*/
|
|
22
|
+
const optionFor = (option, fallback, stats) => {
|
|
23
|
+
if (option === void 0) return fallback;
|
|
24
|
+
if (!Predicate.isFunction(option)) return option;
|
|
25
|
+
return stats === void 0 ? fallback : option(stats);
|
|
26
|
+
};
|
|
27
|
+
/** The object rows one step folds at most: the rest wait for the steps after it. */
|
|
28
|
+
const foldedRows = 1e3;
|
|
29
|
+
/**
|
|
30
|
+
* A step's commit writes, of the store's 10,000, its group's take at most: two for each pack it
|
|
31
|
+
* merges, its row's delete and its `leaving` row, and one for each object row it folds. The rest
|
|
32
|
+
* are the core's, for the receipts' sweep and the run's events.
|
|
33
|
+
*/
|
|
34
|
+
const groupWrites = limits.writes / 2;
|
|
35
|
+
/**
|
|
36
|
+
* The objects one merge takes at most. It holds each input's index and an entry for each object
|
|
37
|
+
* while it writes, so a Worker's 128 MiB holds them all.
|
|
38
|
+
*/
|
|
39
|
+
const groupObjects = 2e5;
|
|
40
|
+
/**
|
|
41
|
+
* The repo's object rows, a small push's each, which a merge folds into its pack: the first
|
|
42
|
+
* `foldedRows` of them, or as many of the largest as one read's 16 MiB answer holds. They're
|
|
43
|
+
* `whole` when the read came back short of its limit.
|
|
44
|
+
*/
|
|
45
|
+
const readObjectRows = Effect.fnUntraced(function* (input) {
|
|
46
|
+
const scope = repoScope(input.listed.repo);
|
|
47
|
+
const page = (limit) => Effect.map(input.store.read({
|
|
48
|
+
scope,
|
|
49
|
+
reads: [{
|
|
50
|
+
collection: objectCollections.objects,
|
|
51
|
+
limit
|
|
52
|
+
}]
|
|
53
|
+
}), (snapshot) => {
|
|
54
|
+
const rows = snapshot.results[0] ?? [];
|
|
55
|
+
return {
|
|
56
|
+
rows,
|
|
57
|
+
whole: rows.length < limit
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
return yield* page(foldedRows).pipe(Effect.catchIf(tooLargeRead, () => page(largeBatch)));
|
|
61
|
+
});
|
|
62
|
+
/** Each object row, read whole. */
|
|
63
|
+
const wholeRows = (rows) => Effect.forEach(rows, (row) => objectOfRow(row));
|
|
64
|
+
/** The bytes a row's value takes, as JSON writes it. */
|
|
65
|
+
const rowsBytes = (rows) => rows.reduce((sum, row) => sum + JSON.stringify(row.value).length, 0);
|
|
66
|
+
const namedOf = (pack) => isPackId(pack.id) ? Effect.succeed({
|
|
67
|
+
...pack,
|
|
68
|
+
id: pack.id
|
|
69
|
+
}) : Effect.die(/* @__PURE__ */ new Error(`The pack row '${pack.id}' doesn't name a pack`));
|
|
70
|
+
const loadAll = (input, packs) => Effect.forEach(packs, (pack) => input.indexes.load(input.bucket, pack));
|
|
71
|
+
/** What `writeMerged` takes beside its inputs, for one step. */
|
|
72
|
+
const writeParts = (input) => ({
|
|
73
|
+
store: input.store,
|
|
74
|
+
bucket: input.bucket,
|
|
75
|
+
blocks: new PackBlocks(input.bucket, fixedRoom(8 * blockHeld(blockBytes))),
|
|
76
|
+
repo: input.listed.repo,
|
|
77
|
+
at: input.at,
|
|
78
|
+
prune: input.quarantine
|
|
79
|
+
});
|
|
80
|
+
/** A removed pack's `leaving` row: a fetch still reading it ends first, and never under an hour. */
|
|
81
|
+
const leavingRows = (input, removed) => {
|
|
82
|
+
const removeAt = input.at + Math.max(pruneFloor, input.fetchLimits.milliseconds);
|
|
83
|
+
return removed.map((pack) => leavingRow(pack, removeAt));
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* The change that lists `merged` in place of `removed` and of the folded object `rows`: each
|
|
87
|
+
* removed pack a `leaving` row, and the merged pack's `quarantine` row ended in the same commit.
|
|
88
|
+
*/
|
|
89
|
+
const replacing = (input, merged, removed, rows) => ({
|
|
90
|
+
add: [merged.pack],
|
|
91
|
+
remove: removed.map((pack) => pack.id),
|
|
92
|
+
put: leavingRows(input, removed),
|
|
93
|
+
delete: [merged.quarantine, ...rows.map((row) => objectKey(row.oid))]
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* The members a geometric repack merges, smallest first: Git's `split_pack_geometry`, those
|
|
97
|
+
* below the first pack that holds `factor` times every smaller one's objects together, then
|
|
98
|
+
* rolled up while the next is under `factor` times their total. Capped, smallest first, at
|
|
99
|
+
* `maxPackSize` bytes, `groupObjects` objects and `groupWrites` of a commit's writes; fewer than
|
|
100
|
+
* two merge nothing.
|
|
101
|
+
*/
|
|
102
|
+
const geometricGroup = (members, options) => {
|
|
103
|
+
const sorted = [...members].sort((a, b) => a.objects - b.objects);
|
|
104
|
+
const factor = options.geometric;
|
|
105
|
+
let split = sorted.length - 1;
|
|
106
|
+
for (; split > 0; split -= 1) if ((sorted[split]?.objects ?? 0) < factor * (sorted[split - 1]?.objects ?? 0)) break;
|
|
107
|
+
if (split > 0) split += 1;
|
|
108
|
+
let total = sorted.slice(0, split).reduce((sum, member) => sum + member.objects, 0);
|
|
109
|
+
for (; split < sorted.length; split += 1) {
|
|
110
|
+
const ours = sorted[split]?.objects ?? 0;
|
|
111
|
+
if (ours >= factor * total) break;
|
|
112
|
+
total += ours;
|
|
113
|
+
}
|
|
114
|
+
const most = options.maxPackSize ?? defaultRepack.maxPackSize;
|
|
115
|
+
const group = [];
|
|
116
|
+
const taken = {
|
|
117
|
+
bytes: 0,
|
|
118
|
+
objects: 0,
|
|
119
|
+
writes: 0
|
|
120
|
+
};
|
|
121
|
+
for (const member of sorted.slice(0, split)) {
|
|
122
|
+
if (taken.bytes + member.bytes > most) break;
|
|
123
|
+
if (taken.objects + member.objects > 2e5) break;
|
|
124
|
+
if (taken.writes + member.writes > groupWrites) break;
|
|
125
|
+
group.push(member);
|
|
126
|
+
taken.bytes += member.bytes;
|
|
127
|
+
taken.objects += member.objects;
|
|
128
|
+
taken.writes += member.writes;
|
|
129
|
+
}
|
|
130
|
+
return group.length < 2 ? [] : group;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* One geometric step: the group `geometricGroup` picks among the listed packs but `kept`, with
|
|
134
|
+
* the object rows as one member, merged into one pack under its own `quarantine` row.
|
|
135
|
+
* `undefined` when the repo's packs already make a progression, or when no group of two fits in
|
|
136
|
+
* `maxPackSize` once merged.
|
|
137
|
+
*/
|
|
138
|
+
const geometricStep = Effect.fnUntraced(function* (input, options, objectRows, kept = () => false, remap) {
|
|
139
|
+
const members = [...input.listed.packs.filter((pack) => !kept(pack)).map((pack) => ({
|
|
140
|
+
kind: "pack",
|
|
141
|
+
pack,
|
|
142
|
+
objects: pack.objects,
|
|
143
|
+
bytes: pack.bytes,
|
|
144
|
+
writes: 2
|
|
145
|
+
})), ...objectRows.length === 0 ? [] : [{
|
|
146
|
+
kind: "rows",
|
|
147
|
+
objects: objectRows.length,
|
|
148
|
+
bytes: rowsBytes(objectRows),
|
|
149
|
+
writes: objectRows.length
|
|
150
|
+
}]];
|
|
151
|
+
const most = options.maxPackSize ?? defaultRepack.maxPackSize;
|
|
152
|
+
for (let group = geometricGroup(members, options); group.length >= 2; group = group.slice(0, Math.ceil(group.length / 2))) {
|
|
153
|
+
const chosen = new Set(group.flatMap((member) => member.kind === "pack" ? [member.pack] : []));
|
|
154
|
+
const packs = input.listed.packs.filter((pack) => chosen.has(pack));
|
|
155
|
+
const rows = group.some((member) => member.kind === "rows") ? yield* wholeRows(objectRows) : [];
|
|
156
|
+
const merged = yield* writeMerged({
|
|
157
|
+
...writeParts(input),
|
|
158
|
+
inputs: yield* loadAll(input, packs),
|
|
159
|
+
rows,
|
|
160
|
+
most
|
|
161
|
+
});
|
|
162
|
+
if (merged === "too big") continue;
|
|
163
|
+
if (merged === void 0) return void 0;
|
|
164
|
+
const removed = yield* Effect.forEach(packs, namedOf);
|
|
165
|
+
const step = {
|
|
166
|
+
change: replacing(input, merged, removed, rows),
|
|
167
|
+
more: true,
|
|
168
|
+
quarantine: merged.quarantine
|
|
169
|
+
};
|
|
170
|
+
const index = remap === void 0 ? void 0 : yield* remapRow(remap, {
|
|
171
|
+
bucket: input.bucket,
|
|
172
|
+
listed: input.listed,
|
|
173
|
+
merged,
|
|
174
|
+
taken: new Set(packs.map((pack) => pack.id)),
|
|
175
|
+
folded: rows.map((row) => row.oid),
|
|
176
|
+
at: input.at
|
|
177
|
+
});
|
|
178
|
+
if (index !== void 0) step.index = index;
|
|
179
|
+
return step;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
export { defaultRepack, foldedRows, geometricGroup, geometricStep, groupObjects, groupWrites, leavingRows, loadAll, namedOf, optionFor, readObjectRows, replacing, rowsBytes, wholeRows, writeParts };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "../contracts/objects.mjs";
|
|
2
|
+
import "../protocol/objects/object.mjs";
|
|
3
|
+
import { linksOf } from "./links.mjs";
|
|
4
|
+
import * as Result from "effect/Result";
|
|
5
|
+
// src/storage/roots.ts
|
|
6
|
+
/**
|
|
7
|
+
* Of a receive's objects, in `oids`, those `named` says none of the others names: its roots. Links
|
|
8
|
+
* form no cycle, so a chain of namers up from any of its objects ends at a root, and once every
|
|
9
|
+
* root is a tip the push moves a ref to, a ref reaches each object it carries. `undefined` past
|
|
10
|
+
* `receivedRootsMost`, which proves nothing. `named` may miss a link, never invent one: a root it
|
|
11
|
+
* shows too many only fails to prove the objects reached (#647).
|
|
12
|
+
*/
|
|
13
|
+
const rootsOf = (oids, named) => {
|
|
14
|
+
const roots = [];
|
|
15
|
+
for (const oid of oids) {
|
|
16
|
+
if (named(oid)) continue;
|
|
17
|
+
if (roots.length === 4e3) return void 0;
|
|
18
|
+
roots.push(oid);
|
|
19
|
+
}
|
|
20
|
+
return roots;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Of whole objects, a small push's rows, their links read again: their roots, and each object they
|
|
24
|
+
* name outside them but the empty tree, which the repo needn't store. `undefined` past the most
|
|
25
|
+
* roots, which proves nothing.
|
|
26
|
+
*/
|
|
27
|
+
const wholeRoots = (objects) => {
|
|
28
|
+
const named = /* @__PURE__ */ new Set();
|
|
29
|
+
for (const object of objects) {
|
|
30
|
+
const links = linksOf(object);
|
|
31
|
+
if (Result.isFailure(links)) return void 0;
|
|
32
|
+
for (const link of links.success) named.add(link.oid);
|
|
33
|
+
}
|
|
34
|
+
const own = new Set(objects.map(({ oid }) => oid));
|
|
35
|
+
const roots = rootsOf(own, (oid) => named.has(oid));
|
|
36
|
+
if (roots === void 0) return void 0;
|
|
37
|
+
return {
|
|
38
|
+
roots,
|
|
39
|
+
outside: [...named].filter((oid) => !own.has(oid) && oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904")
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export { rootsOf, wholeRoots };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { decodeRow, fail } from "../store/errors.mjs";
|
|
2
|
+
import { isPackId, objectCollections } from "./layout.mjs";
|
|
3
|
+
import { millis } from "@ref0/infra";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
// src/storage/rows.ts
|
|
7
|
+
/**
|
|
8
|
+
* A pack being written, added before its first byte. `open` while its writer may still list it;
|
|
9
|
+
* `abandoned` once its `removeAt` has passed and clean-up committed it so, which refuses a late
|
|
10
|
+
* writer's listing commit.
|
|
11
|
+
*/
|
|
12
|
+
const QuarantineRow = Schema.Struct({
|
|
13
|
+
removeAt: Schema.Int,
|
|
14
|
+
state: Schema.Literals(["open", "abandoned"])
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* A pack this repo's list no longer names, its marker and bytes kept until `removeAt`, with the
|
|
18
|
+
* size its list gave. A deleted repo's are `deleted`, so a read that holds an older list still
|
|
19
|
+
* finds an object moved into one. A step's never are: its merged pack is listed with what its
|
|
20
|
+
* inputs held, but a pass's dropped objects, which no read may find. `taken` once clean-up has
|
|
21
|
+
* committed it so, before it deletes the marker, which refuses a late sync's or fetch's listing.
|
|
22
|
+
*/
|
|
23
|
+
const LeavingRow = Schema.Struct({
|
|
24
|
+
removeAt: Schema.Int,
|
|
25
|
+
objects: Schema.Int,
|
|
26
|
+
bytes: Schema.Int,
|
|
27
|
+
deleted: Schema.optional(Schema.Literal(true)),
|
|
28
|
+
taken: Schema.optional(Schema.Literal(true))
|
|
29
|
+
});
|
|
30
|
+
const quarantineKey = (pack) => ({
|
|
31
|
+
collection: objectCollections.quarantine,
|
|
32
|
+
id: pack
|
|
33
|
+
});
|
|
34
|
+
const leavingKey = (pack) => ({
|
|
35
|
+
collection: objectCollections.leaving,
|
|
36
|
+
id: pack
|
|
37
|
+
});
|
|
38
|
+
const quarantineRow = (pack, value) => ({
|
|
39
|
+
...quarantineKey(pack),
|
|
40
|
+
value
|
|
41
|
+
});
|
|
42
|
+
const leavingRow = (pack, removeAt, { deleted = false } = {}) => {
|
|
43
|
+
const value = {
|
|
44
|
+
removeAt,
|
|
45
|
+
objects: pack.objects,
|
|
46
|
+
bytes: pack.bytes
|
|
47
|
+
};
|
|
48
|
+
if (deleted) value.deleted = true;
|
|
49
|
+
return {
|
|
50
|
+
...leavingKey(pack.id),
|
|
51
|
+
value
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/** `prune`'s floor, and `fetchLimits`' time's: no server waits less than an hour for either. */
|
|
55
|
+
const pruneFloor = millis("1 hour");
|
|
56
|
+
const defaultPrune = "14 days";
|
|
57
|
+
/** How long `prune` waits, in milliseconds: never under an hour. */
|
|
58
|
+
const pruneWait = (prune) => Math.max(millis(prune), pruneFloor);
|
|
59
|
+
/** When a row written at `at` is due, from `prune` as it is now. */
|
|
60
|
+
const removeAt = (at, prune) => at + pruneWait(prune);
|
|
61
|
+
/** A stored row as `schema`, keyed by a pack's ID; anything else is `DATA_LOSS`. */
|
|
62
|
+
const decodeHeld = (schema, row) => {
|
|
63
|
+
const what = `The ${row.collection} row '${row.id}'`;
|
|
64
|
+
if (!isPackId(row.id)) return fail("DATA_LOSS", `${what} doesn't name a pack`);
|
|
65
|
+
const pack = row.id;
|
|
66
|
+
return Effect.map(decodeRow(schema, row, what), (value) => ({
|
|
67
|
+
pack,
|
|
68
|
+
value
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
export { LeavingRow, QuarantineRow, decodeHeld, defaultPrune, leavingKey, leavingRow, pruneFloor, pruneWait, quarantineKey, quarantineRow, removeAt };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { gitError } from "../store/errors.mjs";
|
|
2
|
+
import { historyOf, lost, unreadable, walk } from "./walk.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
// src/storage/shallow.ts
|
|
5
|
+
/**
|
|
6
|
+
* A depth this large deepens a shallow clone to its whole history, as `git fetch --unshallow`
|
|
7
|
+
* asks with `deepen 2147483647`, Git's `INFINITE_DEPTH`.
|
|
8
|
+
*/
|
|
9
|
+
const infiniteDepth = 2147483647;
|
|
10
|
+
const notACommit = (object) => gitError("INVALID_ARGUMENT", `The shallow line names ${object.oid}, a ${object.type}`, { hint: "A shallow clone names only commits it holds without their parents" });
|
|
11
|
+
/**
|
|
12
|
+
* The client's shallow commits this repo holds: one it doesn't hold is passed over,
|
|
13
|
+
* as Git's server does, and one that isn't a commit is refused.
|
|
14
|
+
*/
|
|
15
|
+
const clientShallowsOf = Effect.fnUntraced(function* (read, shallows) {
|
|
16
|
+
const held = [...(yield* read([...new Set(shallows)])).values()];
|
|
17
|
+
const odd = held.find((object) => object.type !== "commit");
|
|
18
|
+
if (odd !== void 0) return yield* Effect.fail(notACommit(odd));
|
|
19
|
+
return new Map(held.map((object) => [object.oid, object]));
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* The parents of `commits`, in order: each taken one at a time, as a merge can name more parents
|
|
23
|
+
* than a call takes arguments.
|
|
24
|
+
*/
|
|
25
|
+
const parentsOf = (commits) => {
|
|
26
|
+
const parents = [];
|
|
27
|
+
for (const commit of commits) for (const parent of historyOf(commit)) parents.push(parent);
|
|
28
|
+
return parents;
|
|
29
|
+
};
|
|
30
|
+
/** The commits `wants` name, a tag peeled to what it tags: a want of a tree or a blob has none. */
|
|
31
|
+
const wantedCommits = Effect.fnUntraced(function* (read, wants) {
|
|
32
|
+
const commits = /* @__PURE__ */ new Set();
|
|
33
|
+
let frontier = [...new Set(wants)];
|
|
34
|
+
while (frontier.length > 0) {
|
|
35
|
+
const found = yield* read(frontier);
|
|
36
|
+
const next = [];
|
|
37
|
+
for (const object of found.values()) if (object.type === "commit") commits.add(object.oid);
|
|
38
|
+
else if (object.type === "tag") next.push(...historyOf(object));
|
|
39
|
+
frontier = next.filter((oid) => !commits.has(oid));
|
|
40
|
+
}
|
|
41
|
+
return [...commits];
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* The client's shallow commits the wants reach, walking down from the wants: those
|
|
45
|
+
* `deepen-relative` deepens from, and the only ones a deepen unshallows, so a fetch never sends
|
|
46
|
+
* history a want doesn't reach. `past` walks on below each one, as an infinite deepen sends that
|
|
47
|
+
* history anyway, so one behind another is reached too; without it the walk stops at each, so
|
|
48
|
+
* `deepen-relative` reads no more than the client holds.
|
|
49
|
+
*/
|
|
50
|
+
const reachedShallows = Effect.fnUntraced(function* (read, wants, shallows, past) {
|
|
51
|
+
const reached = yield* walk(read, wants, (object) => !past && shallows.has(object.oid) ? [] : historyOf(object), /* @__PURE__ */ new Set(), lost);
|
|
52
|
+
return [...shallows.values()].filter((commit) => reached.has(commit.oid));
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* The commits within `depth` of `starts`, each at its least depth over every path, a start at 1:
|
|
56
|
+
* `within` those under `depth`, whose parents the pack follows, and `edge` those at it, whose
|
|
57
|
+
* parents it leaves out.
|
|
58
|
+
*/
|
|
59
|
+
const byDepth = Effect.fnUntraced(function* (read, starts, depth) {
|
|
60
|
+
const within = /* @__PURE__ */ new Map();
|
|
61
|
+
let frontier = [...new Set(starts)];
|
|
62
|
+
for (let level = 1; level < depth && frontier.length > 0; level += 1) {
|
|
63
|
+
const found = yield* read(frontier);
|
|
64
|
+
const next = /* @__PURE__ */ new Set();
|
|
65
|
+
for (const oid of frontier) {
|
|
66
|
+
const commit = found.get(oid);
|
|
67
|
+
if (commit === void 0) return yield* Effect.fail(lost(oid));
|
|
68
|
+
if (commit.type !== "commit") return yield* Effect.fail(unreadable(commit, "a commit names it as a parent"));
|
|
69
|
+
within.set(oid, commit);
|
|
70
|
+
for (const parent of historyOf(commit)) if (!within.has(parent)) next.add(parent);
|
|
71
|
+
}
|
|
72
|
+
frontier = [...next].filter((oid) => !within.has(oid));
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
within,
|
|
76
|
+
edge: frontier
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* A fetch's shallow lines and where its history stops, as Git's `upload-pack` works them out from
|
|
81
|
+
* `gitprotocol-v2`'s `deepen` and `deepen-relative`:
|
|
82
|
+
* - with no depth, the client's shallow commits stay so, and the pack stops at them;
|
|
83
|
+
* - `deepen <n>` keeps the commits fewer than `n` from a want, by their nearest path, and cuts at
|
|
84
|
+
* those `n` away: one at the cut is `shallow` unless the client already holds it so, and a
|
|
85
|
+
* client's shallow commit inside it is `unshallow`;
|
|
86
|
+
* - `deepen-relative` counts `n` more from the client's shallow commits the wants reach;
|
|
87
|
+
* - `deepen 2147483647`, without `deepen-relative`, unshallows every one the wants reach, one
|
|
88
|
+
* behind another too. Git's unshallows every one it holds, but the history behind one no
|
|
89
|
+
* want reaches isn't the caller's to fetch.
|
|
90
|
+
*/
|
|
91
|
+
const planShallow = Effect.fnUntraced(function* (read, request) {
|
|
92
|
+
const shallows = yield* clientShallowsOf(read, request.shallows);
|
|
93
|
+
const clientShallows = new Set(shallows.keys());
|
|
94
|
+
const depth = request.depth;
|
|
95
|
+
if (depth === void 0) return {
|
|
96
|
+
shallow: [],
|
|
97
|
+
unshallow: [],
|
|
98
|
+
cut: clientShallows,
|
|
99
|
+
clientShallows,
|
|
100
|
+
starts: []
|
|
101
|
+
};
|
|
102
|
+
const relative = request.deepenRelative === true;
|
|
103
|
+
const wants = yield* wantedCommits(read, request.wants);
|
|
104
|
+
if (!relative && depth >= 2147483647) {
|
|
105
|
+
const reached = yield* reachedShallows(read, wants, shallows, true);
|
|
106
|
+
const unshallow = reached.map((commit) => commit.oid);
|
|
107
|
+
const unshallowed = new Set(unshallow);
|
|
108
|
+
return {
|
|
109
|
+
shallow: [],
|
|
110
|
+
unshallow,
|
|
111
|
+
cut: new Set([...clientShallows].filter((oid) => !unshallowed.has(oid))),
|
|
112
|
+
clientShallows,
|
|
113
|
+
starts: parentsOf(reached)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const from = relative ? (yield* reachedShallows(read, wants, shallows, false)).map((commit) => commit.oid) : wants;
|
|
117
|
+
const levels = yield* byDepth(read, from, relative ? depth + 1 : depth);
|
|
118
|
+
const unshallowed = [...shallows.values()].filter((commit) => levels.within.has(commit.oid));
|
|
119
|
+
const kept = [...clientShallows].filter((oid) => !levels.within.has(oid));
|
|
120
|
+
return {
|
|
121
|
+
shallow: levels.edge.filter((oid) => !clientShallows.has(oid)),
|
|
122
|
+
unshallow: unshallowed.map((commit) => commit.oid),
|
|
123
|
+
cut: /* @__PURE__ */ new Set([...levels.edge, ...kept]),
|
|
124
|
+
clientShallows,
|
|
125
|
+
starts: parentsOf(unshallowed)
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
export { infiniteDepth, planShallow };
|