@ref0/git 0.4.0 → 0.6.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/access/private-refs.mjs +3 -4
- package/dist/auth/authorize.mjs +9 -4
- package/dist/auth/identify.d.mts +5 -3
- package/dist/auth/tokens.mjs +12 -11
- package/dist/client/local.mjs +2 -0
- package/dist/client/slice-push.d.mts +1 -1
- package/dist/contracts/access.d.mts +6 -2
- package/dist/contracts/authorize.d.mts +14 -10
- package/dist/contracts/events.d.mts +32 -5
- package/dist/contracts/events.mjs +14 -3
- package/dist/contracts/git.d.mts +68 -3
- package/dist/contracts/grants.d.mts +6 -1
- package/dist/contracts/lfs.d.mts +5 -2
- package/dist/contracts/objects.d.mts +7 -2
- package/dist/contracts/promises.d.mts +2 -14
- package/dist/contracts/push-uploads.d.mts +1 -1
- package/dist/contracts/queue.d.mts +15 -7
- package/dist/contracts/refs.d.mts +1 -1
- package/dist/contracts/result.d.mts +9 -5
- package/dist/contracts/result.mjs +5 -0
- package/dist/contracts/server.d.mts +13 -6
- package/dist/contracts/work.d.mts +1 -1
- package/dist/core/access.mjs +17 -1
- package/dist/core/call-names.d.mts +3 -1
- package/dist/core/claim-rows.d.mts +4 -0
- package/dist/core/claim-rows.mjs +53 -0
- package/dist/core/events/deliver.d.mts +12 -0
- package/dist/core/events/deliver.mjs +367 -145
- package/dist/core/events/seen.mjs +17 -3
- package/dist/core/forks.mjs +82 -20
- package/dist/core/hooks/post-receive.mjs +20 -17
- package/dist/core/index-job.mjs +23 -17
- package/dist/core/parts.d.mts +6 -0
- package/dist/core/purge.d.mts +8 -0
- package/dist/core/purge.mjs +16 -21
- package/dist/core/push-decide.mjs +26 -4
- package/dist/core/push.mjs +57 -20
- package/dist/core/ref-index-job.mjs +9 -14
- package/dist/core/ref-index.d.mts +1 -0
- package/dist/core/ref-index.mjs +28 -8
- package/dist/core/ref-view.mjs +14 -9
- package/dist/core/refs.mjs +13 -11
- package/dist/core/repack.d.mts +2 -1
- package/dist/core/repack.mjs +66 -118
- package/dist/core/repos.mjs +5 -5
- package/dist/core/rules/check.mjs +7 -6
- package/dist/core/rules/context.d.mts +1 -1
- package/dist/core/seam.d.mts +56 -9
- package/dist/core/seam.mjs +7 -1
- package/dist/core/still-takes.mjs +75 -0
- package/dist/core/view.d.mts +1 -0
- package/dist/core/view.mjs +8 -9
- package/dist/core/work.mjs +1 -1
- package/dist/extend.d.mts +2 -1
- package/dist/http/core-parts.mjs +19 -11
- package/dist/http/handler.mjs +2 -2
- package/dist/http/node.d.mts +2 -23
- package/dist/http/parts.d.mts +1 -0
- package/dist/http/push-uploads.d.mts +10 -2
- package/dist/http/push-uploads.mjs +31 -34
- package/dist/http/receive-pack.mjs +5 -3
- package/dist/http/upload-pack.mjs +2 -2
- package/dist/index.d.mts +11 -7
- package/dist/index.mjs +5 -3
- package/dist/lfs/base.d.mts +32 -0
- package/dist/lfs/base.mjs +8 -0
- package/dist/lfs/calls.mjs +21 -12
- package/dist/lfs/layer.d.mts +27 -0
- package/dist/lfs/layer.mjs +64 -0
- package/dist/lfs/locks.mjs +13 -27
- package/dist/lfs/namespace.d.mts +2 -0
- package/dist/lfs/objects.d.mts +23 -4
- package/dist/lfs/objects.mjs +65 -81
- package/dist/lfs/pointers.mjs +8 -6
- package/dist/lfs/public.d.mts +5 -0
- package/dist/lfs/public.mjs +8 -0
- package/dist/lfs/purge.mjs +19 -25
- package/dist/lfs/rows.mjs +22 -10
- package/dist/lfs/service.d.mts +9 -4
- package/dist/lfs/service.mjs +3 -12
- package/dist/lfs/upkeep.mjs +34 -49
- package/dist/node.d.mts +3 -2
- package/dist/node.mjs +1 -1
- package/dist/protocol/wire/advertisement.d.mts +4 -10
- package/dist/protocol/wire/advertisement.mjs +16 -12
- package/dist/protocol/wire/lines.d.mts +14 -2
- package/dist/protocol/wire/lines.mjs +32 -21
- package/dist/protocol/wire/v2.d.mts +4 -15
- package/dist/protocol/wire/v2.mjs +16 -14
- package/dist/queue/advance.mjs +78 -55
- package/dist/queue/calls.mjs +4 -2
- package/dist/queue/commit.mjs +20 -13
- package/dist/queue/host.d.mts +2 -2
- package/dist/queue/layer.d.mts +4 -2
- package/dist/queue/layer.mjs +8 -3
- package/dist/queue/limits.mjs +36 -6
- package/dist/queue/rows.mjs +14 -5
- package/dist/queue/state.mjs +19 -5
- package/dist/queue/steps.mjs +10 -4
- package/dist/queue/trim.mjs +284 -0
- package/dist/rest/blobs.d.mts +19 -19
- package/dist/rest/caller.d.mts +4 -4
- package/dist/rest/commits.d.mts +96 -96
- package/dist/rest/errors.d.mts +2 -2
- package/dist/rest/events.d.mts +2 -2
- package/dist/rest/files.d.mts +54 -54
- package/dist/rest/forks.d.mts +87 -87
- package/dist/rest/handler.mjs +13 -5
- package/dist/rest/layer.d.mts +14 -0
- package/dist/rest/layer.mjs +52 -0
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +2 -2
- package/dist/rest/namespace.d.mts +2 -0
- package/dist/rest/queue.d.mts +208 -208
- package/dist/rest/refs.d.mts +131 -131
- package/dist/rest/repos.d.mts +12 -12
- package/dist/rest/tags.d.mts +70 -70
- package/dist/rest/tokens.d.mts +23 -23
- package/dist/rest/topics.d.mts +111 -111
- package/dist/rest/trees.d.mts +57 -57
- package/dist/rest/wire.d.mts +2 -0
- package/dist/rest/wire.mjs +2 -2
- package/dist/rest/work.d.mts +6 -6
- package/dist/server/edge-node.d.mts +20 -0
- package/dist/server/edge-node.mjs +20 -0
- package/dist/server/edge.d.mts +10 -0
- package/dist/server/edge.mjs +23 -0
- package/dist/server/extension.mjs +1 -1
- package/dist/server/git-layer.d.mts +15 -4
- package/dist/server/git-layer.mjs +13 -2
- package/dist/server/git-namespace.d.mts +5 -4
- package/dist/server/git-namespace.mjs +6 -3
- package/dist/server/registry.d.mts +3 -0
- package/dist/server/registry.mjs +58 -7
- package/dist/server/server.d.mts +3 -0
- package/dist/server/server.mjs +81 -39
- package/dist/server/uploads.d.mts +14 -0
- package/dist/server/uploads.mjs +15 -0
- package/dist/storage/calls.d.mts +7 -8
- package/dist/storage/calls.mjs +14 -14
- package/dist/storage/clean-up.mjs +59 -29
- package/dist/storage/host-bucket.mjs +16 -1
- package/dist/storage/index-build.d.mts +1 -1
- package/dist/storage/layout.mjs +5 -0
- package/dist/storage/merge.d.mts +1 -1
- package/dist/storage/push-uploads.mjs +12 -16
- package/dist/storage/quarantine.d.mts +1 -1
- package/dist/storage/quarantine.mjs +51 -12
- package/dist/storage/receive-bounds.d.mts +1 -1
- package/dist/storage/repack-job.d.mts +1 -1
- package/dist/storage/repack-job.mjs +7 -14
- package/dist/storage/rows.mjs +42 -3
- package/dist/storage/runs.d.mts +1 -1
- package/dist/store/job-try.mjs +26 -0
- package/dist/store/list-job.mjs +22 -16
- package/dist/store/outbox.mjs +38 -12
- package/dist/store/promises.d.mts +6 -1
- package/dist/store/promises.mjs +74 -89
- package/dist/store/queue-jobs.mjs +22 -1
- package/dist/store/scopes.mjs +0 -10
- package/dist/sync/mirror.d.mts +1 -1
- package/dist/sync/mirror.mjs +1 -1
- package/dist/sync/publish.mjs +12 -7
- package/dist/sync/step.mjs +4 -0
- package/package.json +3 -3
- package/dist/lfs/repo.mjs +0 -42
- package/dist/storage/promise-calls.mjs +0 -29
|
@@ -94,12 +94,25 @@ const knownParts = (events, known) => {
|
|
|
94
94
|
return parts;
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
97
|
+
* `event` as the event stream sends it: as every reader gets it, less the push's `options`, which
|
|
98
|
+
* Git hands only to its server's hooks, so only the host's handler gets them.
|
|
99
|
+
*/
|
|
100
|
+
const streamedEvent = (event) => {
|
|
101
|
+
const shown = shownEvent(event);
|
|
102
|
+
if (shown.type !== "ref.updated" || shown.push.options === void 0) return shown;
|
|
103
|
+
const { options: _, ...push } = shown.push;
|
|
104
|
+
return {
|
|
105
|
+
...shown,
|
|
106
|
+
push
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
97
110
|
* `event` as a caller with `refView` gets it: a push counts only the branches and tags it sees, less
|
|
98
111
|
* the parts of the patterns it doesn't read. When retention took the write's first event, whose
|
|
99
112
|
* parts `parts` then lacks, it counts only those of no pattern, less every pattern's.
|
|
100
113
|
*/
|
|
101
114
|
const seenEvent = (refView, event, parts) => {
|
|
102
|
-
const shown =
|
|
115
|
+
const shown = streamedEvent(event);
|
|
103
116
|
if (shown.type !== "ref.updated" || event.type !== "ref.updated") return shown;
|
|
104
117
|
const { id, hidden, hiddenTotal } = event.push;
|
|
105
118
|
const known = hidden ?? parts.get(id);
|
|
@@ -118,7 +131,8 @@ const seenEvent = (refView, event, parts) => {
|
|
|
118
131
|
/**
|
|
119
132
|
* The events of `events` a caller with `refView` sees, as it gets them: none naming a ref it doesn't
|
|
120
133
|
* see, as `seesEvent` says, and each push's counts its own, as `seenEvent` says, from the parts
|
|
121
|
-
* of each write in `parts`. A whole caller gets every event, with the write's whole counts.
|
|
134
|
+
* of each write in `parts`. A whole caller gets every event, with the write's whole counts. No
|
|
135
|
+
* caller gets a push's options, as `streamedEvent` says.
|
|
122
136
|
*/
|
|
123
|
-
const seenEvents = (events, refView, parts) => refView.whole ? events.map(
|
|
137
|
+
const seenEvents = (events, refView, parts) => refView.whole ? events.map(streamedEvent) : events.flatMap((event) => seesEvent(refView, event) ? [seenEvent(refView, event, parts)] : []);
|
|
124
138
|
export { knownParts, partsToRead, pushCounts, seenEvents };
|
package/dist/core/forks.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { noLfsPointers } from "../storage/lfs-pointers.mjs";
|
|
|
6
6
|
import { holdingsOf, swapsOf } from "../storage/repack.mjs";
|
|
7
7
|
import { SwapsSettled, holdingKey, swapsKey } from "../storage/swap-walk.mjs";
|
|
8
8
|
import { ApartRow, apartAfter, apartKey } from "../storage/repack-contained.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { coverRow, decodeLeft, leavingKey, leavingLate, leavingRow, pruneFloor } from "../storage/rows.mjs";
|
|
10
10
|
import { entryOf, forkOf, forksCreated, heldNameAt, isCreatedKey, listLimit, namedRecordOf, reconcile } from "../store/catalogue.mjs";
|
|
11
11
|
import { afterWrites, decodeRow, storeCall } from "../store/errors.mjs";
|
|
12
12
|
import { decodePacks, packRow } from "../store/git-store.mjs";
|
|
@@ -24,6 +24,7 @@ import { infoReads, repoInfo } from "./repo-info.mjs";
|
|
|
24
24
|
import { kindsOf } from "./ancestry.mjs";
|
|
25
25
|
import { isHolder } from "./names.mjs";
|
|
26
26
|
import { decidePush } from "./push-decide.mjs";
|
|
27
|
+
import { gitsOwnRef } from "./rules/check.mjs";
|
|
27
28
|
import { refCopies } from "./ref-index.mjs";
|
|
28
29
|
import { heldReceipt, receiptKeys, receiptReads, receiptWrites, repoAnswer, withJobs } from "./receipts.mjs";
|
|
29
30
|
import { badRepoName, repoKept } from "./repos.mjs";
|
|
@@ -40,12 +41,13 @@ import * as Clock$1 from "effect/Clock";
|
|
|
40
41
|
* A fork copies every ref and object of its source, private or not, until piece 3 copies only
|
|
41
42
|
* what its caller sees: see `before-production.md`.
|
|
42
43
|
*/
|
|
43
|
-
const forkWhole = WholeRepo.mint();
|
|
44
|
+
const forkWhole = /* @__PURE__ */ WholeRepo.mint();
|
|
44
45
|
/** A fork's `index` row as `repoInfo` reads it, by its place after `statsReads`'. */
|
|
45
46
|
const indexRowsOf = (rows) => rows.indexRow === void 0 ? [] : [rows.indexRow];
|
|
46
47
|
const refsRead = { collection: collections.refs };
|
|
47
48
|
const packsRead = { collection: collections.packs };
|
|
48
49
|
const leavingRead = { collection: objectCollections.leaving };
|
|
50
|
+
const coverRead = { collection: objectCollections.cover };
|
|
49
51
|
/**
|
|
50
52
|
* What a fork reads of its source, after its `self`: refs and packs. Its object rows are read
|
|
51
53
|
* apart, a page at a time, by `sourceRows`, and only by a copy.
|
|
@@ -117,10 +119,57 @@ const coverMarks = /* @__PURE__ */ Effect.fnUntraced(function* (into, packs, rem
|
|
|
117
119
|
yield* Effect.forEach(put, alone, { discard: true });
|
|
118
120
|
});
|
|
119
121
|
/**
|
|
122
|
+
* Adds, outside the version, a `cover` row in `into`'s scope for each of `packs`, due at
|
|
123
|
+
* `removeAt`, with `git.repack` due then, under a try of its own: a marker a reread found unheld,
|
|
124
|
+
* which the fork's clean-up then lets go as a `leaving` row's (#1582). The row holds the marker,
|
|
125
|
+
* never the try, so the try never deletes it.
|
|
126
|
+
*/
|
|
127
|
+
const coverLost = /* @__PURE__ */ Effect.fnUntraced(function* (into, packs, removeAt) {
|
|
128
|
+
const core = yield* CoreParts;
|
|
129
|
+
const tried = newChangeId();
|
|
130
|
+
const put = packs.flatMap(({ id, ...size }) => isPackId(id) ? [coverRow({
|
|
131
|
+
id,
|
|
132
|
+
...size
|
|
133
|
+
}, tried, removeAt)] : []);
|
|
134
|
+
if (put.length === 0) return;
|
|
135
|
+
const jobs = [core.repackJobRow(removeAt)];
|
|
136
|
+
yield* storeCall(() => core.store.add(repoScope(into), {
|
|
137
|
+
put,
|
|
138
|
+
jobs
|
|
139
|
+
}));
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* Of `packs`, just marked for `into`, those whose marker no row of `into` holds now: the fork
|
|
143
|
+
* doesn't list the pack, and its `leaving` row is gone or taken. Clean-up took or ended that row
|
|
144
|
+
* before the marker may have landed, so its end may have missed the marker (#1582).
|
|
145
|
+
*/
|
|
146
|
+
const unheldOf = /* @__PURE__ */ Effect.fnUntraced(function* (into, packs) {
|
|
147
|
+
const core = yield* CoreParts;
|
|
148
|
+
const named = packs.filter(({ id }) => isPackId(id));
|
|
149
|
+
if (named.length === 0) return [];
|
|
150
|
+
const reads = named.flatMap(({ id }) => [{
|
|
151
|
+
collection: collections.packs,
|
|
152
|
+
id
|
|
153
|
+
}, {
|
|
154
|
+
collection: objectCollections.leaving,
|
|
155
|
+
id
|
|
156
|
+
}]);
|
|
157
|
+
const snapshot = yield* storeCall(() => core.store.read(repoScope(into), reads));
|
|
158
|
+
const unheld = [];
|
|
159
|
+
for (const [index, pack] of named.entries()) {
|
|
160
|
+
const listed = (snapshot.results[2 * index]?.length ?? 0) > 0;
|
|
161
|
+
const row = snapshot.results[2 * index + 1]?.[0];
|
|
162
|
+
const left = row === void 0 ? void 0 : yield* decodeLeft(row);
|
|
163
|
+
if (!listed && (left === void 0 || left.value.taken === true)) unheld.push(pack);
|
|
164
|
+
}
|
|
165
|
+
return unheld;
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
120
168
|
* Puts a marker named `into` on each pack the source lists that `marked` doesn't hold, then reads
|
|
121
169
|
* the source again, until a read lists no pack without one: that read is the one a fork commits,
|
|
122
170
|
* so no pack it lists can lose its bytes to the source's upkeep between the read and the commit.
|
|
123
|
-
* `cover` adds each pack's `leaving` row before its marker.
|
|
171
|
+
* `cover` adds each pack's `leaving` row before its marker. After each share, the rows are read
|
|
172
|
+
* again: a marker none holds gets a `cover` row and the call fails, keeping the marker (#1582).
|
|
124
173
|
*/
|
|
125
174
|
const markPacks = /* @__PURE__ */ Effect.fnUntraced(function* (first, into, marked, cover, signal) {
|
|
126
175
|
const core = yield* CoreParts;
|
|
@@ -131,7 +180,7 @@ const markPacks = /* @__PURE__ */ Effect.fnUntraced(function* (first, into, mark
|
|
|
131
180
|
const unmarked = read.listed.packs.filter((pack) => !marked.has(pack.id));
|
|
132
181
|
if (unmarked.length === 0) return read;
|
|
133
182
|
for (const pack of unmarked) marked.set(pack.id, pack);
|
|
134
|
-
yield* cover(unmarked);
|
|
183
|
+
yield* cover.add(unmarked);
|
|
135
184
|
const share = signal === void 0 ? { into } : {
|
|
136
185
|
into,
|
|
137
186
|
signal
|
|
@@ -140,6 +189,8 @@ const markPacks = /* @__PURE__ */ Effect.fnUntraced(function* (first, into, mark
|
|
|
140
189
|
...read.listed,
|
|
141
190
|
packs: unmarked
|
|
142
191
|
}, share);
|
|
192
|
+
const unheld = yield* unheldOf(into, unmarked);
|
|
193
|
+
if (unheld.length > 0) return yield* cover.lost(unheld);
|
|
143
194
|
read = yield* forkRead(core.store, read.internalId);
|
|
144
195
|
}
|
|
145
196
|
return yield* contendedAfterWrites();
|
|
@@ -528,18 +579,21 @@ const forkCalls = (bound) => {
|
|
|
528
579
|
let taken;
|
|
529
580
|
const removeAt = at + Math.max(pruneFloor, fetchLimits.milliseconds);
|
|
530
581
|
let asideFirst = true;
|
|
531
|
-
const cover = (read) => (
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
582
|
+
const cover = (read) => ({
|
|
583
|
+
add: (packs) => {
|
|
584
|
+
const aside = {
|
|
585
|
+
...forkRecord(read, id, revision, holder, at, core.refIndex),
|
|
586
|
+
deleted: true
|
|
587
|
+
};
|
|
588
|
+
const first = asideFirst ? [{
|
|
589
|
+
...selfKey,
|
|
590
|
+
value: aside
|
|
591
|
+
}] : [];
|
|
592
|
+
asideFirst = false;
|
|
593
|
+
return coverMarks(internalId, packs, removeAt, first);
|
|
594
|
+
},
|
|
595
|
+
lost: (packs) => Effect.andThen(coverLost(internalId, packs, removeAt), () => cleaningUp(repo))
|
|
596
|
+
});
|
|
543
597
|
for (let attempt = 0; taken === void 0 && attempt < 5; attempt += 1) {
|
|
544
598
|
const first = yield* sourceSized(forkRead(store, source), caller, source, forkingName, gone);
|
|
545
599
|
yield* authorizeSource(caller, first, forking(first), gone);
|
|
@@ -757,6 +811,7 @@ const forkCalls = (bound) => {
|
|
|
757
811
|
const reads = [
|
|
758
812
|
...statsReads,
|
|
759
813
|
leavingRead,
|
|
814
|
+
coverRead,
|
|
760
815
|
indexRowKey,
|
|
761
816
|
apartKey,
|
|
762
817
|
swapsKey
|
|
@@ -776,7 +831,7 @@ const forkCalls = (bound) => {
|
|
|
776
831
|
repo: name
|
|
777
832
|
}), hiddenFork);
|
|
778
833
|
if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${fork}'`);
|
|
779
|
-
const [, refRows = [], packRows = [], timeRows = [], leavingRows = [], indexRows = [], apartRows = [], swapsRows = []] = snapshot.results;
|
|
834
|
+
const [, refRows = [], packRows = [], timeRows = [], leavingRows = [], coverRows = [], indexRows = [], apartRows = [], swapsRows = []] = snapshot.results;
|
|
780
835
|
const [headRows = [], cursorRows = [], ...afterOutbox] = snapshot.results.slice(1 + reads.length);
|
|
781
836
|
const keyed = receiptReads(kept).length;
|
|
782
837
|
yield* fence.check(afterOutbox.slice(keyed));
|
|
@@ -817,6 +872,7 @@ const forkCalls = (bound) => {
|
|
|
817
872
|
packRows,
|
|
818
873
|
timeRows,
|
|
819
874
|
leavingRows,
|
|
875
|
+
coverRows,
|
|
820
876
|
apartRows,
|
|
821
877
|
swapsRows,
|
|
822
878
|
indexRow: indexRows[0]
|
|
@@ -847,7 +903,7 @@ const forkCalls = (bound) => {
|
|
|
847
903
|
const copyInto = Effect.fnUntraced(function* (caller, fork, into, first, checked, signal) {
|
|
848
904
|
const { fetchLimits } = yield* ObjectsParts;
|
|
849
905
|
const { listing, rows, marked, shared } = into;
|
|
850
|
-
const held = yield* Effect.forEach(rows.leavingRows,
|
|
906
|
+
const held = yield* Effect.forEach([...rows.leavingRows, ...rows.coverRows], decodeLeft);
|
|
851
907
|
const relistedOf = (packs) => {
|
|
852
908
|
const ids = new Set(packs.flatMap(({ id }) => listing.has(id) ? [] : [id]));
|
|
853
909
|
return held.filter(({ pack }) => ids.has(pack));
|
|
@@ -859,7 +915,10 @@ const forkCalls = (bound) => {
|
|
|
859
915
|
const addedRows = first.packs.filter(({ id }) => !listing.has(id));
|
|
860
916
|
yield* checkCopy(first.name, [...firstRows, ...addedRows]);
|
|
861
917
|
const removeAt = into.at + Math.max(pruneFloor, fetchLimits.milliseconds);
|
|
862
|
-
const cover =
|
|
918
|
+
const cover = {
|
|
919
|
+
add: (packs) => coverMarks(into.internalId, packs, removeAt),
|
|
920
|
+
lost: (packs) => Effect.andThen(coverLost(into.internalId, packs, removeAt), () => cleaningUp(fork))
|
|
921
|
+
};
|
|
863
922
|
const readingName = (name) => ({
|
|
864
923
|
kind: "read",
|
|
865
924
|
repo: name
|
|
@@ -919,7 +978,7 @@ const forkCalls = (bound) => {
|
|
|
919
978
|
...apartAfter(found, { remove }),
|
|
920
979
|
...swapsAfter(/* @__PURE__ */ new Set([...kept, ...source.listed.packs.map(({ id }) => id)]), swapsBefore, into.walks)
|
|
921
980
|
],
|
|
922
|
-
delete: added.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : [])
|
|
981
|
+
delete: [...added.flatMap(({ id }) => isPackId(id) ? [leavingKey(id)] : []), ...held.flatMap(({ key, pack }) => key.collection === objectCollections.cover && adding.has(pack) ? [key] : [])]
|
|
923
982
|
},
|
|
924
983
|
bytes: added.reduce((sum, pack) => sum + pack.bytes, 0),
|
|
925
984
|
objects: added.reduce((sum, pack) => sum + pack.objects, 0),
|
|
@@ -1002,6 +1061,8 @@ const forkCalls = (bound) => {
|
|
|
1002
1061
|
if (info !== void 0) return info;
|
|
1003
1062
|
continue;
|
|
1004
1063
|
}
|
|
1064
|
+
const gitsOwn = gitsOwnRef(core.hiddenRefs(), head, void 0);
|
|
1065
|
+
if (gitsOwn !== void 0) return yield* Effect.fail(gitsOwn);
|
|
1005
1066
|
const edits = [{
|
|
1006
1067
|
ref: head,
|
|
1007
1068
|
from,
|
|
@@ -1094,6 +1155,7 @@ const forkCalls = (bound) => {
|
|
|
1094
1155
|
type: "ref.updated",
|
|
1095
1156
|
...repoEnvelope(caller, name),
|
|
1096
1157
|
...move,
|
|
1158
|
+
kind,
|
|
1097
1159
|
push: {
|
|
1098
1160
|
id: write,
|
|
1099
1161
|
...pushCounts(core.access, decision.moved),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { millis } from "../../contracts/promises.mjs";
|
|
2
2
|
import { gitError } from "../../contracts/result.mjs";
|
|
3
3
|
import { decodeRow, storeCall } from "../../store/errors.mjs";
|
|
4
|
-
import { runJobTry } from "../../store/crossing.mjs";
|
|
5
4
|
import { cursorId } from "../../store/outbox.mjs";
|
|
6
5
|
import { versionId } from "../../store/records.mjs";
|
|
6
|
+
import { madeJob, settledCall } from "../../store/job-try.mjs";
|
|
7
7
|
import { collections, newChangeId } from "../../store/scopes.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { CurrentJob, Job } from "@ref0/infra";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
10
|
import * as Effect from "effect/Effect";
|
|
11
11
|
import * as Predicate from "effect/Predicate";
|
|
@@ -166,14 +166,17 @@ const inputOf = (push, attempt, signal) => {
|
|
|
166
166
|
* took it, the cursor moves past it, in a row the try's claim fences, so a stale try moves
|
|
167
167
|
* nothing. A crash between the two hands that one push again, and no other. Drained, the try trims.
|
|
168
168
|
*/
|
|
169
|
-
const postReceiveHandler = (handler) =>
|
|
170
|
-
const
|
|
169
|
+
const postReceiveHandler = (handler) => Effect.fnUntraced(function* () {
|
|
170
|
+
const job = yield* CurrentJob.current;
|
|
171
|
+
const store = yield* CurrentJob.store;
|
|
172
|
+
const signal = yield* CurrentJob.signal;
|
|
173
|
+
const prepared = yield* prepare(job, store);
|
|
171
174
|
if (prepared.kind === "settle") return prepared.outcome;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
yield* Effect.sync(() => signal.throwIfAborted());
|
|
176
|
+
yield* settledCall(async () => handler(inputOf(prepared.push, job.attempt, signal)));
|
|
177
|
+
yield* advance(store, job.scope, prepared.version);
|
|
175
178
|
return { kind: "more" };
|
|
176
|
-
};
|
|
179
|
+
});
|
|
177
180
|
/** The host's `postReceive`, as one shape. */
|
|
178
181
|
const postReceiveOptions = (hook) => Predicate.isFunction(hook) ? { handler: hook } : hook;
|
|
179
182
|
/**
|
|
@@ -193,15 +196,15 @@ const checkPostReceiveTimeout = (hook) => {
|
|
|
193
196
|
const postReceiveJob = (hook, onFailure) => {
|
|
194
197
|
const { handler, retry, timeout } = postReceiveOptions(hook);
|
|
195
198
|
checkPostReceiveTimeout(hook);
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
retry: retry ?? defaultPostReceiveRetry,
|
|
200
|
-
handler: postReceiveHandler(handler)
|
|
199
|
+
const policy = {
|
|
200
|
+
payload: PostReceiveData,
|
|
201
|
+
retry: retry ?? defaultPostReceiveRetry
|
|
201
202
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
const PostReceiveJob = Job.make(postReceiveJobName, timeout === void 0 ? policy : {
|
|
204
|
+
...policy,
|
|
205
|
+
timeout: millis(timeout)
|
|
206
|
+
});
|
|
207
|
+
const definition = madeJob(PostReceiveJob.definition(postReceiveHandler(handler), onFailure === void 0 ? {} : { onFailure }));
|
|
205
208
|
return {
|
|
206
209
|
definition,
|
|
207
210
|
jobRow: () => definition.job({
|
|
@@ -210,4 +213,4 @@ const postReceiveJob = (hook, onFailure) => {
|
|
|
210
213
|
})
|
|
211
214
|
};
|
|
212
215
|
};
|
|
213
|
-
export { SavedPush, checkPostReceiveTimeout, defaultPostReceiveRetry,
|
|
216
|
+
export { SavedPush, checkPostReceiveTimeout, defaultPostReceiveRetry, postReceiveJob, postReceiveJobKey, postReceiveJobName, savedPushRow };
|
package/dist/core/index-job.mjs
CHANGED
|
@@ -2,19 +2,18 @@ import { indexRowOf } from "../storage/index-build.mjs";
|
|
|
2
2
|
import { liftsHolds } from "../storage/index-remap.mjs";
|
|
3
3
|
import { indexRowKey } from "../storage/layout.mjs";
|
|
4
4
|
import { resultCall, storeCall } from "../store/errors.mjs";
|
|
5
|
-
import { runJobTry } from "../store/crossing.mjs";
|
|
6
5
|
import { decodePacks } from "../store/git-store.mjs";
|
|
7
6
|
import { appendEvents, decodeOutbox, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
8
7
|
import { WholeRepo, wholeRefs } from "../store/ref-rows.mjs";
|
|
9
8
|
import { readRecord } from "../store/repo-record.mjs";
|
|
9
|
+
import { madeJob } from "../store/job-try.mjs";
|
|
10
10
|
import { collections, jobRepo, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
11
11
|
import { settleName } from "../store/settle.mjs";
|
|
12
12
|
import { SealedObjects } from "./view.mjs";
|
|
13
13
|
import { fail } from "../contracts/result.mjs";
|
|
14
|
-
import {
|
|
14
|
+
import { CurrentJob, Job } from "@ref0/infra";
|
|
15
15
|
import * as Schema from "effect/Schema";
|
|
16
16
|
import * as Effect from "effect/Effect";
|
|
17
|
-
import * as Option from "effect/Option";
|
|
18
17
|
import * as DateTime from "effect/DateTime";
|
|
19
18
|
// src/core/index-job.ts
|
|
20
19
|
/**
|
|
@@ -46,8 +45,6 @@ const roundOf = (key) => {
|
|
|
46
45
|
const round = Number(key.slice(6));
|
|
47
46
|
return Number.isSafeInteger(round) && round > 0 ? round : 0;
|
|
48
47
|
};
|
|
49
|
-
const indexJobSchema = /* @__PURE__ */ Schema.toStandardSchemaV1(IndexJobData);
|
|
50
|
-
const decodeIndexJobData = /* @__PURE__ */ Schema.decodeUnknownOption(IndexJobData);
|
|
51
48
|
/**
|
|
52
49
|
* The build reads every ref, private or not: its index answers for the repo's objects, as upkeep
|
|
53
50
|
* keeps them, whoever fetches.
|
|
@@ -218,10 +215,14 @@ const readTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, inter
|
|
|
218
215
|
/** `indexAttempt`, as the queue takes it. */
|
|
219
216
|
const indexTry = (...args) => Effect.map(indexAttempt(...args), (attempt) => attempt.next);
|
|
220
217
|
/** `git.index`'s try, in the repo's scope: a step of the build, or past its tries, the refusal. */
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
const indexStep = (parts) => (data) => Effect.flatMap(Effect.all([
|
|
219
|
+
CurrentJob.current,
|
|
220
|
+
CurrentJob.store,
|
|
221
|
+
CurrentJob.signal
|
|
222
|
+
]), ([job, store, signal]) => job.attempt > 20 ? refusalTry(parts, job, {
|
|
223
|
+
store,
|
|
224
|
+
signal
|
|
225
|
+
}, data, spentReason(lastOf(job))) : indexTry(parts, store, jobRepo(job), data, signal, roundOf(job.key)));
|
|
225
226
|
/** How the build's last try ended, as the first refusal try's claim says: later ones can't. */
|
|
226
227
|
const lastOf = (job) => {
|
|
227
228
|
if (job.attempt > 21) return "its refusal tried again";
|
|
@@ -260,7 +261,14 @@ const refusalTry = /* @__PURE__ */ Effect.fnUntraced(function* (parts, job, cont
|
|
|
260
261
|
* its failure logged. A round left failed with no refused row is one an operator's `retry` starts
|
|
261
262
|
* again, since no refusal stands for its try to prune against.
|
|
262
263
|
*/
|
|
263
|
-
const indexFailed = (parts) => (
|
|
264
|
+
const indexFailed = (parts) => (data, failure) => Effect.flatMap(Effect.all([
|
|
265
|
+
CurrentJob.current,
|
|
266
|
+
CurrentJob.store,
|
|
267
|
+
CurrentJob.signal
|
|
268
|
+
]), ([job, store, signal]) => Effect.catch(refusalTry(parts, job, {
|
|
269
|
+
store,
|
|
270
|
+
signal
|
|
271
|
+
}, data, spentReason(failure.error instanceof Error ? failure.error.message : String(failure.error))), (error) => Effect.logError(`git.index left repo ${jobRepo(job)} failed, with no refusal: ${error.message}`)).pipe(Effect.asVoid));
|
|
264
272
|
/** How many times a refusal's try reads and writes the refused row before it fails. */
|
|
265
273
|
const refusalWrites = 3;
|
|
266
274
|
/**
|
|
@@ -269,9 +277,8 @@ const refusalWrites = 3;
|
|
|
269
277
|
* row, the next tries leave a refused row, and `indexFailed` is their last chance. One at a time
|
|
270
278
|
* in each process, as `git.repack` runs.
|
|
271
279
|
*/
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
schema: indexJobSchema,
|
|
280
|
+
const IndexJob = /* @__PURE__ */ Job.make(indexJobName, {
|
|
281
|
+
payload: IndexJobData,
|
|
275
282
|
timeout: "13 minutes",
|
|
276
283
|
concurrency: 1,
|
|
277
284
|
retry: {
|
|
@@ -279,13 +286,12 @@ const indexJob = (parts) => defineJob({
|
|
|
279
286
|
delay: "1 second",
|
|
280
287
|
backoff: "exponential",
|
|
281
288
|
maxDelay: "5 minutes"
|
|
282
|
-
}
|
|
283
|
-
handler: indexHandler(parts),
|
|
284
|
-
onFailure: indexFailed(parts)
|
|
289
|
+
}
|
|
285
290
|
});
|
|
291
|
+
const indexJob = (parts) => madeJob(IndexJob.definition(indexStep(parts), { onFailure: indexFailed(parts) }));
|
|
286
292
|
/** The repo's `git.index` row for `round`, or for its delete, due now. */
|
|
287
293
|
const indexJobRow = (job, round = 0) => job.job({
|
|
288
294
|
key: indexJobKeyOf(round),
|
|
289
295
|
data: {}
|
|
290
296
|
});
|
|
291
|
-
export { IndexJobData, indexDeletedKey,
|
|
297
|
+
export { IndexJobData, indexDeletedKey, indexJob, indexJobKey, indexJobKeyOf, indexJobName, indexJobRow };
|
package/dist/core/parts.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ import { GrantFences } from "../auth/fences.mjs";
|
|
|
7
7
|
import { HeldGrants } from "../auth/grants.mjs";
|
|
8
8
|
import { CursorSeal } from "../store/cursor-seal.mjs";
|
|
9
9
|
import { EventLog } from "../contracts/events.mjs";
|
|
10
|
+
import { HiddenRefs } from "../protocol/wire/lines.mjs";
|
|
10
11
|
import { PushChecks } from "./access.mjs";
|
|
11
12
|
import { RefIndex } from "./ref-index.mjs";
|
|
12
13
|
import { SealedObjects } from "./view.mjs";
|
|
@@ -38,6 +39,11 @@ export interface CoreFields {
|
|
|
38
39
|
*/
|
|
39
40
|
readonly refIndex?: RefIndex;
|
|
40
41
|
readonly fences: GrantFences;
|
|
42
|
+
/**
|
|
43
|
+
* The prefixes whose refs are Git's own, `refs/import/` and each prefix an extension claimed, as
|
|
44
|
+
* the registry holds them: read at each call, since parts are made before the registry's seal.
|
|
45
|
+
*/
|
|
46
|
+
readonly hiddenRefs: () => readonly HiddenRefs[];
|
|
41
47
|
/** The grant behind each caller this server's `identify` or `grantAgain` made. */
|
|
42
48
|
readonly grants: HeldGrants;
|
|
43
49
|
readonly checks: PushChecks;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../contracts/promises.mjs";
|
|
2
|
+
import "../contracts/git.mjs";
|
|
3
|
+
import "../contracts/result.mjs";
|
|
4
|
+
import "../contracts/ids.mjs";
|
|
5
|
+
import "../contracts/objects.mjs";
|
|
6
|
+
import { JobDefinition, JobInput, Moment } from "@ref0/infra";
|
|
7
|
+
import "effect/Schema";
|
|
8
|
+
import "effect/Effect";
|
package/dist/core/purge.mjs
CHANGED
|
@@ -2,15 +2,15 @@ import { repackJobName } from "../storage/repack-job.mjs";
|
|
|
2
2
|
import { objectCollections } from "../storage/layout.mjs";
|
|
3
3
|
import { tooLargeRead } from "../storage/object-rows.mjs";
|
|
4
4
|
import { forkedFrom, reconcile, releaseHold } from "../store/catalogue.mjs";
|
|
5
|
-
import { runJobTry } from "../store/crossing.mjs";
|
|
6
5
|
import { storeCall } from "../store/errors.mjs";
|
|
6
|
+
import { madeJob, repoTry } from "../store/job-try.mjs";
|
|
7
7
|
import { outboxCollections } from "../store/outbox.mjs";
|
|
8
8
|
import { readRecord } from "../store/repo-record.mjs";
|
|
9
|
-
import { collections,
|
|
10
|
-
import {
|
|
9
|
+
import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
10
|
+
import { isDeliverJob } from "./events/deliver.mjs";
|
|
11
11
|
import "./hooks/post-receive.mjs";
|
|
12
12
|
import { indexJobName } from "./index-job.mjs";
|
|
13
|
-
import {
|
|
13
|
+
import { Job, limits } from "@ref0/infra";
|
|
14
14
|
import * as Schema from "effect/Schema";
|
|
15
15
|
import * as Effect from "effect/Effect";
|
|
16
16
|
// src/core/purge.ts
|
|
@@ -31,17 +31,14 @@ const purgeLargePage = /* @__PURE__ */ Math.floor(limits.answerBytes / limits.va
|
|
|
31
31
|
/**
|
|
32
32
|
* The jobs whose work a purge waits for, while one is waiting, running or failed in the repo's
|
|
33
33
|
* scope: git.repack's moves its packs' bytes out and runs its upkeep's, git.index's deleted round
|
|
34
|
-
* deletes its index's files, and git.deliver sends `repo.deleted`. A
|
|
35
|
-
* until a host retries or discards it. A new job that deletes a repo's
|
|
34
|
+
* deletes its index's files, and each delivery's, `git.deliver.<name>`, sends `repo.deleted`. A
|
|
35
|
+
* failed one holds the purge until a host retries or discards it. A new job that deletes a repo's
|
|
36
|
+
* bytes joins this list, or its check below. Every
|
|
36
37
|
* other job ends on the record the purge deletes last: git.list's projection the purge runs itself
|
|
37
38
|
* before it, and git.post-receive reads no push once the purge has deleted them. A post-receive try
|
|
38
39
|
* already running holds it too: the cursor row it adds once its host returns would outlive the record.
|
|
39
40
|
*/
|
|
40
|
-
const drainJobs = /* @__PURE__ */ new Set([
|
|
41
|
-
repackJobName,
|
|
42
|
-
indexJobName,
|
|
43
|
-
deliverJobName
|
|
44
|
-
]);
|
|
41
|
+
const drainJobs = /* @__PURE__ */ new Set([repackJobName, indexJobName]);
|
|
45
42
|
/**
|
|
46
43
|
* The rows whose bytes a drain job deletes, and which it deletes itself: while one stands, the
|
|
47
44
|
* purge waits, so no row naming bytes goes before them.
|
|
@@ -51,6 +48,7 @@ const drainedCollections = [
|
|
|
51
48
|
collections.pushUploads,
|
|
52
49
|
objectCollections.quarantine,
|
|
53
50
|
objectCollections.leaving,
|
|
51
|
+
objectCollections.cover,
|
|
54
52
|
objectCollections.staged,
|
|
55
53
|
objectCollections.receive,
|
|
56
54
|
objectCollections.merge,
|
|
@@ -92,13 +90,13 @@ const purgeCollections = [
|
|
|
92
90
|
outboxCollections.events,
|
|
93
91
|
outboxCollections.outbox,
|
|
94
92
|
outboxCollections.delivered,
|
|
93
|
+
outboxCollections.cursors,
|
|
95
94
|
outboxCollections.followers
|
|
96
95
|
];
|
|
97
96
|
const purgeJobName = "git.purge";
|
|
98
97
|
/** The repo's one `git.purge` row. */
|
|
99
98
|
const purgeJobKey = "purge";
|
|
100
99
|
const PurgeData = /* @__PURE__ */ Schema.Struct({});
|
|
101
|
-
const purgeJobSchema = /* @__PURE__ */ Schema.toStandardSchemaV1(PurgeData);
|
|
102
100
|
const again = { kind: "more" };
|
|
103
101
|
/**
|
|
104
102
|
* Whether a drain job is waiting, running or failed in `scope`, or a post-receive try is running:
|
|
@@ -109,7 +107,7 @@ const draining = /* @__PURE__ */ Effect.fnUntraced(function* (store, scope) {
|
|
|
109
107
|
for (;;) {
|
|
110
108
|
const page = after === void 0 ? {} : { page: { after } };
|
|
111
109
|
const listing = yield* storeCall(() => store.list(scope, page));
|
|
112
|
-
if (listing.items.some((item) => drainJobs.has(item.name) || item.name === "git.post-receive" && item.state === "running")) return true;
|
|
110
|
+
if (listing.items.some((item) => drainJobs.has(item.name) || isDeliverJob(item) || item.name === "git.post-receive" && item.state === "running")) return true;
|
|
113
111
|
if (listing.next === void 0) return false;
|
|
114
112
|
after = listing.next;
|
|
115
113
|
}
|
|
@@ -223,20 +221,17 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
|
|
|
223
221
|
delete: own.keys
|
|
224
222
|
}))).ok ? void 0 : again;
|
|
225
223
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
/** `git.purge`, over one server's parts. */
|
|
229
|
-
const purgeJob = (parts) => defineJob({
|
|
230
|
-
name: purgeJobName,
|
|
231
|
-
schema: purgeJobSchema,
|
|
224
|
+
const PurgeJob = /* @__PURE__ */ Job.make(purgeJobName, {
|
|
225
|
+
payload: PurgeData,
|
|
232
226
|
concurrency: 1,
|
|
233
|
-
handler: purgeHandler(parts),
|
|
234
227
|
rebuild: () => ({})
|
|
235
228
|
});
|
|
229
|
+
/** `git.purge`, over one server's parts: each try one page of the repo's rows. */
|
|
230
|
+
const purgeJob = (parts) => madeJob(PurgeJob.definition(() => repoTry((store, repo) => purgeStep(parts, store, repo))));
|
|
236
231
|
/** The repo's `git.purge` row, due at `at`. */
|
|
237
232
|
const purgeJobRow = (job, at) => job.job({
|
|
238
233
|
key: purgeJobKey,
|
|
239
234
|
data: {},
|
|
240
235
|
at
|
|
241
236
|
});
|
|
242
|
-
export { purgeCollections,
|
|
237
|
+
export { purgeCollections, purgeJob, purgeJobKey, purgeJobName, purgeJobRow, purgePage };
|
|
@@ -5,14 +5,15 @@ import { collections, reachedKey } from "../store/scopes.mjs";
|
|
|
5
5
|
import { isRefName } from "./names.mjs";
|
|
6
6
|
import { refConflicts } from "./ref-conflicts.mjs";
|
|
7
7
|
import { refDeletes, refPuts, stampDrops } from "./ref-index.mjs";
|
|
8
|
-
import { limits } from "@ref0/infra";
|
|
8
|
+
import { jsonBytes, limits } from "@ref0/infra";
|
|
9
9
|
// src/core/push-decide.ts
|
|
10
10
|
/** The most refs one push moves: two writes each, its row and its event, inside a commit's 10,000. */
|
|
11
11
|
const pushRefLimit = 4e3;
|
|
12
12
|
/**
|
|
13
13
|
* What a push at `pushRefLimit` leaves of a commit's writes for its other rows: 2,000. Its mirror
|
|
14
14
|
* jobs, `mirrorLimits.mirrors` at most, its `git.queue.advance` jobs, one a moved target and
|
|
15
|
-
* `queueLimits.targets` at most,
|
|
15
|
+
* `queueLimits.targets` at most, its delivery jobs, one a delivery and `deliveryLimit` at most,
|
|
16
|
+
* and its fixed rows stay within it by construction.
|
|
16
17
|
*/
|
|
17
18
|
const pushOtherWrites = limits.writes - 2 * pushRefLimit;
|
|
18
19
|
/**
|
|
@@ -37,6 +38,27 @@ const otherWritesProblem = (push, index) => {
|
|
|
37
38
|
context: { reason: "too-large" }
|
|
38
39
|
});
|
|
39
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* The most bytes, as UTF-8 JSON, a push's options take across its write's events, each moved ref's
|
|
43
|
+
* `ref.updated` carrying them whole: a quarter of a commit's `limits.bytes`, so the events, the
|
|
44
|
+
* refs and the other rows stay within it. A push of 4,000 refs with 100 B of options takes 400 KB.
|
|
45
|
+
*/
|
|
46
|
+
const pushOptionsEventBytes = limits.bytes / 4;
|
|
47
|
+
/**
|
|
48
|
+
* `RESOURCE_EXHAUSTED`, `too-large`, before the commit, for a push whose `options`, repeated on
|
|
49
|
+
* the `ref.updated` of each of its `moved` refs, pass `pushOptionsEventBytes`, where the store
|
|
50
|
+
* would refuse the commit bare.
|
|
51
|
+
*/
|
|
52
|
+
const pushOptionsProblem = (options, moved) => {
|
|
53
|
+
if (options === void 0 || options.length === 0) return void 0;
|
|
54
|
+
const each = jsonBytes(options);
|
|
55
|
+
if (each * moved <= pushOptionsEventBytes) return void 0;
|
|
56
|
+
const message = `A push's options take ${each} bytes on each of its ${moved} refs' events, past a push's ${pushOptionsEventBytes}`;
|
|
57
|
+
return gitError("RESOURCE_EXHAUSTED", message, {
|
|
58
|
+
hint: "Push fewer refs at a time, or send fewer or shorter push options",
|
|
59
|
+
context: { reason: "too-large" }
|
|
60
|
+
});
|
|
61
|
+
};
|
|
40
62
|
const refused = (error) => ({
|
|
41
63
|
kind: "answer",
|
|
42
64
|
answer: {
|
|
@@ -148,7 +170,7 @@ const clearsMark = (decision) => decision.kind === "commit" && decision.moved.le
|
|
|
148
170
|
/**
|
|
149
171
|
* Objects whose refs don't move: their own commit, with no version, for a write that names no ref,
|
|
150
172
|
* or a client's fetch, whose refused refs' tips stay to merge onto. A push that names refs and
|
|
151
|
-
* moves none commits nothing, its pack
|
|
173
|
+
* moves none commits nothing, its pack abandoned as the push answers, for the next clean-up.
|
|
152
174
|
*/
|
|
153
175
|
const objectsAlone = (read, command, updates) => {
|
|
154
176
|
if (!(command.updates.length === 0 || command.source === "import") || command.received === void 0) return void 0;
|
|
@@ -268,4 +290,4 @@ const decidePush = ({ read, command, index }) => {
|
|
|
268
290
|
moved: moves
|
|
269
291
|
};
|
|
270
292
|
};
|
|
271
|
-
export { clearsMark, decidePush, indexedPushRefLimit, otherWritesProblem, pushOtherWrites, pushRefLimit, pushRefLimitOf };
|
|
293
|
+
export { clearsMark, decidePush, indexedPushRefLimit, otherWritesProblem, pushOptionsEventBytes, pushOptionsProblem, pushOtherWrites, pushRefLimit, pushRefLimitOf };
|