@leed-ai/git-gateway-testkit 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +19 -2
- package/dist/contract-suite/ancestry-cases.d.ts +4 -0
- package/dist/contract-suite/ancestry-cases.js +49 -0
- package/dist/contract-suite/ancestry-cases.js.map +1 -0
- package/dist/contract-suite/backend-case.d.ts +35 -0
- package/dist/contract-suite/backend-case.js +17 -0
- package/dist/contract-suite/backend-case.js.map +1 -0
- package/dist/contract-suite/backend-contract-suite.d.ts +44 -0
- package/dist/contract-suite/backend-contract-suite.js +59 -0
- package/dist/contract-suite/backend-contract-suite.js.map +1 -0
- package/dist/contract-suite/backend-fixtures.d.ts +25 -0
- package/dist/contract-suite/backend-fixtures.js +79 -0
- package/dist/contract-suite/backend-fixtures.js.map +1 -0
- package/dist/contract-suite/content-cases.d.ts +4 -0
- package/dist/contract-suite/content-cases.js +31 -0
- package/dist/contract-suite/content-cases.js.map +1 -0
- package/dist/contract-suite/lifecycle-cases.d.ts +4 -0
- package/dist/contract-suite/lifecycle-cases.js +86 -0
- package/dist/contract-suite/lifecycle-cases.js.map +1 -0
- package/dist/contract-suite/push-cases.d.ts +4 -0
- package/dist/contract-suite/push-cases.js +92 -0
- package/dist/contract-suite/push-cases.js.map +1 -0
- package/dist/contract-suite/push-helpers.d.ts +17 -0
- package/dist/contract-suite/push-helpers.js +47 -0
- package/dist/contract-suite/push-helpers.js.map +1 -0
- package/dist/contract-suite/read-cases.d.ts +4 -0
- package/dist/contract-suite/read-cases.js +186 -0
- package/dist/contract-suite/read-cases.js.map +1 -0
- package/dist/contract-suite/transport-cases.d.ts +4 -0
- package/dist/contract-suite/transport-cases.js +105 -0
- package/dist/contract-suite/transport-cases.js.map +1 -0
- package/dist/git-binary.d.ts +19 -0
- package/dist/git-binary.js +54 -0
- package/dist/git-binary.js.map +1 -0
- package/dist/git-sandbox.d.ts +33 -0
- package/dist/git-sandbox.js +76 -0
- package/dist/git-sandbox.js.map +1 -0
- package/dist/memory/memory-backend.d.ts +45 -0
- package/dist/memory/memory-backend.js +154 -0
- package/dist/memory/memory-backend.js.map +1 -0
- package/dist/memory/memory-reads.d.ts +9 -0
- package/dist/memory/memory-reads.js +39 -0
- package/dist/memory/memory-reads.js.map +1 -0
- package/dist/memory/memory-repository.d.ts +38 -0
- package/dist/memory/memory-repository.js +97 -0
- package/dist/memory/memory-repository.js.map +1 -0
- package/dist/memory/memory-tokens.d.ts +28 -0
- package/dist/memory/memory-tokens.js +59 -0
- package/dist/memory/memory-tokens.js.map +1 -0
- package/dist/memory/pack-selection.d.ts +30 -0
- package/dist/memory/pack-selection.js +104 -0
- package/dist/memory/pack-selection.js.map +1 -0
- package/dist/memory/receive-pack-service.d.ts +15 -0
- package/dist/memory/receive-pack-service.js +126 -0
- package/dist/memory/receive-pack-service.js.map +1 -0
- package/dist/memory/smart-http-server.d.ts +15 -0
- package/dist/memory/smart-http-server.js +65 -0
- package/dist/memory/smart-http-server.js.map +1 -0
- package/dist/memory/upload-pack-service.d.ts +15 -0
- package/dist/memory/upload-pack-service.js +123 -0
- package/dist/memory/upload-pack-service.js.map +1 -0
- package/dist/node/serve-fetch-handler.d.ts +16 -0
- package/dist/node/serve-fetch-handler.js +52 -0
- package/dist/node/serve-fetch-handler.js.map +1 -0
- package/dist/node/serve-streaming.d.ts +16 -0
- package/dist/node/serve-streaming.js +87 -0
- package/dist/node/serve-streaming.js.map +1 -0
- package/package.json +175 -4
- package/src/contract-suite/ancestry-cases.ts +56 -0
- package/src/contract-suite/backend-case.ts +53 -0
- package/src/contract-suite/backend-contract-suite.ts +89 -0
- package/src/contract-suite/backend-fixtures.ts +89 -0
- package/src/contract-suite/content-cases.ts +55 -0
- package/src/contract-suite/lifecycle-cases.ts +121 -0
- package/src/contract-suite/push-cases.ts +123 -0
- package/src/contract-suite/push-helpers.ts +63 -0
- package/src/contract-suite/read-cases.ts +213 -0
- package/src/contract-suite/transport-cases.ts +134 -0
- package/src/git-binary.ts +65 -0
- package/src/git-sandbox.ts +87 -0
- package/src/memory/memory-backend.ts +188 -0
- package/src/memory/memory-reads.ts +52 -0
- package/src/memory/memory-repository.ts +115 -0
- package/src/memory/memory-tokens.ts +64 -0
- package/src/memory/pack-selection.ts +127 -0
- package/src/memory/receive-pack-service.ts +141 -0
- package/src/memory/smart-http-server.ts +78 -0
- package/src/memory/upload-pack-service.ts +132 -0
- package/src/node/serve-fetch-handler.ts +71 -0
- package/src/node/serve-streaming.ts +107 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { assertEqual, expectGatewayError } from '@leed-ai/git-gateway-contract/behaviour/assertions';
|
|
3
|
+
|
|
4
|
+
import { backendCase, type BackendCase, type BackendContext } from './backend-case.ts';
|
|
5
|
+
import { fixtureCommit } from './backend-fixtures.ts';
|
|
6
|
+
import { expectAccepted, newObjects, pushNewBranch, pushRef, seedRepo } from './push-helpers.ts';
|
|
7
|
+
|
|
8
|
+
const GROUP = 'ancestry';
|
|
9
|
+
const MISSING = '0123456789abcdef0123456789abcdef01234567';
|
|
10
|
+
|
|
11
|
+
/** The optional isAncestor capability, or null when the backend does not offer it (the case passes). */
|
|
12
|
+
function capability(context: BackendContext) {
|
|
13
|
+
const { backend } = context;
|
|
14
|
+
if (backend.isAncestor === undefined) return null;
|
|
15
|
+
return async (ancestor: string, descendant: string, repo = context.repo) =>
|
|
16
|
+
backend.isAncestor?.(repo, ancestor, descendant);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** isAncestor, for backends that offer it; a backend without it passes every case. */
|
|
20
|
+
export const ancestryCases: readonly BackendCase[] = [
|
|
21
|
+
backendCase(GROUP, 'isAncestor answers as git merge-base --is-ancestor does', async (context) => {
|
|
22
|
+
const isAncestor = capability(context);
|
|
23
|
+
if (isAncestor === null) return;
|
|
24
|
+
const root = await seedRepo(context, { 'a.txt': 'a\n' });
|
|
25
|
+
const second = await fixtureCommit({ 'a.txt': 'a, revised\n' }, [root.sha], 'Second\n');
|
|
26
|
+
expectAccepted(
|
|
27
|
+
await pushRef(context, 'refs/heads/main', root.sha, second.sha, newObjects(second, root)),
|
|
28
|
+
'refs/heads/main',
|
|
29
|
+
);
|
|
30
|
+
const side = await fixtureCommit({ 'a.txt': 'a\n', 'b.txt': 'b\n' }, [root.sha], 'Side\n');
|
|
31
|
+
const merge = await fixtureCommit(
|
|
32
|
+
{ 'a.txt': 'a, revised\n', 'b.txt': 'b\n' },
|
|
33
|
+
[second.sha, side.sha],
|
|
34
|
+
'Merge\n',
|
|
35
|
+
);
|
|
36
|
+
await pushNewBranch(context, 'topic', { ...merge, objects: [...side.objects, ...merge.objects] });
|
|
37
|
+
assertEqual(await isAncestor(root.sha, second.sha), true, 'parent of a commit');
|
|
38
|
+
assertEqual(await isAncestor(root.sha, merge.sha), true, 'grandparent through a merge');
|
|
39
|
+
assertEqual(await isAncestor(side.sha, merge.sha), true, 'second parent of a merge');
|
|
40
|
+
assertEqual(await isAncestor(merge.sha, merge.sha), true, 'a commit is its own ancestor');
|
|
41
|
+
assertEqual(await isAncestor(second.sha, side.sha), false, 'siblings');
|
|
42
|
+
assertEqual(await isAncestor(merge.sha, root.sha), false, 'a descendant is not an ancestor');
|
|
43
|
+
}),
|
|
44
|
+
backendCase(
|
|
45
|
+
GROUP,
|
|
46
|
+
'isAncestor is null for an unknown commit and repo_not_found for a missing repository',
|
|
47
|
+
async (context) => {
|
|
48
|
+
const isAncestor = capability(context);
|
|
49
|
+
if (isAncestor === null) return;
|
|
50
|
+
const root = await seedRepo(context);
|
|
51
|
+
assertEqual(await isAncestor(MISSING, root.sha), null, 'unknown ancestor');
|
|
52
|
+
assertEqual(await isAncestor(root.sha, MISSING), null, 'unknown descendant');
|
|
53
|
+
await expectGatewayError(isAncestor(root.sha, root.sha, `${context.repo}-missing`), 'repo_not_found');
|
|
54
|
+
},
|
|
55
|
+
),
|
|
56
|
+
];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import type { GitAccess } from '@leed-ai/git-gateway-contract/storage/git-remote';
|
|
3
|
+
import type { StorageBackend } from '@leed-ai/git-gateway-contract/storage/storage-backend';
|
|
4
|
+
import { GitHttpClient, type FetchLike } from '@leed-ai/git-gateway-core/smart-http/git-http-client';
|
|
5
|
+
|
|
6
|
+
/** How a storage host treats pushes the contract leaves to the host. */
|
|
7
|
+
export interface HostBehaviour {
|
|
8
|
+
/**
|
|
9
|
+
* A push whose update names the ref's current id but does not contain it (a non-fast-forward
|
|
10
|
+
* update sent with force): "accepted" (git's default on a bare repository) or "refused".
|
|
11
|
+
*/
|
|
12
|
+
readonly nonFastForward: 'accepted' | 'refused';
|
|
13
|
+
/** gitRemote(…, "read") yields a credential that cannot push. */
|
|
14
|
+
readonly readRemoteCannotPush: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Everything a backend contract case runs with. */
|
|
18
|
+
export interface BackendContext {
|
|
19
|
+
readonly backend: StorageBackend;
|
|
20
|
+
/** A repository name no other case uses. The case creates it unless it tests creation. */
|
|
21
|
+
readonly repo: string;
|
|
22
|
+
readonly behaviour: HostBehaviour;
|
|
23
|
+
/** Size of the large-file case's file in bytes. */
|
|
24
|
+
readonly largeFileBytes: number;
|
|
25
|
+
/** A smart-HTTP client for a freshly minted remote of the case's repository. */
|
|
26
|
+
client(access: GitAccess): Promise<GitHttpClient>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** One rule of the storage backend contract. */
|
|
30
|
+
export interface BackendCase {
|
|
31
|
+
readonly group: string;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly run: (context: BackendContext) => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Declares a backend contract case. */
|
|
37
|
+
export function backendCase(
|
|
38
|
+
group: string,
|
|
39
|
+
name: string,
|
|
40
|
+
run: (context: BackendContext) => Promise<void>,
|
|
41
|
+
): BackendCase {
|
|
42
|
+
return { group, name, run };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A client factory for a backend's remotes, sending requests through `fetch`. */
|
|
46
|
+
export function clientFactory(
|
|
47
|
+
backend: StorageBackend,
|
|
48
|
+
repo: string,
|
|
49
|
+
fetch: FetchLike | undefined,
|
|
50
|
+
): (access: GitAccess) => Promise<GitHttpClient> {
|
|
51
|
+
return async (access) =>
|
|
52
|
+
new GitHttpClient(await backend.gitRemote(repo, access), fetch === undefined ? {} : { fetch });
|
|
53
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import type { TestRegistrar } from '@leed-ai/git-gateway-contract/behaviour/behaviour-suite';
|
|
3
|
+
import type { StorageBackend } from '@leed-ai/git-gateway-contract/storage/storage-backend';
|
|
4
|
+
import type { FetchLike } from '@leed-ai/git-gateway-core/smart-http/git-http-client';
|
|
5
|
+
|
|
6
|
+
import { ancestryCases } from './ancestry-cases.ts';
|
|
7
|
+
import { clientFactory, type BackendCase, type HostBehaviour } from './backend-case.ts';
|
|
8
|
+
import { contentCases } from './content-cases.ts';
|
|
9
|
+
import { lifecycleCases } from './lifecycle-cases.ts';
|
|
10
|
+
import { pushCases } from './push-cases.ts';
|
|
11
|
+
import { readCases } from './read-cases.ts';
|
|
12
|
+
import { transportCases } from './transport-cases.ts';
|
|
13
|
+
|
|
14
|
+
/** Every case of the storage backend contract, grouped by area. */
|
|
15
|
+
export const BACKEND_CASES: readonly BackendCase[] = [
|
|
16
|
+
...lifecycleCases,
|
|
17
|
+
...transportCases,
|
|
18
|
+
...readCases,
|
|
19
|
+
...pushCases,
|
|
20
|
+
...contentCases,
|
|
21
|
+
...ancestryCases,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/** How to run the backend contract suite against one backend. */
|
|
25
|
+
export interface BackendSuiteOptions {
|
|
26
|
+
/** Suite title; default "StorageBackend contract". */
|
|
27
|
+
readonly name?: string;
|
|
28
|
+
/** Returns the backend under test; called once per case. */
|
|
29
|
+
readonly createBackend: () => StorageBackend | Promise<StorageBackend>;
|
|
30
|
+
/** How the host treats what the contract leaves to it. */
|
|
31
|
+
readonly behaviour: HostBehaviour;
|
|
32
|
+
/** Sends requests to the backend's git remotes; default the global fetch. */
|
|
33
|
+
readonly fetch?: FetchLike;
|
|
34
|
+
/** Prefix of every repository name the cases create; default "contract". Keep it short. */
|
|
35
|
+
readonly repoPrefix?: string;
|
|
36
|
+
/** Size of the large-file case's file; default 5 MiB. */
|
|
37
|
+
readonly largeFileBytes?: number;
|
|
38
|
+
/** Delete each case's repository when it ends; default true. */
|
|
39
|
+
readonly cleanup?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Which cases to register; default every case. For a backend mode that cannot run a whole group,
|
|
42
|
+
* such as names that createRepo refuses, which the lifecycle group creates.
|
|
43
|
+
*/
|
|
44
|
+
readonly include?: (entry: BackendCase) => boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let runCounter = 0;
|
|
48
|
+
|
|
49
|
+
/** Runs one case against a fresh backend and a repository name no other case uses. */
|
|
50
|
+
export async function runBackendCase(entry: BackendCase, options: BackendSuiteOptions): Promise<void> {
|
|
51
|
+
runCounter += 1;
|
|
52
|
+
const backend = await options.createBackend();
|
|
53
|
+
const repo = `${options.repoPrefix ?? 'contract'}-${runCounter}-${crypto.randomUUID().slice(0, 8)}`;
|
|
54
|
+
try {
|
|
55
|
+
await entry.run({
|
|
56
|
+
backend,
|
|
57
|
+
repo,
|
|
58
|
+
behaviour: options.behaviour,
|
|
59
|
+
largeFileBytes: options.largeFileBytes ?? 5 * 1024 * 1024,
|
|
60
|
+
client: clientFactory(backend, repo, options.fetch),
|
|
61
|
+
});
|
|
62
|
+
} finally {
|
|
63
|
+
if (options.cleanup !== false) await backend.deleteRepo(repo);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Registers the storage backend contract suite with a test framework: one test per case, grouped
|
|
69
|
+
* by area. Every backend runs it unchanged — the in-memory backend, the Artifacts local binding
|
|
70
|
+
* and a disposable GitLab project — declaring only how its host treats non-fast-forward pushes
|
|
71
|
+
* and read credentials.
|
|
72
|
+
*
|
|
73
|
+
* registerBackendContractSuite({ describe, it }, {
|
|
74
|
+
* createBackend: () => backend,
|
|
75
|
+
* fetch: backend.fetch,
|
|
76
|
+
* behaviour: { nonFastForward: 'accepted', readRemoteCannotPush: true },
|
|
77
|
+
* });
|
|
78
|
+
*/
|
|
79
|
+
export function registerBackendContractSuite(test: TestRegistrar, options: BackendSuiteOptions): void {
|
|
80
|
+
const included = BACKEND_CASES.filter((entry) => options.include?.(entry) ?? true);
|
|
81
|
+
const groups = Map.groupBy(included, (entry) => entry.group);
|
|
82
|
+
test.describe(options.name ?? 'StorageBackend contract', () => {
|
|
83
|
+
for (const [group, cases] of groups) {
|
|
84
|
+
test.describe(group, () => {
|
|
85
|
+
for (const entry of cases) test.it(entry.name, () => runBackendCase(entry, options));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import type { Commit } from '@leed-ai/git-gateway-contract/schemas/commit';
|
|
3
|
+
import { createCommit } from '@leed-ai/git-gateway-core/objects/commit-object';
|
|
4
|
+
import { createObject } from '@leed-ai/git-gateway-core/objects/hash-object';
|
|
5
|
+
import type { GitObject, GitTreeEntry } from '@leed-ai/git-gateway-core/schemas/git-object';
|
|
6
|
+
import { editTree } from '@leed-ai/git-gateway-core/tree/edit-tree';
|
|
7
|
+
import { decodeTree } from '@leed-ai/git-gateway-core/objects/tree-object';
|
|
8
|
+
|
|
9
|
+
/** A file of a fixture commit: bytes (or UTF-8 text) and mode. */
|
|
10
|
+
export interface FixtureFile {
|
|
11
|
+
readonly content: Uint8Array | string;
|
|
12
|
+
readonly mode?: '100644' | '100755' | '120000';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A commit built for a test, with every new object it needs. */
|
|
16
|
+
export interface FixtureCommit {
|
|
17
|
+
readonly sha: string;
|
|
18
|
+
readonly commit: Commit;
|
|
19
|
+
/** The commit, its root tree, every subtree and every blob. */
|
|
20
|
+
readonly objects: GitObject[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const encoder = new TextEncoder();
|
|
24
|
+
const AUTHOR = { name: 'Contract Suite', email: 'contract@example.com' };
|
|
25
|
+
let clock = Date.parse('2026-01-01T00:00:00Z');
|
|
26
|
+
|
|
27
|
+
/** A fresh whole-second UTC date, one minute after the last, so histories have distinct dates. */
|
|
28
|
+
function nextDate(): string {
|
|
29
|
+
clock += 60_000;
|
|
30
|
+
return new Date(clock).toISOString();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Builds a commit of exactly `files` (path → content) with the given parents, entirely in
|
|
35
|
+
* memory through the core encoders. Dates are whole seconds in UTC, so a backend that reads the
|
|
36
|
+
* commit back can report it exactly.
|
|
37
|
+
*/
|
|
38
|
+
export async function fixtureCommit(
|
|
39
|
+
files: Readonly<Record<string, FixtureFile | string>>,
|
|
40
|
+
parents: readonly string[] = [],
|
|
41
|
+
message = 'Contract suite commit\n',
|
|
42
|
+
): Promise<FixtureCommit> {
|
|
43
|
+
const objects = new Map<string, GitObject>();
|
|
44
|
+
const changes = [];
|
|
45
|
+
for (const [path, file] of Object.entries(files)) {
|
|
46
|
+
const spec = typeof file === 'string' ? { content: file } : file;
|
|
47
|
+
const blob = await createObject(
|
|
48
|
+
'blob',
|
|
49
|
+
typeof spec.content === 'string' ? encoder.encode(spec.content) : spec.content,
|
|
50
|
+
);
|
|
51
|
+
objects.set(blob.sha, blob);
|
|
52
|
+
changes.push({ op: 'set' as const, path, mode: spec.mode ?? '100644', sha: blob.sha });
|
|
53
|
+
}
|
|
54
|
+
const reader = {
|
|
55
|
+
async readTree(sha: string): Promise<GitTreeEntry[] | null> {
|
|
56
|
+
const object = objects.get(sha);
|
|
57
|
+
return object?.type === 'tree' ? decodeTree(object.data, sha) : null;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const edited = await editTree({ tree: null, changes }, reader);
|
|
61
|
+
for (const object of edited.objects) objects.set(object.sha, object);
|
|
62
|
+
const signature = { ...AUTHOR, date: nextDate() };
|
|
63
|
+
const created = await createCommit({
|
|
64
|
+
tree: edited.tree,
|
|
65
|
+
parents: [...parents],
|
|
66
|
+
author: signature,
|
|
67
|
+
committer: signature,
|
|
68
|
+
message,
|
|
69
|
+
});
|
|
70
|
+
return { sha: created.object.sha, commit: created.commit, objects: [created.object, ...objects.values()] };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Deterministic pseudo-random bytes (xorshift32), so a large binary fixture is reproducible. */
|
|
74
|
+
export function pseudoRandomBytes(length: number, seed = 0x9e3779b9): Uint8Array {
|
|
75
|
+
const out = new Uint8Array(length);
|
|
76
|
+
let state = seed >>> 0 || 1;
|
|
77
|
+
for (let index = 0; index < length; index += 1) {
|
|
78
|
+
state ^= state << 13;
|
|
79
|
+
state >>>= 0;
|
|
80
|
+
state ^= state >>> 17;
|
|
81
|
+
state ^= state << 5;
|
|
82
|
+
state >>>= 0;
|
|
83
|
+
out[index] = state & 0xff;
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Every byte value 0–255, twice: the smallest file that exercises all of them. */
|
|
89
|
+
export const ALL_BYTES: Uint8Array = Uint8Array.from({ length: 512 }, (_, index) => index % 256);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { assertEqual, assertTrue, present } from '@leed-ai/git-gateway-contract/behaviour/assertions';
|
|
3
|
+
import { sameBytes } from '@leed-ai/git-gateway-contract/reference/bytes';
|
|
4
|
+
|
|
5
|
+
import { backendCase, type BackendCase } from './backend-case.ts';
|
|
6
|
+
import { pseudoRandomBytes } from './backend-fixtures.ts';
|
|
7
|
+
import { seedRepo } from './push-helpers.ts';
|
|
8
|
+
|
|
9
|
+
const GROUP = 'content';
|
|
10
|
+
|
|
11
|
+
/** Large and binary files, deep trees. */
|
|
12
|
+
export const contentCases: readonly BackendCase[] = [
|
|
13
|
+
backendCase(
|
|
14
|
+
GROUP,
|
|
15
|
+
'a large binary file round-trips through readBlob, readFile and fetch',
|
|
16
|
+
async (context) => {
|
|
17
|
+
const bytes = pseudoRandomBytes(context.largeFileBytes);
|
|
18
|
+
const seeded = await seedRepo(context, { 'assets/large.bin': { content: bytes } });
|
|
19
|
+
const blob = present(
|
|
20
|
+
seeded.objects.find((object) => object.type === 'blob' && object.data.length === bytes.length),
|
|
21
|
+
'blob',
|
|
22
|
+
);
|
|
23
|
+
const { backend, repo } = context;
|
|
24
|
+
assertTrue(
|
|
25
|
+
sameBytes(present(await backend.readBlob(repo, blob.sha), 'readBlob'), bytes),
|
|
26
|
+
'readBlob bytes',
|
|
27
|
+
);
|
|
28
|
+
assertTrue(
|
|
29
|
+
sameBytes(present(await backend.readFile(repo, 'main', 'assets/large.bin'), 'readFile'), bytes),
|
|
30
|
+
'readFile bytes',
|
|
31
|
+
);
|
|
32
|
+
const fetched = await (await context.client('read')).fetchPack({ wants: [seeded.sha] });
|
|
33
|
+
const got = present(
|
|
34
|
+
fetched.objects.find((object) => object.sha === blob.sha),
|
|
35
|
+
'fetched blob',
|
|
36
|
+
);
|
|
37
|
+
assertTrue(sameBytes(got.data, bytes), 'fetched bytes');
|
|
38
|
+
},
|
|
39
|
+
),
|
|
40
|
+
backendCase(GROUP, 'an empty file and a deep tree are stored and read back', async (context) => {
|
|
41
|
+
const deep = Array.from({ length: 24 }, (_, index) => `d${index}`).join('/');
|
|
42
|
+
await seedRepo(context, { 'empty.txt': '', [`${deep}/leaf.txt`]: 'leaf\n' });
|
|
43
|
+
const { backend, repo } = context;
|
|
44
|
+
assertEqual(
|
|
45
|
+
present(await backend.readFile(repo, 'main', 'empty.txt'), 'empty file').length,
|
|
46
|
+
0,
|
|
47
|
+
'empty file is empty',
|
|
48
|
+
);
|
|
49
|
+
assertEqual(
|
|
50
|
+
new TextDecoder().decode(present(await backend.readFile(repo, 'main', `${deep}/leaf.txt`), 'leaf')),
|
|
51
|
+
'leaf\n',
|
|
52
|
+
'deep leaf',
|
|
53
|
+
);
|
|
54
|
+
}),
|
|
55
|
+
];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import {
|
|
3
|
+
assertEqual,
|
|
4
|
+
assertTrue,
|
|
5
|
+
expectGatewayError,
|
|
6
|
+
} from '@leed-ai/git-gateway-contract/behaviour/assertions';
|
|
7
|
+
import type { GitAccess } from '@leed-ai/git-gateway-contract/storage/git-remote';
|
|
8
|
+
import { StorageRepoInfo } from '@leed-ai/git-gateway-contract/storage/storage-repo-info';
|
|
9
|
+
|
|
10
|
+
import { backendCase, type BackendCase } from './backend-case.ts';
|
|
11
|
+
import { seedRepo } from './push-helpers.ts';
|
|
12
|
+
|
|
13
|
+
const GROUP = 'lifecycle';
|
|
14
|
+
const SHA = 'ffffffffffffffffffffffffffffffffffffffff';
|
|
15
|
+
/** An access level outside the schema, smuggled past the type checker as a caller without types would. */
|
|
16
|
+
const NOT_AN_ACCESS_LEVEL: GitAccess = JSON.parse('"admin"');
|
|
17
|
+
|
|
18
|
+
/** createRepo, repoInfo, deleteRepo, missing repositories and input validation. */
|
|
19
|
+
export const lifecycleCases: readonly BackendCase[] = [
|
|
20
|
+
backendCase(
|
|
21
|
+
GROUP,
|
|
22
|
+
'createRepo creates an empty repository and repoInfo describes it',
|
|
23
|
+
async ({ backend, repo }) => {
|
|
24
|
+
const created = await backend.createRepo(repo);
|
|
25
|
+
assertTrue(StorageRepoInfo.safeParse(created).success, 'createRepo returns a StorageRepoInfo');
|
|
26
|
+
assertEqual([created.name, created.defaultBranch], [repo, 'main'], 'name and default branch "main"');
|
|
27
|
+
assertEqual(await backend.repoInfo(repo), created, 'repoInfo reports what createRepo returned');
|
|
28
|
+
},
|
|
29
|
+
),
|
|
30
|
+
backendCase(GROUP, 'createRepo honours defaultBranch', async ({ backend, repo }) => {
|
|
31
|
+
const created = await backend.createRepo(repo, { defaultBranch: 'trunk' });
|
|
32
|
+
assertEqual(created.defaultBranch, 'trunk', 'createRepo result');
|
|
33
|
+
assertEqual((await backend.repoInfo(repo))?.defaultBranch, 'trunk', 'repoInfo');
|
|
34
|
+
}),
|
|
35
|
+
backendCase(
|
|
36
|
+
GROUP,
|
|
37
|
+
'createRepo of an existing name is repo_exists and leaves it untouched',
|
|
38
|
+
async (context) => {
|
|
39
|
+
const seeded = await seedRepo(context);
|
|
40
|
+
const error = await expectGatewayError(context.backend.createRepo(context.repo), 'repo_exists');
|
|
41
|
+
assertEqual(error.details.repo, context.repo, 'names the repository');
|
|
42
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'main'), seeded.sha, 'history kept');
|
|
43
|
+
},
|
|
44
|
+
),
|
|
45
|
+
backendCase(
|
|
46
|
+
GROUP,
|
|
47
|
+
'deleteRepo deletes, and deleting a missing repository does nothing',
|
|
48
|
+
async (context) => {
|
|
49
|
+
await seedRepo(context);
|
|
50
|
+
await context.backend.deleteRepo(context.repo);
|
|
51
|
+
assertEqual(await context.backend.repoInfo(context.repo), null, 'repoInfo is null after delete');
|
|
52
|
+
await context.backend.deleteRepo(context.repo);
|
|
53
|
+
await expectGatewayError(context.backend.resolveRef(context.repo, 'main'), 'repo_not_found');
|
|
54
|
+
},
|
|
55
|
+
),
|
|
56
|
+
backendCase(GROUP, 'repoInfo of a missing repository is null', async ({ backend, repo }) => {
|
|
57
|
+
assertEqual(await backend.repoInfo(repo), null, 'null');
|
|
58
|
+
}),
|
|
59
|
+
backendCase(
|
|
60
|
+
GROUP,
|
|
61
|
+
'every read and gitRemote on a missing repository is repo_not_found',
|
|
62
|
+
async ({ backend, repo }) => {
|
|
63
|
+
const calls: (() => Promise<unknown>)[] = [
|
|
64
|
+
() => backend.resolveRef(repo, 'main'),
|
|
65
|
+
() => backend.readCommit(repo, SHA),
|
|
66
|
+
() => backend.readTree(repo, SHA),
|
|
67
|
+
() => backend.readBlob(repo, SHA),
|
|
68
|
+
() => backend.readFile(repo, 'main', 'README.md'),
|
|
69
|
+
() => backend.log(repo, 'main', { limit: 10 }),
|
|
70
|
+
() => backend.gitRemote(repo, 'read'),
|
|
71
|
+
() => backend.gitRemote(repo, 'write'),
|
|
72
|
+
];
|
|
73
|
+
for (const call of calls) {
|
|
74
|
+
assertEqual(
|
|
75
|
+
(await expectGatewayError(call(), 'repo_not_found')).details.repo,
|
|
76
|
+
repo,
|
|
77
|
+
'names the repository',
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
),
|
|
82
|
+
backendCase(
|
|
83
|
+
GROUP,
|
|
84
|
+
'invalid arguments are invalid_input before the host is called',
|
|
85
|
+
async ({ backend, repo }) => {
|
|
86
|
+
await backend.createRepo(repo);
|
|
87
|
+
const calls: (() => Promise<unknown>)[] = [
|
|
88
|
+
() => backend.createRepo('bad name!'),
|
|
89
|
+
() => backend.createRepo(`${repo}-x`, { defaultBranch: 'bad..branch' }),
|
|
90
|
+
() => backend.repoInfo('x.git'),
|
|
91
|
+
() => backend.resolveRef(repo, 'refs/remotes/origin/main'),
|
|
92
|
+
() => backend.readCommit(repo, 'ABC'),
|
|
93
|
+
() => backend.readTree(repo, SHA.slice(1)),
|
|
94
|
+
() => backend.readBlob(repo, ''),
|
|
95
|
+
() => backend.readFile(repo, 'main', '/abs/path'),
|
|
96
|
+
() => backend.log(repo, 'main', { limit: 0 }),
|
|
97
|
+
() => backend.log(repo, 'main', { limit: 1001 }),
|
|
98
|
+
() => backend.gitRemote(repo, NOT_AN_ACCESS_LEVEL),
|
|
99
|
+
];
|
|
100
|
+
for (const call of calls) await expectGatewayError(call(), 'invalid_input');
|
|
101
|
+
assertEqual(await backend.repoInfo(`${repo}-x`), null, 'nothing was created');
|
|
102
|
+
},
|
|
103
|
+
),
|
|
104
|
+
backendCase(
|
|
105
|
+
GROUP,
|
|
106
|
+
'invalid arguments on a missing repository are invalid_input, not repo_not_found',
|
|
107
|
+
async ({ backend, repo }) => {
|
|
108
|
+
const calls: (() => Promise<unknown>)[] = [
|
|
109
|
+
() => backend.resolveRef(repo, 'refs/remotes/origin/main'),
|
|
110
|
+
() => backend.readCommit(repo, 'ABC'),
|
|
111
|
+
() => backend.readTree(repo, SHA.slice(1)),
|
|
112
|
+
() => backend.readBlob(repo, ''),
|
|
113
|
+
() => backend.readFile(repo, 'main', '/abs/path'),
|
|
114
|
+
() => backend.readFile(repo, 'bad..branch', 'README.md'),
|
|
115
|
+
() => backend.log(repo, 'main', { limit: 0 }),
|
|
116
|
+
() => backend.gitRemote(repo, NOT_AN_ACCESS_LEVEL),
|
|
117
|
+
];
|
|
118
|
+
for (const call of calls) await expectGatewayError(call(), 'invalid_input');
|
|
119
|
+
},
|
|
120
|
+
),
|
|
121
|
+
];
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { assertEqual, assertTrue } from '@leed-ai/git-gateway-contract/behaviour/assertions';
|
|
3
|
+
import { ZERO_SHA } from '@leed-ai/git-gateway-contract/schemas/sha';
|
|
4
|
+
|
|
5
|
+
import { backendCase, type BackendCase } from './backend-case.ts';
|
|
6
|
+
import { fixtureCommit } from './backend-fixtures.ts';
|
|
7
|
+
import {
|
|
8
|
+
expectAccepted,
|
|
9
|
+
expectRefused,
|
|
10
|
+
newObjects,
|
|
11
|
+
pushNewBranch,
|
|
12
|
+
pushRef,
|
|
13
|
+
seedRepo,
|
|
14
|
+
} from './push-helpers.ts';
|
|
15
|
+
|
|
16
|
+
const GROUP = 'push semantics';
|
|
17
|
+
const MAIN = 'refs/heads/main';
|
|
18
|
+
|
|
19
|
+
/** Ref updates through receive-pack: stale heads, fast-forward, force, create and delete. */
|
|
20
|
+
export const pushCases: readonly BackendCase[] = [
|
|
21
|
+
backendCase(GROUP, 'a fast-forward naming the current head is accepted', async (context) => {
|
|
22
|
+
const first = await seedRepo(context);
|
|
23
|
+
const second = await fixtureCommit({ 'README.md': '# Two\n' }, [first.sha]);
|
|
24
|
+
expectAccepted(await pushRef(context, MAIN, first.sha, second.sha, newObjects(second, first)), MAIN);
|
|
25
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'main'), second.sha, 'main moved');
|
|
26
|
+
}),
|
|
27
|
+
backendCase(GROUP, 'an update naming a stale old id is refused and changes nothing', async (context) => {
|
|
28
|
+
const first = await seedRepo(context);
|
|
29
|
+
const second = await fixtureCommit({ 'README.md': '# Two\n' }, [first.sha]);
|
|
30
|
+
expectAccepted(await pushRef(context, MAIN, first.sha, second.sha, second.objects), MAIN);
|
|
31
|
+
// A writer that still believes main is at `first` builds on it and pushes.
|
|
32
|
+
const stale = await fixtureCommit({ 'README.md': '# Stale\n' }, [first.sha]);
|
|
33
|
+
expectRefused(await pushRef(context, MAIN, first.sha, stale.sha, stale.objects), MAIN);
|
|
34
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'main'), second.sha, 'main unchanged');
|
|
35
|
+
}),
|
|
36
|
+
backendCase(GROUP, 'creating a branch that already exists (old id zero) is refused', async (context) => {
|
|
37
|
+
const first = await seedRepo(context);
|
|
38
|
+
const other = await fixtureCommit({ 'other.txt': 'o\n' });
|
|
39
|
+
expectRefused(await pushRef(context, MAIN, ZERO_SHA, other.sha, other.objects), MAIN);
|
|
40
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'main'), first.sha, 'main unchanged');
|
|
41
|
+
}),
|
|
42
|
+
backendCase(
|
|
43
|
+
GROUP,
|
|
44
|
+
'a non-fast-forward naming the current head follows the host behaviour',
|
|
45
|
+
async (context) => {
|
|
46
|
+
const first = await seedRepo(context);
|
|
47
|
+
const base = await fixtureCommit({ 'f.txt': 'base\n' }, [first.sha]);
|
|
48
|
+
await pushNewBranch(context, 'feature', base);
|
|
49
|
+
const rewritten = await fixtureCommit({ 'f.txt': 'rewritten\n' }, [first.sha]);
|
|
50
|
+
const report = await pushRef(
|
|
51
|
+
context,
|
|
52
|
+
'refs/heads/feature',
|
|
53
|
+
base.sha,
|
|
54
|
+
rewritten.sha,
|
|
55
|
+
newObjects(rewritten, first),
|
|
56
|
+
);
|
|
57
|
+
const head = await context.backend.resolveRef(context.repo, 'feature');
|
|
58
|
+
if (context.behaviour.nonFastForward === 'accepted') {
|
|
59
|
+
expectAccepted(report, 'refs/heads/feature');
|
|
60
|
+
assertEqual(head, rewritten.sha, 'feature rewritten');
|
|
61
|
+
} else {
|
|
62
|
+
expectRefused(report, 'refs/heads/feature');
|
|
63
|
+
assertEqual(head, base.sha, 'feature unchanged');
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
),
|
|
67
|
+
backendCase(
|
|
68
|
+
GROUP,
|
|
69
|
+
'a non-fast-forward naming a stale head is refused even when forced',
|
|
70
|
+
async (context) => {
|
|
71
|
+
const first = await seedRepo(context);
|
|
72
|
+
const moved = await fixtureCommit({ 'README.md': '# Moved\n' }, [first.sha]);
|
|
73
|
+
expectAccepted(await pushRef(context, MAIN, first.sha, moved.sha, moved.objects), MAIN);
|
|
74
|
+
const unrelated = await fixtureCommit({ 'x.txt': 'unrelated\n' });
|
|
75
|
+
expectRefused(await pushRef(context, MAIN, first.sha, unrelated.sha, unrelated.objects), MAIN);
|
|
76
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'main'), moved.sha, 'main unchanged');
|
|
77
|
+
},
|
|
78
|
+
),
|
|
79
|
+
backendCase(GROUP, 'a branch is deleted by a push naming its current head', async (context) => {
|
|
80
|
+
const first = await seedRepo(context);
|
|
81
|
+
const feature = await fixtureCommit({ 'f.txt': 'f\n' }, [first.sha]);
|
|
82
|
+
await pushNewBranch(context, 'feature', feature);
|
|
83
|
+
expectAccepted(await pushRef(context, 'refs/heads/feature', feature.sha, ZERO_SHA), 'refs/heads/feature');
|
|
84
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'feature'), null, 'feature gone');
|
|
85
|
+
const refs = (await (await context.client('write')).advertisement('git-receive-pack')).refs.map(
|
|
86
|
+
(ref) => ref.name,
|
|
87
|
+
);
|
|
88
|
+
assertTrue(!refs.includes('refs/heads/feature'), 'no longer advertised');
|
|
89
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'main'), first.sha, 'main untouched');
|
|
90
|
+
}),
|
|
91
|
+
backendCase(GROUP, 'a delete naming a stale head is refused', async (context) => {
|
|
92
|
+
const first = await seedRepo(context);
|
|
93
|
+
const feature = await fixtureCommit({ 'f.txt': 'f\n' }, [first.sha]);
|
|
94
|
+
await pushNewBranch(context, 'feature', feature);
|
|
95
|
+
expectRefused(await pushRef(context, 'refs/heads/feature', first.sha, ZERO_SHA), 'refs/heads/feature');
|
|
96
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'feature'), feature.sha, 'feature kept');
|
|
97
|
+
}),
|
|
98
|
+
backendCase(GROUP, 'a tag is created and deleted like a branch', async (context) => {
|
|
99
|
+
const first = await seedRepo(context);
|
|
100
|
+
expectAccepted(await pushRef(context, 'refs/tags/release', ZERO_SHA, first.sha), 'refs/tags/release');
|
|
101
|
+
assertEqual(
|
|
102
|
+
await context.backend.resolveRef(context.repo, 'refs/tags/release'),
|
|
103
|
+
first.sha,
|
|
104
|
+
'tag created',
|
|
105
|
+
);
|
|
106
|
+
expectAccepted(await pushRef(context, 'refs/tags/release', first.sha, ZERO_SHA), 'refs/tags/release');
|
|
107
|
+
assertEqual(await context.backend.resolveRef(context.repo, 'refs/tags/release'), null, 'tag deleted');
|
|
108
|
+
}),
|
|
109
|
+
backendCase(GROUP, 'of two concurrent pushes from the same head exactly one wins', async (context) => {
|
|
110
|
+
const first = await seedRepo(context);
|
|
111
|
+
const left = await fixtureCommit({ 'README.md': '# Left\n' }, [first.sha]);
|
|
112
|
+
const right = await fixtureCommit({ 'README.md': '# Right\n' }, [first.sha]);
|
|
113
|
+
const reports = await Promise.all([
|
|
114
|
+
pushRef(context, MAIN, first.sha, left.sha, left.objects),
|
|
115
|
+
pushRef(context, MAIN, first.sha, right.sha, right.objects),
|
|
116
|
+
]);
|
|
117
|
+
const winners = reports.filter((report) => report.refs.every((ref) => ref.status === 'ok'));
|
|
118
|
+
assertEqual(winners.length, 1, 'exactly one push succeeded');
|
|
119
|
+
const head = await context.backend.resolveRef(context.repo, 'main');
|
|
120
|
+
assertTrue(head === left.sha || head === right.sha, 'main names the winner');
|
|
121
|
+
assertEqual(head, winners[0] === reports[0] ? left.sha : right.sha, 'the winner is the one reported ok');
|
|
122
|
+
}),
|
|
123
|
+
];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { assertEqual, BehaviourFailure } from '@leed-ai/git-gateway-contract/behaviour/assertions';
|
|
3
|
+
import { ZERO_SHA } from '@leed-ai/git-gateway-contract/schemas/sha';
|
|
4
|
+
import type { GitObject } from '@leed-ai/git-gateway-core/schemas/git-object';
|
|
5
|
+
import type { ReportStatus } from '@leed-ai/git-gateway-core/schemas/report-status';
|
|
6
|
+
|
|
7
|
+
import type { BackendContext } from './backend-case.ts';
|
|
8
|
+
import { fixtureCommit, type FixtureCommit } from './backend-fixtures.ts';
|
|
9
|
+
|
|
10
|
+
/** Pushes one ref update (and the objects it needs) through a write remote; returns the report. */
|
|
11
|
+
export async function pushRef(
|
|
12
|
+
context: BackendContext,
|
|
13
|
+
ref: string,
|
|
14
|
+
oldSha: string,
|
|
15
|
+
newSha: string,
|
|
16
|
+
objects: readonly GitObject[] = [],
|
|
17
|
+
): Promise<ReportStatus> {
|
|
18
|
+
const client = await context.client('write');
|
|
19
|
+
return client.push([{ oldSha, newSha, ref }], objects);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Fails unless the report says the pack unpacked and `ref` was updated. */
|
|
23
|
+
export function expectAccepted(report: ReportStatus, ref: string): void {
|
|
24
|
+
assertEqual(report, { unpack: 'ok', refs: [{ ref, status: 'ok' }] }, `push to ${ref} accepted`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Fails unless the report refused `ref`; returns the reason the host gave. */
|
|
28
|
+
export function expectRefused(report: ReportStatus, ref: string): string {
|
|
29
|
+
const status = report.refs.find((entry) => entry.ref === ref);
|
|
30
|
+
if (status?.status !== 'ng') {
|
|
31
|
+
throw new BehaviourFailure(`expected the push to ${ref} to be refused, got ${JSON.stringify(report)}`);
|
|
32
|
+
}
|
|
33
|
+
return status.reason;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Pushes a commit as a new branch and fails unless it was accepted. */
|
|
37
|
+
export async function pushNewBranch(
|
|
38
|
+
context: BackendContext,
|
|
39
|
+
branch: string,
|
|
40
|
+
commit: FixtureCommit,
|
|
41
|
+
): Promise<void> {
|
|
42
|
+
expectAccepted(
|
|
43
|
+
await pushRef(context, `refs/heads/${branch}`, ZERO_SHA, commit.sha, commit.objects),
|
|
44
|
+
`refs/heads/${branch}`,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Creates the case's repository and pushes one commit to "main"; returns that commit. */
|
|
49
|
+
export async function seedRepo(
|
|
50
|
+
context: BackendContext,
|
|
51
|
+
files: Parameters<typeof fixtureCommit>[0] = { 'README.md': '# Seed\n' },
|
|
52
|
+
): Promise<FixtureCommit> {
|
|
53
|
+
await context.backend.createRepo(context.repo, { defaultBranch: 'main' });
|
|
54
|
+
const commit = await fixtureCommit(files);
|
|
55
|
+
await pushNewBranch(context, 'main', commit);
|
|
56
|
+
return commit;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The objects a child commit adds on top of its parent (everything not already pushed). */
|
|
60
|
+
export function newObjects(child: FixtureCommit, parent: FixtureCommit): GitObject[] {
|
|
61
|
+
const known = new Set(parent.objects.map((object) => object.sha));
|
|
62
|
+
return child.objects.filter((object) => !known.has(object.sha));
|
|
63
|
+
}
|