@ref0/git 0.7.0 → 0.8.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 +0 -2
- package/dist/auth/authorize.mjs +31 -24
- package/dist/auth/bridge.mjs +8 -8
- package/dist/auth/fences.d.mts +0 -1
- package/dist/auth/fences.mjs +1 -1
- package/dist/auth/grants.d.mts +0 -1
- package/dist/auth/grants.mjs +2 -2
- package/dist/auth/host-function.d.mts +1 -7
- package/dist/auth/host-function.mjs +38 -38
- package/dist/auth/identify.d.mts +0 -1
- package/dist/auth/identify.mjs +1 -1
- package/dist/auth/policy.d.mts +7 -4
- package/dist/auth/policy.mjs +13 -10
- package/dist/auth/token-rows.mjs +2 -5
- package/dist/auth/tokens-layer.d.mts +0 -2
- package/dist/auth/tokens-public.d.mts +3 -3
- package/dist/auth/tokens-public.mjs +4 -2
- package/dist/auth/tokens.d.mts +6 -1
- package/dist/auth/tokens.mjs +7 -1
- package/dist/client/client.d.mts +22 -15
- package/dist/client/client.mjs +31 -27
- package/dist/client/git-http.mjs +22 -5
- package/dist/client/local.mjs +1 -1
- package/dist/client/namespace.d.mts +2 -0
- package/dist/client/push-upload.d.mts +1 -0
- package/dist/client/push-upload.mjs +169 -2
- package/dist/client/remote-helper.mjs +2 -4
- package/dist/client/remote.mjs +37 -15
- package/dist/client/run-remote-helper.mjs +4 -4
- package/dist/client/transport.mjs +26 -19
- package/dist/contracts/actors.d.mts +57 -28
- package/dist/contracts/actors.mjs +38 -2
- package/dist/contracts/authorize.d.mts +21 -15
- package/dist/contracts/callers.mjs +40 -0
- package/dist/contracts/client.d.mts +16 -9
- package/dist/contracts/events.d.mts +12 -10
- package/dist/contracts/events.mjs +8 -6
- package/dist/contracts/files.d.mts +42 -42
- package/dist/contracts/forks.d.mts +0 -24
- package/dist/contracts/git-hooks.d.mts +217 -0
- package/dist/contracts/git-hooks.mjs +3 -1
- package/dist/contracts/grants.d.mts +46 -27
- package/dist/contracts/lfs.d.mts +17 -4
- package/dist/contracts/merges.d.mts +7 -7
- package/dist/contracts/objects.d.mts +20 -4
- package/dist/contracts/opaque.mjs +19 -1
- package/dist/contracts/operations.d.mts +8 -1
- package/dist/contracts/operations.mjs +209 -0
- package/dist/contracts/queue.d.mts +3 -3
- package/dist/contracts/queue.mjs +5 -18
- package/dist/contracts/remote.d.mts +13 -4
- package/dist/contracts/remote.mjs +3 -3
- package/dist/contracts/repos.d.mts +11 -40
- package/dist/contracts/repos.mjs +11 -10
- package/dist/contracts/result.d.mts +28 -11
- package/dist/contracts/result.mjs +32 -2
- package/dist/contracts/rules.d.mts +706 -46
- package/dist/contracts/rules.mjs +81 -2
- package/dist/contracts/server.d.mts +5 -275
- package/dist/contracts/services.d.mts +0 -3
- package/dist/contracts/services.mjs +1 -3
- package/dist/contracts/signin.d.mts +2 -2
- package/dist/contracts/signin.mjs +4 -5
- package/dist/contracts/sync.d.mts +1 -4
- package/dist/contracts/tokens.d.mts +29 -17
- package/dist/contracts/tokens.mjs +14 -3
- package/dist/contracts/topics.d.mts +38 -11
- package/dist/contracts/topics.mjs +8 -2
- package/dist/core/access.d.mts +0 -2
- package/dist/core/access.mjs +15 -4
- package/dist/core/events/deliver.mjs +19 -1
- package/dist/core/forks.mjs +30 -11
- package/dist/core/hooks/groups.d.mts +0 -1
- package/dist/core/hooks/groups.mjs +8 -9
- package/dist/core/loose-tally.mjs +46 -0
- package/dist/core/objects/writing.mjs +1 -0
- package/dist/core/promise.mjs +1 -15
- package/dist/core/purge.mjs +14 -9
- package/dist/core/push.mjs +13 -6
- package/dist/core/ref-view.mjs +14 -6
- package/dist/core/repack.mjs +19 -14
- package/dist/core/repo-info.mjs +8 -6
- package/dist/core/repos.mjs +1 -0
- package/dist/core/rules/check.mjs +10 -10
- package/dist/core/rules/context.d.mts +3 -1
- package/dist/core/rules/context.mjs +16 -13
- package/dist/core/rules/fetch.mjs +17 -23
- package/dist/core/tokens.mjs +2 -1
- package/dist/effect.d.mts +2 -4
- package/dist/effect.mjs +2 -4
- package/dist/engine/commits.mjs +19 -47
- package/dist/engine/failures.d.mts +1 -2
- package/dist/engine/failures.mjs +1 -3
- package/dist/engine/merge-base-walk.mjs +57 -142
- package/dist/engine/merge-bases.mjs +5 -5
- package/dist/engine/merge.mjs +16 -14
- package/dist/extend.d.mts +1 -2
- package/dist/extend.mjs +1 -2
- package/dist/http/core-parts.mjs +1 -2
- package/dist/http/handler.mjs +11 -31
- package/dist/http/parts.d.mts +0 -1
- package/dist/index.d.mts +28 -21
- package/dist/index.mjs +5 -2
- package/dist/lfs/base.d.mts +6 -3
- package/dist/lfs/base.mjs +2 -1
- package/dist/lfs/layer.d.mts +4 -3
- package/dist/lfs/layer.mjs +23 -9
- package/dist/lfs/objects.mjs +90 -41
- package/dist/lfs/pointers.mjs +69 -18
- package/dist/lfs/purge.mjs +6 -2
- package/dist/lfs/rows.mjs +24 -7
- package/dist/lfs/service.d.mts +6 -3
- package/dist/lfs/service.mjs +8 -2
- package/dist/lfs/upkeep.mjs +44 -26
- package/dist/lfs/upload-most.mjs +41 -0
- package/dist/lfs/uploaded.mjs +59 -0
- package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
- package/dist/protocol/bytes/text.mjs +6 -1
- package/dist/protocol/objects/fsck.mjs +6 -3
- package/dist/queue/advance.mjs +38 -8
- package/dist/queue/calls.mjs +4 -14
- package/dist/queue/lanes.mjs +1 -1
- package/dist/queue/rows.mjs +8 -0
- package/dist/queue/schedule.mjs +1 -1
- package/dist/queue/search.mjs +3 -4
- package/dist/rest/client-namespace.d.mts +2 -0
- package/dist/rest/client.d.mts +32 -8
- package/dist/rest/client.mjs +308 -382
- package/dist/rest/commits.d.mts +240 -240
- package/dist/rest/files.d.mts +18 -18
- package/dist/rest/forks.d.mts +45 -57
- package/dist/rest/handlers.mjs +2 -1
- package/dist/rest/listen.d.mts +8 -6
- package/dist/rest/listen.mjs +31 -75
- package/dist/rest/me.d.mts +2 -2
- package/dist/rest/merges.d.mts +7 -7
- package/dist/rest/refs.d.mts +139 -139
- package/dist/rest/repos.d.mts +54 -66
- package/dist/rest/tokens.d.mts +12 -12
- package/dist/rest/topics.d.mts +110 -110
- package/dist/rest/trees.d.mts +66 -66
- package/dist/rest/wire.d.mts +1 -1
- package/dist/rest.d.mts +1 -7
- package/dist/rest.mjs +1 -5
- package/dist/server/git-layer.d.mts +10 -2
- package/dist/server/git-layer.mjs +29 -10
- package/dist/server/joined.d.mts +1 -1
- package/dist/server/server.d.mts +0 -1
- package/dist/server/server.mjs +26 -45
- package/dist/signin/context.d.mts +0 -1
- package/dist/signin/context.mjs +5 -9
- package/dist/storage/clean-up.mjs +3 -1
- package/dist/storage/fsck.mjs +12 -2
- package/dist/storage/graph-rebuild.mjs +262 -0
- package/dist/storage/index-build.mjs +100 -12
- package/dist/storage/lfs-pointers.d.mts +5 -5
- package/dist/storage/lfs-pointers.mjs +37 -11
- package/dist/storage/loose.mjs +4 -1
- package/dist/storage/memory-budget.mjs +1 -1
- package/dist/storage/merge-fence.mjs +81 -19
- package/dist/storage/merge-most.mjs +1 -0
- package/dist/storage/merge-row.mjs +16 -4
- package/dist/storage/merge-stream.mjs +9 -6
- package/dist/storage/object-rows.mjs +17 -1
- package/dist/storage/pack-receive.mjs +10 -6
- package/dist/storage/packs.mjs +58 -27
- package/dist/storage/prune.mjs +68 -40
- package/dist/storage/ready.d.mts +1 -1
- package/dist/storage/ready.mjs +12 -3
- package/dist/storage/receive-state.mjs +1 -1
- package/dist/storage/repack-contained.mjs +22 -14
- package/dist/storage/repack.d.mts +1 -1
- package/dist/storage/repack.mjs +3 -2
- package/dist/storage/unpack.mjs +7 -0
- package/dist/store/call-count.d.mts +23 -3
- package/dist/store/call-count.mjs +36 -13
- package/dist/store/records.mjs +10 -4
- package/dist/store/repo-record.mjs +29 -12
- package/dist/store/scopes.mjs +6 -1
- package/dist/sync/import.mjs +14 -2
- package/dist/sync/layer.d.mts +5 -1
- package/dist/sync/layer.mjs +7 -2
- package/dist/sync/step.mjs +15 -15
- package/dist/topics/advance.mjs +7 -6
- package/dist/topics/members.mjs +38 -9
- package/package.json +3 -3
- package/dist/engine/merge-base-walk.d.mts +0 -3
- package/dist/server/routes.d.mts +0 -32
- package/dist/server/routes.mjs +0 -69
- package/dist/sync/bridge.d.mts +0 -6
- package/dist/sync/bridge.mjs +0 -29
package/dist/core/ref-view.mjs
CHANGED
|
@@ -113,12 +113,12 @@ const memoKey = (internalId, caller) => Effect.map(grantOf(caller), (grant) => J
|
|
|
113
113
|
/** `caller`'s ref view of `repo`'s refs, asked of `authorize` each time it runs: no held answer. */
|
|
114
114
|
/** The prefixes of the registry's table, as `AccessOption.refViewOf` takes them. */
|
|
115
115
|
const prefixesOf = (table) => table.map(({ owner }) => owner.prefix);
|
|
116
|
-
const askRefView = (access, caller,
|
|
116
|
+
const askRefView = (access, caller, about, hidden) => {
|
|
117
117
|
if (access === void 0) return Effect.succeed(wholeView);
|
|
118
118
|
return Effect.map(Effect.suspend(() => audience({
|
|
119
119
|
caller,
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
patterns: access.patterns,
|
|
121
|
+
...about
|
|
122
122
|
})), (audience) => access.refViewOf(audience, hidden));
|
|
123
123
|
};
|
|
124
124
|
/** `caller`'s ref view of `repo`'s refs, asked of `authorize` once per request at most. */
|
|
@@ -127,7 +127,7 @@ const refViewIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo) {
|
|
|
127
127
|
if (access === void 0) return wholeView;
|
|
128
128
|
const hidden = prefixesOf(hiddenRefs());
|
|
129
129
|
const authorize = yield* Authorize;
|
|
130
|
-
const ask = Effect.provideService(askRefView(access, caller, repo, hidden), Authorize, authorize);
|
|
130
|
+
const ask = Effect.provideService(askRefView(access, caller, { repo }, hidden), Authorize, authorize);
|
|
131
131
|
const memo = yield* Effect.serviceOption(AudienceMemo);
|
|
132
132
|
if (Option.isNone(memo)) return yield* ask;
|
|
133
133
|
const key = yield* memoKey(repo.internalId, caller);
|
|
@@ -166,6 +166,14 @@ const accessAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, r
|
|
|
166
166
|
const refViewAgain = /* @__PURE__ */ Effect.fnUntraced(function* (caller, kind, repo) {
|
|
167
167
|
const { access, hiddenRefs } = yield* CoreParts;
|
|
168
168
|
yield* accessAgain(caller, kind, repo);
|
|
169
|
-
return yield* askRefView(access, caller, repo, prefixesOf(hiddenRefs()));
|
|
169
|
+
return yield* askRefView(access, caller, { repo }, prefixesOf(hiddenRefs()));
|
|
170
170
|
});
|
|
171
|
-
|
|
171
|
+
/**
|
|
172
|
+
* `caller`'s ref view of the repo an import is about to make as `name`, asked of `authorize` as
|
|
173
|
+
* `repo.create` is, with the name and no repo: afresh, since no repo is there to hold it by.
|
|
174
|
+
*/
|
|
175
|
+
const creatingRefView = /* @__PURE__ */ Effect.fnUntraced(function* (caller, name) {
|
|
176
|
+
const { access, hiddenRefs } = yield* CoreParts;
|
|
177
|
+
return yield* askRefView(access, caller, { creating: name }, prefixesOf(hiddenRefs()));
|
|
178
|
+
});
|
|
179
|
+
export { AudienceMemo, ViewedMemo, accessAgain, creatingRefView, refViewAgain, refViewIn, seesJob, viewedIn, wholeView, withAudienceMemo };
|
package/dist/core/repack.mjs
CHANGED
|
@@ -5,12 +5,13 @@ import { untilAborted } from "../store/crossing.mjs";
|
|
|
5
5
|
import { gitJob } from "../store/job-try.mjs";
|
|
6
6
|
import { decodePacks, featureChange, gitStore, packRow } from "../store/git-store.mjs";
|
|
7
7
|
import { appendEvents, decodeOutbox, outboxReads, repoEnvelope } from "../store/outbox.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { decodeStats, looseRows, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
|
|
9
9
|
import { settleName } from "../store/settle.mjs";
|
|
10
10
|
import { replacedAtCommit } from "../storage/index-remap.mjs";
|
|
11
11
|
import { indexRowKey, isPackId, objectCollections } from "../storage/layout.mjs";
|
|
12
12
|
import { listedIds } from "../storage/listed-ids.mjs";
|
|
13
|
-
import {
|
|
13
|
+
import { noRows } from "../storage/object-rows.mjs";
|
|
14
|
+
import { ReadyRow, readyBytesOf } from "../storage/ready.mjs";
|
|
14
15
|
import { ApartRow, apartAfter, apartKey } from "../storage/repack-contained.mjs";
|
|
15
16
|
import { SwapsSettled, swapsKey, swapsLeft } from "../storage/swap-walk.mjs";
|
|
16
17
|
import { QuarantineRow, decodeHeld, decodeLeft, isLeftKey, leavingKey, leavingLate, leavingRow, leftPack } from "../storage/rows.mjs";
|
|
@@ -175,7 +176,8 @@ const leavingOf = /* @__PURE__ */ Effect.fnUntraced(function* (parts, packs, at)
|
|
|
175
176
|
return {
|
|
176
177
|
change: {
|
|
177
178
|
remove: named.map((pack) => pack.id),
|
|
178
|
-
put: named.map((pack) => leavingRow(pack, removeAt, { deleted: true }))
|
|
179
|
+
put: named.map((pack) => leavingRow(pack, removeAt, { deleted: true })),
|
|
180
|
+
rows: noRows
|
|
179
181
|
},
|
|
180
182
|
more: true
|
|
181
183
|
};
|
|
@@ -255,12 +257,13 @@ const heldRows = /* @__PURE__ */ Effect.fnUntraced(function* (keyed) {
|
|
|
255
257
|
const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId, keys = []) {
|
|
256
258
|
const { record, snapshot } = yield* readRecord(store, internalId, [...stepReads, ...keys]);
|
|
257
259
|
if (record === void 0) return void 0;
|
|
258
|
-
const [refRows = [], packRows = [], timeRows = [], ...rest] = snapshot.results.slice(1);
|
|
260
|
+
const [refRows = [], packRows = [], timeRows = [], readyRows = [], ...rest] = snapshot.results.slice(1);
|
|
259
261
|
const [headRows = [], cursorRows = [], runRows = [], receipts = [], own = [], indexRows = [], apartRows = [], swapsRows = []] = rest;
|
|
260
262
|
const held = yield* heldRows(snapshot.results.slice(stepReads.length + 1).flat());
|
|
261
263
|
const packs = yield* decodePacks(packRows);
|
|
262
264
|
const refs = yield* wholeRefs(upkeepWhole, refRows);
|
|
263
|
-
const times = yield*
|
|
265
|
+
const times = yield* decodeStats(timeRows);
|
|
266
|
+
const readyBytes = yield* readyBytesOf(readyRows);
|
|
264
267
|
const outbox = yield* decodeOutbox([headRows, cursorRows]);
|
|
265
268
|
const [runRow] = runRows;
|
|
266
269
|
const saved = runRow === void 0 ? void 0 : yield* decodeRow(MaintenanceRun, runRow, "The repack run");
|
|
@@ -277,6 +280,7 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId,
|
|
|
277
280
|
refs,
|
|
278
281
|
packs,
|
|
279
282
|
times,
|
|
283
|
+
readyBytes,
|
|
280
284
|
outbox,
|
|
281
285
|
saved,
|
|
282
286
|
sweep,
|
|
@@ -307,7 +311,7 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
307
311
|
const scope = repoScope(internalId);
|
|
308
312
|
const now = yield* parts.now;
|
|
309
313
|
const late = now - at;
|
|
310
|
-
const objects = changeOf(read.version, startedLate(step?.change ?? {}, late));
|
|
314
|
+
const objects = changeOf(read.version, startedLate(step?.change ?? { rows: noRows }, late));
|
|
311
315
|
yield* featureChange(scope, objects);
|
|
312
316
|
const deleted = read.record.deleted === true;
|
|
313
317
|
const sweep = read.sweep(at);
|
|
@@ -326,7 +330,7 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
326
330
|
name: read.record.name,
|
|
327
331
|
outbox: read.outbox,
|
|
328
332
|
scope
|
|
329
|
-
}, run, packsAfter(read.packs, step?.change ?? {}), {
|
|
333
|
+
}, run, packsAfter(read.packs, step?.change ?? { rows: noRows }), {
|
|
330
334
|
last: step?.more !== true,
|
|
331
335
|
saved: read.saved !== void 0,
|
|
332
336
|
at,
|
|
@@ -348,13 +352,15 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
348
352
|
const { indexJobRow } = parts;
|
|
349
353
|
const removes = (step?.change.remove?.length ?? 0) > 0 && !deleted;
|
|
350
354
|
const pruning = (laid.length > 0 || !removes || read.index === void 0 ? laid : [read.index]).flatMap((row) => index === void 0 || indexJobRow === void 0 ? [] : indexJobs({ indexJobRow }, index.status(row, now, listing)));
|
|
351
|
-
const apart = [...apartAfter(read.apart, step?.change ?? {}), ...swapsLeft(read.swaps, step?.change ?? {})];
|
|
355
|
+
const apart = [...apartAfter(read.apart, step?.change ?? { rows: noRows }), ...swapsLeft(read.swaps, step?.change ?? { rows: noRows })];
|
|
352
356
|
const pass = step?.prune === void 0 || deleted ? [] : [pruneJobRow(step.prune)];
|
|
357
|
+
const loose = looseRows(read.times.loose, step?.change.rows ?? noRows);
|
|
353
358
|
const others = step?.repack === void 0 || deleted ? [] : [repackJobRow$1(step.repack)];
|
|
354
359
|
const change = {
|
|
355
360
|
...objects,
|
|
356
361
|
put: [
|
|
357
362
|
...objects.put ?? [],
|
|
363
|
+
...loose,
|
|
358
364
|
...apart,
|
|
359
365
|
...laid,
|
|
360
366
|
...mark,
|
|
@@ -436,8 +442,8 @@ const reviveParked = /* @__PURE__ */ Effect.fnUntraced(function* (store, interna
|
|
|
436
442
|
* own writes at one version, runs `upkeep`'s step first, which answers `more` alone when it did some, asks the
|
|
437
443
|
* objects for a step, with the default branch's tip and the tags, and commits its change at that
|
|
438
444
|
* version, fenced by the try's claim, as `commitStep` says. After `dropTries` or more `missed`
|
|
439
|
-
* dropping commits in a row, it asks for a step that drops none. A deleted repo's step, once
|
|
440
|
-
* receipts and
|
|
445
|
+
* dropping commits in a row, it asks for a step that drops none. A deleted repo's step, once no page
|
|
446
|
+
* of its receipts and own writes is left to sweep now, moves its packs out of the list, a page at a time, and asks the objects
|
|
441
447
|
* nothing until none are listed; then, with no tip and no tags, its ready shallow pack is let go.
|
|
442
448
|
* A step that finds the version moved reads again, up to `writeTries` times, the rows
|
|
443
449
|
* `rereadKeys` names, and commits at the new version while `stillTakes` holds: a step with its
|
|
@@ -472,7 +478,7 @@ const repackStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
472
478
|
version: first.version,
|
|
473
479
|
packs: first.packs
|
|
474
480
|
};
|
|
475
|
-
const stats = repoStats(first.record, first.refs.size, first.packs, first.times);
|
|
481
|
+
const stats = repoStats(first.record, first.refs.size, first.packs, first.times, first.readyBytes);
|
|
476
482
|
const served = first.record.deleted === true ? /* @__PURE__ */ new Map() : first.refs;
|
|
477
483
|
const tags = [...served].flatMap(([name, oid]) => name.startsWith("refs/tags/") ? [oid] : []);
|
|
478
484
|
const tip = served.get(headOf(first.record.defaultBranch));
|
|
@@ -491,9 +497,8 @@ const repackStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
491
497
|
if (missed >= 5) input.drops = false;
|
|
492
498
|
if (retried) input.retried = true;
|
|
493
499
|
if (first.record.deleted === true) input.deleted = true;
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
change: {},
|
|
500
|
+
const held = first.sweep(at).more ? {
|
|
501
|
+
change: { rows: noRows },
|
|
497
502
|
more: false
|
|
498
503
|
} : void 0;
|
|
499
504
|
const step = (first.record.deleted === true ? held ?? (yield* leavingOf(parts, first.packs, at)) : void 0) ?? (yield* resultCall(() => SealedObjects.whole(parts.objects, upkeepWhole).maintain(listed, input)));
|
package/dist/core/repo-info.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { indexRowKey } from "../storage/layout.mjs";
|
|
2
|
+
import { readyBytesOf } from "../storage/ready.mjs";
|
|
2
3
|
import { namedRecordOf } from "../store/catalogue.mjs";
|
|
3
4
|
import { storeCall } from "../store/errors.mjs";
|
|
4
5
|
import { decodePacks } from "../store/git-store.mjs";
|
|
5
|
-
import {
|
|
6
|
+
import { decodeStats, repoStats, seenTimes } from "../store/repo-record.mjs";
|
|
6
7
|
import { repoScope } from "../store/scopes.mjs";
|
|
7
8
|
import { liveAsAsked, repoAccess, statsReads } from "./access.mjs";
|
|
8
9
|
import { refViewIn, wholeView } from "./ref-view.mjs";
|
|
@@ -77,16 +78,17 @@ const createdInfo = (caller, internalId, record) => infoIn(caller, internalId, r
|
|
|
77
78
|
/** A repo's info for a caller with `refView`, from what `repoInfo` says. */
|
|
78
79
|
const infoIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, internalId, record, results, refView) {
|
|
79
80
|
const { objects: sealed } = yield* ObjectsParts;
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
81
|
+
const [refRows = [], packRows = [], timeRows = [], readyRows = [], indexRows = []] = results;
|
|
82
|
+
const packs = yield* decodePacks(packRows);
|
|
83
|
+
const times = yield* decodeStats(timeRows);
|
|
84
|
+
const readyBytes = yield* readyBytesOf(readyRows);
|
|
83
85
|
const refs = refView.whole ? refRows.length : refRows.filter((row) => refView.sees(row.id)).length;
|
|
84
|
-
const whole = repoStats(record, refs, packs, seenTimes(times, refView));
|
|
86
|
+
const whole = repoStats(record, refs, packs, seenTimes(times, refView), readyBytes);
|
|
85
87
|
const info = refView.whole ? {
|
|
86
88
|
name: record.name,
|
|
87
89
|
public: record.public,
|
|
88
90
|
stats: whole,
|
|
89
|
-
work: yield* repoWork(internalId, sealed,
|
|
91
|
+
work: yield* repoWork(internalId, sealed, indexRows[0], packs)
|
|
90
92
|
} : {
|
|
91
93
|
name: record.name,
|
|
92
94
|
public: record.public,
|
package/dist/core/repos.mjs
CHANGED
|
@@ -322,6 +322,7 @@ const createWith = /* @__PURE__ */ Effect.fnUntraced(function* (caller, input, a
|
|
|
322
322
|
const entry = yield* entryOf(store, id);
|
|
323
323
|
if (nameMoved(keyed, entry)) continue;
|
|
324
324
|
if (entry !== void 0 && entry.deleted !== true) return yield* alreadyExists(id);
|
|
325
|
+
if (also.check !== void 0) yield* also.check(id);
|
|
325
326
|
const internalId = newInternalId();
|
|
326
327
|
const record = {
|
|
327
328
|
name: id,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { gitError } from "../../contracts/result.mjs";
|
|
2
|
-
import { hostEffect,
|
|
2
|
+
import { hostEffect, logRefusal, rejectedError } from "../../auth/host-function.mjs";
|
|
3
3
|
import { hiddenUnder } from "../../protocol/wire/lines.mjs";
|
|
4
4
|
import { inCallScope } from "../../store/call-count.mjs";
|
|
5
|
-
import { checkedAnswer, pushContextOf } from "./context.mjs";
|
|
5
|
+
import { checkedAnswer, plainAnswer, pushContextOf } from "./context.mjs";
|
|
6
6
|
import { shortRef } from "./patterns.mjs";
|
|
7
7
|
import { pushRulesOf } from "./service.mjs";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
@@ -11,7 +11,7 @@ import * as Result from "effect/Result";
|
|
|
11
11
|
/** Every rule a push runs: the host's `Rules`, then those `parts` adds. */
|
|
12
12
|
const pushRulesFor = (parts) => pushRulesOf(parts.added?.() ?? []);
|
|
13
13
|
/** `rule`'s answer for `update`, of the push's `reached` refs, as the host's call. */
|
|
14
|
-
const ruleAnswer = (
|
|
14
|
+
const ruleAnswer = (checking, rule, reached, update) => {
|
|
15
15
|
const changed = {
|
|
16
16
|
key: update.ref,
|
|
17
17
|
updates: [update]
|
|
@@ -21,8 +21,8 @@ const ruleAnswer = (reports, checking, rule, reached, update) => {
|
|
|
21
21
|
update,
|
|
22
22
|
authorize: (asked) => inCallScope(authorize(asked), checking.scope)
|
|
23
23
|
});
|
|
24
|
-
const answer = checkedAnswer(`The push rule '${rule.name}'`, () => rule.check(input));
|
|
25
|
-
return hostEffect(
|
|
24
|
+
const answer = checkedAnswer(`The push rule '${rule.name}'`, plainAnswer, () => rule.check(input));
|
|
25
|
+
return hostEffect("rules.push", checking.about, answer);
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* Whether a push `as` an owner may change `ref`: a ref under one of `table`'s prefixes is its
|
|
@@ -62,13 +62,13 @@ const runPushRules = /* @__PURE__ */ Effect.fnUntraced(function* (parts, input,
|
|
|
62
62
|
if (rules.length === 0) return checked();
|
|
63
63
|
const { about } = checking;
|
|
64
64
|
const refuse = (ref, error) => {
|
|
65
|
-
reportRefusal(parts.reports, "rules.push", about, error);
|
|
66
65
|
refused.set(ref, error);
|
|
66
|
+
return logRefusal("rules.push", about, error);
|
|
67
67
|
};
|
|
68
68
|
const ruleRefusal = Effect.fnUntraced(function* (update) {
|
|
69
69
|
checking.passOver(update.ref);
|
|
70
70
|
for (const rule of rules) {
|
|
71
|
-
const answer = yield* ruleAnswer(
|
|
71
|
+
const answer = yield* ruleAnswer(checking, rule, reached, update);
|
|
72
72
|
if (answer.kind === "reject") return rejectedError(answer);
|
|
73
73
|
}
|
|
74
74
|
}, Effect.result);
|
|
@@ -82,7 +82,7 @@ const runPushRules = /* @__PURE__ */ Effect.fnUntraced(function* (parts, input,
|
|
|
82
82
|
const lifted = update.kind === "force" && checking.bypassed.has(update.ref);
|
|
83
83
|
if (rejected === void 0 && !lifted) continue;
|
|
84
84
|
if (rejected !== void 0 && update.kind !== "force") {
|
|
85
|
-
refuse(update.ref, rejected);
|
|
85
|
+
yield* refuse(update.ref, rejected);
|
|
86
86
|
continue;
|
|
87
87
|
}
|
|
88
88
|
const exact = yield* Effect.result(input.exact(update));
|
|
@@ -92,7 +92,7 @@ const runPushRules = /* @__PURE__ */ Effect.fnUntraced(function* (parts, input,
|
|
|
92
92
|
continue;
|
|
93
93
|
}
|
|
94
94
|
if (exact.success === "force") {
|
|
95
|
-
if (rejected !== void 0) refuse(update.ref, rejected);
|
|
95
|
+
if (rejected !== void 0) yield* refuse(update.ref, rejected);
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
98
|
const shown = {
|
|
@@ -102,7 +102,7 @@ const runPushRules = /* @__PURE__ */ Effect.fnUntraced(function* (parts, input,
|
|
|
102
102
|
kinds.set(update.ref, shown);
|
|
103
103
|
const again = yield* ruleRefusal(shown);
|
|
104
104
|
if (Result.isFailure(again)) refused.set(update.ref, again.failure);
|
|
105
|
-
else if (again.success !== void 0) refuse(update.ref, again.success);
|
|
105
|
+
else if (again.success !== void 0) yield* refuse(update.ref, again.success);
|
|
106
106
|
}
|
|
107
107
|
return checked();
|
|
108
108
|
});
|
|
@@ -2,8 +2,8 @@ import { Caller } from "../../contracts/actors.mjs";
|
|
|
2
2
|
import { TreeChange } from "../../contracts/engine.mjs";
|
|
3
3
|
import { InternalRepoId, Oid, RefName, RepoName } from "../../contracts/ids.mjs";
|
|
4
4
|
import { GitObject } from "../../contracts/objects.mjs";
|
|
5
|
-
import { LfsPointers } from "../../contracts/object-values.mjs";
|
|
6
5
|
import { RefSource, RefUpdate, RefUpdateKind } from "../../contracts/refs.mjs";
|
|
6
|
+
import { LfsPointers } from "../../contracts/object-values.mjs";
|
|
7
7
|
import { RepoStats } from "../../contracts/repos.mjs";
|
|
8
8
|
import { GitError } from "../../contracts/result.mjs";
|
|
9
9
|
import { CommitChange, RuleOperation } from "../../contracts/rules.mjs";
|
|
@@ -12,6 +12,8 @@ import { CallScope } from "../../store/call-count.mjs";
|
|
|
12
12
|
import { Ordered } from "../hooks/order.mjs";
|
|
13
13
|
import { WalkFailure } from "./commit-changes.mjs";
|
|
14
14
|
import * as Effect from "effect/Effect";
|
|
15
|
+
import "effect/Schema";
|
|
16
|
+
import "effect/Result";
|
|
15
17
|
import * as Stream from "effect/Stream";
|
|
16
18
|
/** One push's checks' input: the request, each edit's kind, and the repo's facts at one read. */
|
|
17
19
|
export interface CheckInput {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { accept, reject } from "../../contracts/result.mjs";
|
|
1
|
+
import { accept, decisionAnswer, reject } from "../../contracts/result.mjs";
|
|
2
2
|
import { actingOf } from "../../auth/acting.mjs";
|
|
3
3
|
import { WalkRefused } from "../../engine/combined.mjs";
|
|
4
4
|
import { inCallScope, scopedContext } from "../../store/call-count.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
import * as Option from "effect/Option";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
7
8
|
import * as Exit from "effect/Exit";
|
|
8
9
|
import * as Result from "effect/Result";
|
|
9
|
-
import * as Predicate from "effect/Predicate";
|
|
10
10
|
import * as Stream from "effect/Stream";
|
|
11
11
|
import * as Deferred from "effect/Deferred";
|
|
12
12
|
// src/core/rules/context.ts
|
|
@@ -128,23 +128,26 @@ const pushContextOf = (checking, updates, changed, extra) => {
|
|
|
128
128
|
...extra
|
|
129
129
|
};
|
|
130
130
|
};
|
|
131
|
-
|
|
131
|
+
/** A push rule's, a hook group's or `prepare`'s answer, which carries no value. */
|
|
132
|
+
const plainAnswer = /* @__PURE__ */ Schema.decodeUnknownResult(decisionAnswer(Schema.Undefined));
|
|
132
133
|
/**
|
|
133
|
-
* A host check's answer: one that is neither `accept()` nor `reject()
|
|
134
|
-
* can answer whatever its types say,
|
|
134
|
+
* A host check's answer, as `read` reads it: one that is neither `accept()` nor `reject()` as
|
|
135
|
+
* `DecisionAnswer` types them, which a host's JavaScript can answer whatever its types say, such as
|
|
136
|
+
* a reject with no string `message` or a `code` Git has none of, is the host's failure.
|
|
135
137
|
*/
|
|
136
|
-
const answerOf = (name, answer) => {
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
const answerOf = (name, read, answer) => {
|
|
139
|
+
const answered = read(answer);
|
|
140
|
+
if (Result.isSuccess(answered)) return answered.success;
|
|
141
|
+
throw new TypeError(`${name} answered neither accept() nor reject(): ${answered.failure.message}`);
|
|
139
142
|
};
|
|
140
143
|
/**
|
|
141
|
-
* `check()`'s answer, as `answerOf` reads it
|
|
142
|
-
* host's JavaScript can give whatever its types say, and one
|
|
144
|
+
* `check()`'s answer, as `answerOf` reads it with `read`: a throw, an answer that isn't an Effect,
|
|
145
|
+
* which a host's JavaScript can give whatever its types say, and one `read` refuses each die, for
|
|
143
146
|
* `hostEffect` to make the host's failure.
|
|
144
147
|
*/
|
|
145
|
-
const checkedAnswer = (name, check) => Effect.suspend(() => {
|
|
148
|
+
const checkedAnswer = (name, read, check) => Effect.suspend(() => {
|
|
146
149
|
const answer = check();
|
|
147
|
-
return Effect.isEffect(answer) ? Effect.flatMap(answer, (value) => Effect.sync(() => answerOf(name, value))) : Effect.die(/* @__PURE__ */ new TypeError(`${name} answered no Effect`));
|
|
150
|
+
return Effect.isEffect(answer) ? Effect.flatMap(answer, (value) => Effect.sync(() => answerOf(name, read, value))) : Effect.die(/* @__PURE__ */ new TypeError(`${name} answered no Effect`));
|
|
148
151
|
});
|
|
149
152
|
/** The codes `authorize` fails with when the host failed, not when it refused. */
|
|
150
153
|
const hostFailures = /* @__PURE__ */ new Set([
|
|
@@ -153,4 +156,4 @@ const hostFailures = /* @__PURE__ */ new Set([
|
|
|
153
156
|
"INTERNAL",
|
|
154
157
|
"DATA_LOSS"
|
|
155
158
|
]);
|
|
156
|
-
export { answerOf, checkedAnswer, checking, commitChangesCovered, pushContextOf };
|
|
159
|
+
export { answerOf, checkedAnswer, checking, commitChangesCovered, plainAnswer, pushContextOf };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { gitError } from "../../contracts/result.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { hostEffect,
|
|
4
|
-
import { CoreParts } from "../parts.mjs";
|
|
1
|
+
import { decisionAnswer, gitError } from "../../contracts/result.mjs";
|
|
2
|
+
import { FetchAdjustment } from "../../contracts/rules.mjs";
|
|
3
|
+
import { hostEffect, logRefusal, rejectedError } from "../../auth/host-function.mjs";
|
|
5
4
|
import { checkedAnswer } from "./context.mjs";
|
|
6
5
|
import { fetchRulesOf } from "./service.mjs";
|
|
7
6
|
import * as Effect from "effect/Effect";
|
|
@@ -31,15 +30,11 @@ const inputOf = (check) => {
|
|
|
31
30
|
if (check.request !== void 0) read.request = check.request;
|
|
32
31
|
return read;
|
|
33
32
|
};
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const depth = answer.value?.depth;
|
|
40
|
-
if (depth === void 0 || isRuledDepth(depth)) return depth;
|
|
41
|
-
throw new TypeError(`${name} set a depth that isn't a whole number above 0: ${depth}`);
|
|
42
|
-
};
|
|
33
|
+
/**
|
|
34
|
+
* A fetch rule's answer: a depth it sets that isn't a whole number above 0, as `RuledDepth` holds,
|
|
35
|
+
* is the rule's own bug, so the host's failure.
|
|
36
|
+
*/
|
|
37
|
+
const fetchAnswer = /* @__PURE__ */ Schema.decodeUnknownResult(decisionAnswer(FetchAdjustment));
|
|
43
38
|
/**
|
|
44
39
|
* A clone's or fetch's rules, the host's `Rules`, in order, or a read's: any `reject()` refuses it,
|
|
45
40
|
* as the first to reject says, answered as its value, and a rule that fails or dies fails it as the
|
|
@@ -47,7 +42,7 @@ const depthOf = (name, answer) => {
|
|
|
47
42
|
* read keeps no history to cut, so a depth set on one refuses it, `NOT_ALLOWED` for
|
|
48
43
|
* `fetch-depth-unsupported`. Each refusal is reported once. No rule sets a filter.
|
|
49
44
|
*/
|
|
50
|
-
const ruledBy = /* @__PURE__ */ Effect.fnUntraced(function* (
|
|
45
|
+
const ruledBy = /* @__PURE__ */ Effect.fnUntraced(function* (check) {
|
|
51
46
|
const rules = yield* fetchRulesOf();
|
|
52
47
|
if (rules.length === 0) return { depth: void 0 };
|
|
53
48
|
const { actor } = check.caller;
|
|
@@ -63,14 +58,14 @@ const ruledBy = /* @__PURE__ */ Effect.fnUntraced(function* (reports, check) {
|
|
|
63
58
|
for (const rule of rules) {
|
|
64
59
|
const name = `The fetch rule '${rule.name}'`;
|
|
65
60
|
const input = inputOf(check);
|
|
66
|
-
const answered = Effect.
|
|
61
|
+
const answered = Effect.map(checkedAnswer(name, fetchAnswer, () => rule.check(input)), (answer) => answer.kind === "reject" ? answer : {
|
|
67
62
|
kind: "accept",
|
|
68
|
-
depth:
|
|
69
|
-
})
|
|
70
|
-
const depth = yield* hostEffect(
|
|
63
|
+
depth: answer.value?.depth
|
|
64
|
+
});
|
|
65
|
+
const depth = yield* hostEffect("rules.fetch", about, answered);
|
|
71
66
|
if (depth.kind === "reject") {
|
|
72
67
|
const refused = rejectedError(depth);
|
|
73
|
-
|
|
68
|
+
yield* logRefusal("rules.fetch", about, refused);
|
|
74
69
|
return { refused };
|
|
75
70
|
}
|
|
76
71
|
if (depth.depth !== void 0) depths.push(depth.depth);
|
|
@@ -78,7 +73,7 @@ const ruledBy = /* @__PURE__ */ Effect.fnUntraced(function* (reports, check) {
|
|
|
78
73
|
if (depths.length === 0) return { depth: void 0 };
|
|
79
74
|
if ("read" in check) {
|
|
80
75
|
const refused = gitError("NOT_ALLOWED", "A fetch rule set a depth, which a read of bytes keeps no history for", { context: { reason: "fetch-depth-unsupported" } });
|
|
81
|
-
|
|
76
|
+
yield* logRefusal("rules.fetch", about, refused);
|
|
82
77
|
return { refused };
|
|
83
78
|
}
|
|
84
79
|
return { depth: Math.min(...depths) };
|
|
@@ -87,15 +82,14 @@ const ruledBy = /* @__PURE__ */ Effect.fnUntraced(function* (reports, check) {
|
|
|
87
82
|
* A clone's or fetch's rules, as `ruledBy` asks them, failing with a refusal as the rule wrote it.
|
|
88
83
|
* Answers the smallest depth any rule set; `withRuledDepth` says how the fetch takes it.
|
|
89
84
|
*/
|
|
90
|
-
const runFetchRules = (
|
|
85
|
+
const runFetchRules = (check) => Effect.flatMap(ruledBy(check), (ruled) => ruled.refused === void 0 ? Effect.succeed(ruled.depth) : Effect.fail(ruled.refused));
|
|
91
86
|
/**
|
|
92
87
|
* `input`'s read of `repo`, asked of the host's fetch rules as `ruledBy` says: the refusal, or
|
|
93
88
|
* `undefined` when they accept it. A rule's failure fails it, as the host's. Only a target Git
|
|
94
89
|
* already found visible to the caller is asked about.
|
|
95
90
|
*/
|
|
96
91
|
const readRefusal = /* @__PURE__ */ Effect.fnUntraced(function* (repo, input) {
|
|
97
|
-
|
|
98
|
-
return (yield* ruledBy(core.checks.reports, {
|
|
92
|
+
return (yield* ruledBy({
|
|
99
93
|
caller: input.caller,
|
|
100
94
|
repo,
|
|
101
95
|
read: input.target,
|
package/dist/core/tokens.mjs
CHANGED
|
@@ -95,7 +95,8 @@ const tokenCallsAs = (tokens, bound) => bound === void 0 || isHost(bound) ? toke
|
|
|
95
95
|
const checkedTokenCalls = (tokens, caller) => ({
|
|
96
96
|
create: (target, input) => Effect.flatMap(targetCheck(caller, {
|
|
97
97
|
kind: "token.create",
|
|
98
|
-
...tokenParties(input)
|
|
98
|
+
...tokenParties(input),
|
|
99
|
+
scope: input.scope
|
|
99
100
|
}, target), (held) => tokens.create(target, input, held)),
|
|
100
101
|
list: (target, input) => Effect.flatMap(targetCheck(caller, { kind: "token.list" }, target), (held) => tokens.list(target, input, held)),
|
|
101
102
|
get: (id) => heldCheck(caller, id, "token.list"),
|
package/dist/effect.d.mts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { EffectCalls, GitCaller,
|
|
1
|
+
import { EffectCalls, GitCaller, GitStore } from "./contracts/services.mjs";
|
|
2
2
|
import { IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput } from "./contracts/objects.mjs";
|
|
3
|
-
import { effectGitClient } from "./client/client.mjs";
|
|
4
3
|
import { CallAllowance, CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
|
|
5
4
|
import { spentRefusalOf } from "./contracts/calls-spent.mjs";
|
|
6
5
|
import { storeCall } from "./store/errors.mjs";
|
|
7
6
|
import { bucketCall } from "./storage/calls.mjs";
|
|
8
7
|
import { GitRestApi } from "./rest/api.mjs";
|
|
9
|
-
import { GitRoutesOptions, GitRoutesServices, GitServer } from "./server/routes.mjs";
|
|
10
8
|
import { GitCallerMiddleware, GitRestServices, RestServerSeam } from "./rest/caller.mjs";
|
|
11
9
|
import { GitErrors } from "./rest/errors.mjs";
|
|
12
10
|
import { GitRestHandlers } from "./rest/handlers.mjs";
|
|
@@ -16,4 +14,4 @@ import { ReposApiGroup } from "./rest/repos.mjs";
|
|
|
16
14
|
import { TokensApiGroup } from "./rest/tokens.mjs";
|
|
17
15
|
import { WorkApiGroup } from "./rest/work.mjs";
|
|
18
16
|
import { SeamAuthorizeInput, TokenRevokeCheck } from "./core/seam.mjs";
|
|
19
|
-
export { type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware,
|
|
17
|
+
export { type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, spentRefusalOf, storeCall };
|
package/dist/effect.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { GitCaller,
|
|
2
|
-
import { effectGitClient } from "./client/client.mjs";
|
|
1
|
+
import { GitCaller, GitStore } from "./contracts/services.mjs";
|
|
3
2
|
import { CallBudget } from "./store/call-count.mjs";
|
|
4
3
|
import { spentRefusalOf } from "./contracts/calls-spent.mjs";
|
|
5
4
|
import { storeCall } from "./store/errors.mjs";
|
|
6
5
|
import { bucketCall } from "./storage/calls.mjs";
|
|
7
6
|
import { GitRestApi } from "./rest/api.mjs";
|
|
8
|
-
import { GitServer } from "./server/routes.mjs";
|
|
9
7
|
import { GitCallerMiddleware, GitRestServices } from "./rest/caller.mjs";
|
|
10
8
|
import { GitErrors } from "./rest/errors.mjs";
|
|
11
9
|
import { GitRestHandlers } from "./rest/handlers.mjs";
|
|
@@ -14,4 +12,4 @@ import { RefsApiGroup } from "./rest/refs.mjs";
|
|
|
14
12
|
import { ReposApiGroup } from "./rest/repos.mjs";
|
|
15
13
|
import { TokensApiGroup } from "./rest/tokens.mjs";
|
|
16
14
|
import { WorkApiGroup } from "./rest/work.mjs";
|
|
17
|
-
export { CallBudget, GitCaller, GitCallerMiddleware,
|
|
15
|
+
export { CallBudget, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, MeApiGroup, RefsApiGroup, ReposApiGroup, TokensApiGroup, WorkApiGroup, bucketCall, spentRefusalOf, storeCall };
|
package/dist/engine/commits.mjs
CHANGED
|
@@ -40,52 +40,24 @@ const namedCommit = /* @__PURE__ */ Effect.fnUntraced(function* (reader, oid) {
|
|
|
40
40
|
/** A commit's time as Git's queue orders by it: its committer's, in seconds. */
|
|
41
41
|
const timeOf = (commit) => Math.floor(commit.committer.at / 1e3);
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* past the call's objects stops as `walk-limit`.
|
|
43
|
+
* The commits a merge-base walk reads through `reader`, `tips` among them already: each read when
|
|
44
|
+
* the walk first reaches it, and held as its parents and time alone.
|
|
46
45
|
*/
|
|
47
|
-
const
|
|
48
|
-
const read = new Map(tips.map((tip) => [tip.oid,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
read.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return yield* generations(read);
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* Each commit's generation, worked out parents first, without recursion. Commits whose parents
|
|
60
|
-
* lead back to themselves can't be Git's, whose IDs hash their parents: `DATA_LOSS`.
|
|
61
|
-
*/
|
|
62
|
-
const generations = (read) => Effect.suspend(() => {
|
|
63
|
-
const walked = /* @__PURE__ */ new Map();
|
|
64
|
-
const entered = /* @__PURE__ */ new Set();
|
|
65
|
-
for (const start of read.keys()) {
|
|
66
|
-
const stack = [start];
|
|
67
|
-
for (let oid = stack.at(-1); oid !== void 0; oid = stack.at(-1)) {
|
|
68
|
-
const commit = read.get(oid);
|
|
69
|
-
if (walked.has(oid) || commit === void 0) {
|
|
70
|
-
stack.pop();
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const waiting = commit.parents.filter((parent) => !walked.has(parent));
|
|
74
|
-
if (waiting.length > 0 && !entered.has(oid)) {
|
|
75
|
-
entered.add(oid);
|
|
76
|
-
stack.push(...waiting);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (waiting.length > 0) return fail("DATA_LOSS", `${oid} is its own ancestor`);
|
|
80
|
-
const generation = 1 + Math.max(0, ...commit.parents.map((p) => walked.get(p)?.generation ?? 0));
|
|
81
|
-
walked.set(oid, {
|
|
46
|
+
const walkedThrough = (reader, tips) => {
|
|
47
|
+
const read = new Map(tips.map((tip) => [tip.oid, {
|
|
48
|
+
parents: tip.parents,
|
|
49
|
+
time: timeOf(tip)
|
|
50
|
+
}]));
|
|
51
|
+
return {
|
|
52
|
+
known: (oid) => read.get(oid),
|
|
53
|
+
read: (oid) => Effect.map(commitAt(reader, oid), (commit) => {
|
|
54
|
+
const walked = {
|
|
82
55
|
parents: commit.parents,
|
|
83
|
-
time: timeOf(commit)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
export { ancestry, commitAt, namedCommit, timeOf };
|
|
56
|
+
time: timeOf(commit)
|
|
57
|
+
};
|
|
58
|
+
read.set(oid, walked);
|
|
59
|
+
return walked;
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export { commitAt, namedCommit, timeOf, walkedThrough };
|
package/dist/engine/failures.mjs
CHANGED
|
@@ -11,6 +11,4 @@ const fromDiff = (limit) => (error) => {
|
|
|
11
11
|
case "object-too-large": return gitError("RESOURCE_EXHAUSTED", error.message, { context: { reason: "object-too-large" } });
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
const fromMissing = (error) => gitError("NOT_FOUND", error.message);
|
|
16
|
-
export { fromDiff, fromMissing };
|
|
14
|
+
export { fromDiff };
|