@ref0/git 0.0.0 → 0.3.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 +50 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +170 -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 +151 -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 +11 -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 +38 -0
- package/dist/contracts/promises.mjs +13 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +402 -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 +133 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +272 -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 +180 -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/call-names.d.mts +1 -0
- package/dist/core/call-names.mjs +93 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +475 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +297 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +212 -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 +64 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1070 -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 +26 -0
- package/dist/core/seam.mjs +54 -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 +4 -0
- package/dist/extend.mjs +3 -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 +1037 -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 +18 -0
- package/dist/rest/handler.mjs +129 -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 +17 -0
- package/dist/server/extension.mjs +93 -0
- package/dist/server/lifecycle.d.mts +3 -0
- package/dist/server/lifecycle.mjs +89 -0
- package/dist/server/routes.d.mts +28 -0
- package/dist/server/routes.mjs +60 -0
- package/dist/server/server.d.mts +8 -0
- package/dist/server/server.mjs +615 -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/bits.mjs +41 -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 +15 -0
- package/dist/storage/fetch.mjs +998 -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 +1447 -0
- package/dist/storage/index-fetch.d.mts +10 -0
- package/dist/storage/index-fetch.mjs +677 -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 +121 -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 +781 -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 +1007 -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 +603 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +152 -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 +4 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/send-list.d.mts +8 -0
- package/dist/storage/send-list.mjs +319 -0
- package/dist/storage/shallow.d.mts +4 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +238 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +8 -0
- package/dist/storage/walk.mjs +176 -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/closed.d.mts +21 -0
- package/dist/store/closed.mjs +34 -0
- package/dist/store/crossing.mjs +69 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +88 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +135 -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 +297 -0
- package/dist/store/promises.d.mts +5 -0
- package/dist/store/promises.mjs +258 -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 +34 -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 +83 -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 +555 -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 +141 -0
- package/package.json +86 -5
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { headOf, openRepo } from "../core/access.mjs";
|
|
2
|
+
import { kindsOf } from "../core/ancestry.mjs";
|
|
3
|
+
import { isRefName } from "../core/names.mjs";
|
|
4
|
+
import { hiddenUnder } from "../protocol/wire/lines.mjs";
|
|
5
|
+
import { receiveRefs, sendPush } from "../client/remote.mjs";
|
|
6
|
+
import { effectObjects, oneShotReads } from "../storage/calls.mjs";
|
|
7
|
+
import { decodeRow, fail, storeCall } from "../store/errors.mjs";
|
|
8
|
+
import { MirrorRow } from "../store/records.mjs";
|
|
9
|
+
import { collections, jobRepo, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
10
|
+
import { boundOf } from "./bound.mjs";
|
|
11
|
+
import { readImport } from "./records.mjs";
|
|
12
|
+
import { fromRemote, httpOf, openedFor, remoteOf, runTry, syncObjects, unknownProvider } from "./tries.mjs";
|
|
13
|
+
import { resultIn, uncounted } from "../store/crossing.mjs";
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Result from "effect/Result";
|
|
16
|
+
// src/sync/mirror.ts
|
|
17
|
+
/** How long a mirror waits before it reads its repo's import again, while the import runs. */
|
|
18
|
+
const importWait = 1e4;
|
|
19
|
+
const mirrorKey = (ref) => ({
|
|
20
|
+
collection: collections.mirrors,
|
|
21
|
+
id: ref
|
|
22
|
+
});
|
|
23
|
+
const mirrorRow = (ref, value) => ({
|
|
24
|
+
...mirrorKey(ref),
|
|
25
|
+
value
|
|
26
|
+
});
|
|
27
|
+
const mirrorsRead = { collection: collections.mirrors };
|
|
28
|
+
/** The codes a remote answers a credential or a repo it won't push to with: the mirror pauses. */
|
|
29
|
+
const refusedCodes = /* @__PURE__ */ new Set([
|
|
30
|
+
"UNAUTHENTICATED",
|
|
31
|
+
"NOT_ALLOWED",
|
|
32
|
+
"NOT_FOUND"
|
|
33
|
+
]);
|
|
34
|
+
const stateOf = (repo, ref, row) => {
|
|
35
|
+
const state = {
|
|
36
|
+
repo,
|
|
37
|
+
ref,
|
|
38
|
+
state: row.state
|
|
39
|
+
};
|
|
40
|
+
if (row.paused !== void 0) state.paused = row.paused;
|
|
41
|
+
return state;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* `mirror`: the mirror's row, active, and its job due now, in one commit, once the caller may
|
|
45
|
+
* update the repo and the destination names a provider `syncJobs` was given. Sent again, it
|
|
46
|
+
* writes the same row, so a paused mirror resumes and an active one pushes again.
|
|
47
|
+
*/
|
|
48
|
+
const mirrorWith = Effect.fnUntraced(function* (input) {
|
|
49
|
+
const bound = yield* boundOf(input.git);
|
|
50
|
+
const { destination } = input;
|
|
51
|
+
if (!bound.providers.has(destination.provider)) return yield* Effect.fail(unknownProvider(destination.provider));
|
|
52
|
+
const caller = { actor: input.actor };
|
|
53
|
+
const operation = {
|
|
54
|
+
kind: "repo.update",
|
|
55
|
+
repo: input.repo
|
|
56
|
+
};
|
|
57
|
+
const { internalId, record } = yield* openRepo(bound.core, caller, operation, [], input.internalId);
|
|
58
|
+
const ref = headOf(input.ref ?? record.defaultBranch);
|
|
59
|
+
if (!isRefName(ref)) return yield* fail("INVALID_ARGUMENT", `'${ref}' isn't a ref Git takes`);
|
|
60
|
+
if (hiddenUnder(ref) !== void 0) return yield* fail("INVALID_ARGUMENT", `'${ref}' is Git's own, and no mirror pushes it`);
|
|
61
|
+
const row = {
|
|
62
|
+
destination: {
|
|
63
|
+
provider: destination.provider,
|
|
64
|
+
repo: destination.repo
|
|
65
|
+
},
|
|
66
|
+
state: "active"
|
|
67
|
+
};
|
|
68
|
+
const job = bound.mirrorJob.job({
|
|
69
|
+
key: ref,
|
|
70
|
+
data: { ref }
|
|
71
|
+
});
|
|
72
|
+
const scope = repoScope(internalId);
|
|
73
|
+
const { store } = bound.core;
|
|
74
|
+
for (let tries = 0; tries < 5; tries += 1) {
|
|
75
|
+
const read = yield* storeCall(() => store.read(scope, [mirrorKey(ref)]));
|
|
76
|
+
if ((yield* storeCall(() => store.commit(scope, {
|
|
77
|
+
id: newChangeId(),
|
|
78
|
+
expect: read.version,
|
|
79
|
+
put: [mirrorRow(ref, row)],
|
|
80
|
+
jobs: [job]
|
|
81
|
+
}))).ok) return stateOf(input.repo, ref, row);
|
|
82
|
+
}
|
|
83
|
+
return yield* fail("UNAVAILABLE", `Other writes kept moving '${input.repo}'`, { hint: "Mirror again" });
|
|
84
|
+
});
|
|
85
|
+
/** The mirror's row, whether the repo's import still runs, and the row read's version. */
|
|
86
|
+
const readMirror = Effect.fnUntraced(function* (attempt) {
|
|
87
|
+
const { core, internalId, ref } = attempt;
|
|
88
|
+
const snapshot = yield* storeCall(() => core.store.read(repoScope(internalId), [mirrorKey(attempt.ref)]));
|
|
89
|
+
const [[own] = []] = snapshot.results;
|
|
90
|
+
const mirror = own === void 0 ? void 0 : yield* decodeRow(MirrorRow, own, `Mirror '${ref}'`);
|
|
91
|
+
const imported = yield* readImport(core.store, internalId);
|
|
92
|
+
return {
|
|
93
|
+
mirror,
|
|
94
|
+
importing: imported.row?.state === "running" && !imported.cancelled,
|
|
95
|
+
version: snapshot.version
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
const again = { kind: "more" };
|
|
99
|
+
/**
|
|
100
|
+
* The mirror paused, committed at `version`, the read the try began with: a push that moved the
|
|
101
|
+
* ref since, or a resume, moved it, so a stale try records nothing and its next read decides.
|
|
102
|
+
*/
|
|
103
|
+
const paused = Effect.fnUntraced(function* (attempt, version, mirror, why) {
|
|
104
|
+
const row = {
|
|
105
|
+
...mirror,
|
|
106
|
+
state: "paused",
|
|
107
|
+
paused: why
|
|
108
|
+
};
|
|
109
|
+
return (yield* storeCall(() => attempt.core.store.commit(repoScope(attempt.internalId), {
|
|
110
|
+
id: newChangeId(),
|
|
111
|
+
expect: version,
|
|
112
|
+
put: [mirrorRow(attempt.ref, row)]
|
|
113
|
+
}))).ok ? void 0 : again;
|
|
114
|
+
});
|
|
115
|
+
/** Whether the upstream's tip is behind the ref's: the walk the push decide's own kinds take. */
|
|
116
|
+
const goesOn = Effect.fnUntraced(function* (core, listed, edit) {
|
|
117
|
+
const kinds = yield* kindsOf({
|
|
118
|
+
objects: oneShotReads(effectObjects(syncObjects(core))),
|
|
119
|
+
listed,
|
|
120
|
+
pushed: () => Effect.succeed(void 0),
|
|
121
|
+
edits: [edit]
|
|
122
|
+
});
|
|
123
|
+
const [update] = kinds.updates;
|
|
124
|
+
if (update === void 0 || kinds.refused.has(edit.ref)) return false;
|
|
125
|
+
if (update.kind !== "force") return true;
|
|
126
|
+
return (yield* kinds.exact(update)) === "fast-forward";
|
|
127
|
+
});
|
|
128
|
+
const upstreamOf = Effect.fnUntraced(function* (http) {
|
|
129
|
+
const read = yield* Effect.result(receiveRefs(http));
|
|
130
|
+
if (Result.isSuccess(read)) return {
|
|
131
|
+
kind: "read",
|
|
132
|
+
refs: read.success
|
|
133
|
+
};
|
|
134
|
+
const { failure } = read;
|
|
135
|
+
if (!refusedCodes.has(failure.code)) return yield* Effect.fail(fromRemote("advertise")(failure));
|
|
136
|
+
return { kind: "refused" };
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* One mirror try: the mirror's row, the ref's tip and the upstream's, then a push of the ref from
|
|
140
|
+
* the upstream's tip, so the upstream only ever moves from the ID it advertised.
|
|
141
|
+
* - a paused mirror, or one with no row, ends; one whose repo's import runs waits for it;
|
|
142
|
+
* - an upstream already at the tip ends;
|
|
143
|
+
* - an upstream tip the ref doesn't go on from pauses it `diverged`;
|
|
144
|
+
* - a refused push whose upstream has moved since is stale, and reads again; one whose upstream
|
|
145
|
+
* hasn't, or a credential or a POST the upstream refuses, pauses it `refused`.
|
|
146
|
+
*/
|
|
147
|
+
const mirrorStep = Effect.fnUntraced(function* (attempt) {
|
|
148
|
+
const { core, bound, ref, context } = attempt;
|
|
149
|
+
const read = yield* readMirror(attempt);
|
|
150
|
+
const { mirror } = read;
|
|
151
|
+
if (mirror === void 0 || mirror.state !== "active") return void 0;
|
|
152
|
+
if (read.importing) return {
|
|
153
|
+
kind: "more",
|
|
154
|
+
at: (yield* core.now) + importWait
|
|
155
|
+
};
|
|
156
|
+
const opened = yield* openedFor(core, bound.caller, attempt.internalId);
|
|
157
|
+
const tip = opened?.refs.get(ref);
|
|
158
|
+
if (opened === void 0 || tip === void 0) return void 0;
|
|
159
|
+
const remote = yield* remoteOf(bound, mirror.destination, context.signal);
|
|
160
|
+
const http = httpOf(remote);
|
|
161
|
+
const upstream = yield* upstreamOf(http);
|
|
162
|
+
if (upstream.kind === "refused") return yield* paused(attempt, read.version, mirror, "refused");
|
|
163
|
+
const from = upstream.refs.refs.get(ref) ?? null;
|
|
164
|
+
if (from === tip) return void 0;
|
|
165
|
+
const edit = {
|
|
166
|
+
ref,
|
|
167
|
+
from,
|
|
168
|
+
to: tip
|
|
169
|
+
};
|
|
170
|
+
if (from !== null && !(yield* goesOn(core, opened.listed, edit))) return yield* paused(attempt, read.version, mirror, "diverged");
|
|
171
|
+
const source = {
|
|
172
|
+
objects: effectObjects(syncObjects(core)),
|
|
173
|
+
listed: opened.listed,
|
|
174
|
+
limits: core.fetchLimits
|
|
175
|
+
};
|
|
176
|
+
const pushed = yield* Effect.result(sendPush(http, source, upstream.refs, [edit], {}));
|
|
177
|
+
if (Result.isFailure(pushed)) {
|
|
178
|
+
const { failure } = pushed;
|
|
179
|
+
if (!refusedCodes.has(failure.code)) return yield* Effect.fail(fromRemote("take a push")(failure));
|
|
180
|
+
return yield* paused(attempt, read.version, mirror, "refused");
|
|
181
|
+
}
|
|
182
|
+
const [update] = pushed.success.updates;
|
|
183
|
+
if (update?.kind === "applied") return void 0;
|
|
184
|
+
return yield* refusedPush(attempt, read.version, mirror, http, upstream.refs, ref);
|
|
185
|
+
});
|
|
186
|
+
/** A refused push: stale when the upstream's tip has moved since it was read, so read again. */
|
|
187
|
+
const refusedPush = Effect.fnUntraced(function* (attempt, version, mirror, http, first, ref) {
|
|
188
|
+
const reread = yield* upstreamOf(http);
|
|
189
|
+
if (reread.kind === "read" && reread.refs.refs.get(ref) !== first.refs.get(ref)) return again;
|
|
190
|
+
return yield* paused(attempt, version, mirror, "refused");
|
|
191
|
+
});
|
|
192
|
+
/** `git.sync.mirror`'s handler over `bound`: one try, its failure thrown as `SyncTryError`. */
|
|
193
|
+
const mirrorTry = (bound) => (job, context) => {
|
|
194
|
+
const attempt = {
|
|
195
|
+
bound,
|
|
196
|
+
core: {
|
|
197
|
+
...bound.host,
|
|
198
|
+
store: context.store
|
|
199
|
+
},
|
|
200
|
+
internalId: jobRepo(job),
|
|
201
|
+
ref: job.data.ref,
|
|
202
|
+
context
|
|
203
|
+
};
|
|
204
|
+
return runTry(mirrorStep(attempt), context.signal);
|
|
205
|
+
};
|
|
206
|
+
/** `mirrors`: each of the repo's mirror rows, by ref, once the caller may read the repo. */
|
|
207
|
+
const mirrorsWith = Effect.fnUntraced(function* (input) {
|
|
208
|
+
const bound = yield* boundOf(input.git);
|
|
209
|
+
const caller = { actor: input.actor };
|
|
210
|
+
const operation = {
|
|
211
|
+
kind: "read",
|
|
212
|
+
repo: input.repo
|
|
213
|
+
};
|
|
214
|
+
const { snapshot } = yield* openRepo(bound.core, caller, operation, [mirrorsRead], input.internalId);
|
|
215
|
+
const [, rows = []] = snapshot.results;
|
|
216
|
+
const states = [];
|
|
217
|
+
for (const row of rows) {
|
|
218
|
+
const mirror = yield* decodeRow(MirrorRow, row, `Mirror '${row.id}'`);
|
|
219
|
+
states.push(stateOf(input.repo, row.id, mirror));
|
|
220
|
+
}
|
|
221
|
+
return states;
|
|
222
|
+
});
|
|
223
|
+
/** The repo's mirrors and their states; `Mirrors` says how. */
|
|
224
|
+
const mirrors = (input) => resultIn(mirrorsWith(input), uncounted("a host's sync call: no Git request"), input.signal);
|
|
225
|
+
/** Saves the repo's mirror of `ref` and pushes it now; `Mirror` says how. */
|
|
226
|
+
const mirror = (input) => resultIn(mirrorWith(input), uncounted("a host's sync call: no Git request"), input.signal);
|
|
227
|
+
export { mirror, mirrorTry, mirrorWith, mirrors, mirrorsWith };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Result } from "../contracts/result.mjs";
|
|
2
|
+
import { SyncPublishInput } from "../contracts/sync.mjs";
|
|
3
|
+
import "effect/Effect";
|
|
4
|
+
/** Moves an import's staging refs to their names; `PublishImported` says how. */
|
|
5
|
+
export declare const publishImported: (input: SyncPublishInput) => Promise<Result<void>>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { openRepo } from "../core/access.mjs";
|
|
2
|
+
import { isRefName } from "../core/names.mjs";
|
|
3
|
+
import { push } from "../core/push.mjs";
|
|
4
|
+
import { isOid } from "../protocol/bytes/text.mjs";
|
|
5
|
+
import { gitsOwnMove, hiddenUnder } from "../protocol/wire/lines.mjs";
|
|
6
|
+
import { resultIn, uncounted } from "../store/crossing.mjs";
|
|
7
|
+
import { fail, gitError } from "../store/errors.mjs";
|
|
8
|
+
import { wholeRefs } from "../store/ref-rows.mjs";
|
|
9
|
+
import { collections } from "../store/scopes.mjs";
|
|
10
|
+
import { boundOf } from "./bound.mjs";
|
|
11
|
+
import "./step.mjs";
|
|
12
|
+
import { syncWhole } from "./tries.mjs";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
// src/sync/publish.ts
|
|
15
|
+
/** Whether `ref` is an import's staging ref, which only `source: 'import'` writes. */
|
|
16
|
+
const isStaging = (ref) => gitsOwnMove("import", ref);
|
|
17
|
+
const refsRead = { collection: collections.refs };
|
|
18
|
+
/** The first reason `moves` can't be sent, as `INVALID_ARGUMENT`. */
|
|
19
|
+
const refusedMoves = (moves) => {
|
|
20
|
+
const froms = /* @__PURE__ */ new Set();
|
|
21
|
+
const tos = /* @__PURE__ */ new Set();
|
|
22
|
+
for (const move of moves) {
|
|
23
|
+
const { from, oid } = move;
|
|
24
|
+
if (!isRefName(from) || !isStaging(from)) return `'${from}' isn't a staging ref under refs/import/`;
|
|
25
|
+
if (!isOid(oid)) return `'${oid}' isn't an object ID`;
|
|
26
|
+
if (froms.has(from)) return `Two moves name '${from}'`;
|
|
27
|
+
froms.add(from);
|
|
28
|
+
if (move.to === null) continue;
|
|
29
|
+
const { to, at } = move;
|
|
30
|
+
if (!isRefName(to)) return `'${to}' isn't a full ref name`;
|
|
31
|
+
if (at !== null && !isOid(at)) return `'${at}' isn't an object ID`;
|
|
32
|
+
if (hiddenUnder(to) !== void 0) return `'${to}' is Git's own: no import publishes to it`;
|
|
33
|
+
if (tos.has(to)) return `Two moves write '${to}'`;
|
|
34
|
+
tos.add(to);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/** An oid as a refusal names it, or `nothing` for a ref that isn't there. */
|
|
38
|
+
const tipText = (oid) => oid ?? "nothing";
|
|
39
|
+
/** A move's `to` found away from its `at`: another writer moved it since the caller read it. */
|
|
40
|
+
const movedTo = (to, at, found) => gitError("FAILED_PRECONDITION", `'${to}' is at ${tipText(found)}, not ${tipText(at)}`, {
|
|
41
|
+
hint: "Read the ref again: another write moved it",
|
|
42
|
+
context: {
|
|
43
|
+
reason: "ref-conflict",
|
|
44
|
+
ref: to,
|
|
45
|
+
expected: tipText(at),
|
|
46
|
+
found: tipText(found)
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
/** The first write in `moves` whose `to` isn't at its `at` in `refs`, and isn't at its `oid`. */
|
|
50
|
+
const firstMoved = (moves, refs) => {
|
|
51
|
+
for (const move of moves) {
|
|
52
|
+
if (move.to === null) continue;
|
|
53
|
+
const found = refs.get(move.to) ?? null;
|
|
54
|
+
if (found !== move.at && found !== move.oid) return movedTo(move.to, move.at, found);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* `publishImported`: each move's edits against the refs as they are, through the host's core,
|
|
59
|
+
* which skips `authorize` as host calls do: push rules and limits still apply, and `actor` is who
|
|
60
|
+
* the events name. A move whose `from` is gone is done when its `to` is `null` or already at
|
|
61
|
+
* `oid`, as when its answer was lost; that's read before `at`.
|
|
62
|
+
*/
|
|
63
|
+
const publishWith = Effect.fnUntraced(function* (input) {
|
|
64
|
+
const bound = yield* boundOf(input.git);
|
|
65
|
+
const refused = refusedMoves(input.moves);
|
|
66
|
+
if (refused !== void 0) return yield* fail("INVALID_ARGUMENT", refused);
|
|
67
|
+
const caller = { actor: input.actor };
|
|
68
|
+
const operation = {
|
|
69
|
+
kind: "read",
|
|
70
|
+
repo: input.repo
|
|
71
|
+
};
|
|
72
|
+
const refsNow = Effect.fnUntraced(function* () {
|
|
73
|
+
const { snapshot } = yield* openRepo(bound.host, caller, operation, [refsRead], input.internalId);
|
|
74
|
+
return yield* wholeRefs(syncWhole, snapshot.results[1] ?? []);
|
|
75
|
+
});
|
|
76
|
+
const refs = yield* refsNow();
|
|
77
|
+
const edits = [];
|
|
78
|
+
for (const move of input.moves) {
|
|
79
|
+
const { from, oid, to } = move;
|
|
80
|
+
const staged = refs.get(from);
|
|
81
|
+
const found = to === null ? null : refs.get(to) ?? null;
|
|
82
|
+
if (staged === void 0) {
|
|
83
|
+
if (to === null || found === oid) continue;
|
|
84
|
+
return yield* fail("FAILED_PRECONDITION", `'${from}' is gone, and '${to}' isn't at ${oid}`, { hint: "Read the refs again, and move what is staged now" });
|
|
85
|
+
}
|
|
86
|
+
if (staged !== oid) return yield* fail("FAILED_PRECONDITION", `'${from}' is at ${staged}, not ${oid}`, { hint: "Read the refs again, and move what is staged now" });
|
|
87
|
+
edits.push({
|
|
88
|
+
ref: from,
|
|
89
|
+
from: oid,
|
|
90
|
+
to: null
|
|
91
|
+
});
|
|
92
|
+
if (move.to === null || found === oid) continue;
|
|
93
|
+
if (found !== move.at) return yield* Effect.fail(movedTo(move.to, move.at, found));
|
|
94
|
+
edits.push({
|
|
95
|
+
ref: move.to,
|
|
96
|
+
from: move.at,
|
|
97
|
+
to: oid
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (edits.length === 0) return;
|
|
101
|
+
const movedOr = (error) => Effect.flatMap(refsNow(), (now) => Effect.fail(firstMoved(input.moves, now) ?? error));
|
|
102
|
+
const request = {
|
|
103
|
+
caller,
|
|
104
|
+
repo: input.repo,
|
|
105
|
+
source: "import",
|
|
106
|
+
edits,
|
|
107
|
+
atomic: true
|
|
108
|
+
};
|
|
109
|
+
if (input.internalId !== void 0) request.internalId = input.internalId;
|
|
110
|
+
const rejected = (yield* push(bound.host, request).pipe(Effect.catchIf((error) => error.context?.reason === "changed-while-checked", movedOr))).updates.flatMap((update) => update.kind === "rejected" ? [update] : []);
|
|
111
|
+
const [first] = rejected;
|
|
112
|
+
if (first === void 0) return;
|
|
113
|
+
return yield* movedOr((rejected.find((update) => update.error.message !== "atomic transaction failed") ?? first).error);
|
|
114
|
+
});
|
|
115
|
+
/** Moves an import's staging refs to their names; `PublishImported` says how. */
|
|
116
|
+
const publishImported = (input) => resultIn(publishWith(input), uncounted("a host's sync call: no Git request"), input.signal);
|
|
117
|
+
export { publishImported, publishWith };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { KeptError } from "../core/receipts.mjs";
|
|
2
|
+
import { decodeRow, storeCall } from "../store/errors.mjs";
|
|
3
|
+
import { collections, repoScope } from "../store/scopes.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
// src/sync/records.ts
|
|
7
|
+
/**
|
|
8
|
+
* An import's own record, `imports/self` in its repo's scope, written by the create that starts it
|
|
9
|
+
* and by each step's commit, so a try after a crash goes on from the last step that landed:
|
|
10
|
+
* - `tips`: the remote's branches and tags as the import's first step listed them, each moved
|
|
11
|
+
* to its tip by the last step, `publish`;
|
|
12
|
+
* - `roots`: where the history copied so far stops, the remote's `shallow` lines; `deepest`, how
|
|
13
|
+
* many commits from each tip it holds; `step`, how many more the next segment asks for;
|
|
14
|
+
* - `copied`: whether the history is whole, or as deep as `depth` asks, so the next step publishes;
|
|
15
|
+
* - `objects` and `bytes`: what the steps have received;
|
|
16
|
+
* - `error`: a failed import's last try's, which never carries a credential.
|
|
17
|
+
*/
|
|
18
|
+
const ImportRow = Schema.Struct({
|
|
19
|
+
source: Schema.Struct({
|
|
20
|
+
provider: Schema.String,
|
|
21
|
+
repo: Schema.String
|
|
22
|
+
}),
|
|
23
|
+
depth: Schema.optionalKey(Schema.Int),
|
|
24
|
+
state: Schema.Literals([
|
|
25
|
+
"running",
|
|
26
|
+
"done",
|
|
27
|
+
"failed"
|
|
28
|
+
]),
|
|
29
|
+
tips: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
|
|
30
|
+
roots: Schema.Array(Schema.String),
|
|
31
|
+
deepest: Schema.Int,
|
|
32
|
+
step: Schema.Int,
|
|
33
|
+
copied: Schema.Boolean,
|
|
34
|
+
objects: Schema.Int,
|
|
35
|
+
bytes: Schema.Int,
|
|
36
|
+
error: Schema.optionalKey(KeptError)
|
|
37
|
+
});
|
|
38
|
+
/** The import's own row. */
|
|
39
|
+
const importKey = {
|
|
40
|
+
collection: collections.imports,
|
|
41
|
+
id: "self"
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* `cancelImport`'s row, beside the import's: its own, so a step's commit, which writes the
|
|
45
|
+
* import's row, never writes over a cancel, and the step's read of both sees it.
|
|
46
|
+
*/
|
|
47
|
+
const cancelKey = {
|
|
48
|
+
collection: collections.imports,
|
|
49
|
+
id: "cancel"
|
|
50
|
+
};
|
|
51
|
+
const importRow = (value) => ({
|
|
52
|
+
...importKey,
|
|
53
|
+
value
|
|
54
|
+
});
|
|
55
|
+
/** `row` failed with `error`, kept without its `cause`, as a receipt keeps an error. */
|
|
56
|
+
const failedRow = (row, error) => ({
|
|
57
|
+
...row,
|
|
58
|
+
state: "failed",
|
|
59
|
+
error
|
|
60
|
+
});
|
|
61
|
+
/** A kept error as `GitError`, for `import` to answer. */
|
|
62
|
+
const heldError = (kept) => kept;
|
|
63
|
+
/** The repo's import row and cancel row, in one read. */
|
|
64
|
+
const readImport = Effect.fnUntraced(function* (store, internalId) {
|
|
65
|
+
const snapshot = yield* storeCall(() => store.read(repoScope(internalId), [{ ...importKey }, { ...cancelKey }]));
|
|
66
|
+
const [[own] = [], [cancel] = []] = snapshot.results;
|
|
67
|
+
return {
|
|
68
|
+
row: own === void 0 ? void 0 : yield* decodeRow(ImportRow, own, "Import"),
|
|
69
|
+
cancelled: cancel !== void 0,
|
|
70
|
+
version: snapshot.version
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
export { ImportRow, cancelKey, failedRow, heldError, importKey, importRow, readImport };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SyncProvider, SyncRemote } from "../contracts/sync.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Any smart HTTP remote under `url`: a source's `repo` is its path there, so
|
|
4
|
+
* `{ provider: 'smart-http', repo: 'pip/app.git' }` reaches `<url>/pip/app.git`, with the
|
|
5
|
+
* options' credentials and transport; a path that leaves `url` is refused. It has no webhooks:
|
|
6
|
+
* a mirror pushes after each move.
|
|
7
|
+
*/
|
|
8
|
+
export declare const smartHttp: (options: SyncRemote) => SyncProvider;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/sync/smart-http.ts
|
|
2
|
+
const smartHttpName = "smart-http";
|
|
3
|
+
/**
|
|
4
|
+
* Any smart HTTP remote under `url`: a source's `repo` is its path there, so
|
|
5
|
+
* `{ provider: 'smart-http', repo: 'pip/app.git' }` reaches `<url>/pip/app.git`, with the
|
|
6
|
+
* options' credentials and transport; a path that leaves `url` is refused. It has no webhooks:
|
|
7
|
+
* a mirror pushes after each move.
|
|
8
|
+
*/
|
|
9
|
+
const smartHttp = (options) => {
|
|
10
|
+
const base = new URL(options.url.endsWith("/") ? options.url : `${options.url}/`).href;
|
|
11
|
+
return {
|
|
12
|
+
name: smartHttpName,
|
|
13
|
+
remote: (repo) => {
|
|
14
|
+
const url = new URL(repo, base).href;
|
|
15
|
+
if (!url.startsWith(base) || repo.split("/").includes("..")) return Promise.reject(/* @__PURE__ */ new TypeError(`'${repo}' isn't a path under the provider's URL`));
|
|
16
|
+
return Promise.resolve({
|
|
17
|
+
...options,
|
|
18
|
+
url
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export { smartHttp, smartHttpName };
|