Skip to content

Commit 4738679

Browse files
donjor-agent[bot]rsi-pr-agent
authored andcommitted
fix(fork-sync): the license merge keys an unnamed entry on its repositoryUrl (#1616)
> 🤖 claude/anthropic claude-opus-5-5 (high) ## Problem The sync's license resolver keys `third-party-licenses.config.json` entries on `name`. Upstream's `packageOverrides` now has 5 entries with only `repositoryUrl`, so the resolver refuses every conflict on that file. The `.2638` sync's license conflict had to be merged by hand. ## Change An entry's key is its `name`, or its `repositoryUrl` when it has no name. An entry with neither still refuses. ## Scope and approval Follow-up F2 from the `.2638` UAT, #1607, accepted by the maintainer. Not covered: the landing rerun's rewrite of one `é` escape to a literal character (same JSON, different bytes). ## Verification | check | result | | --- | --- | | `vp test run scripts/lib/fork-license-merge.test.ts` | 8 passed, 1 new | | Merge of trunk's real config with itself | merged, JSON equal; refused before | | `vp run fork:ci` | exit 0; scripts 732/732 | Claude Opus 5.5 in Claude Code, inside T3 Code. ## Fork trailers Squashes: - 2d609f2 fix(fork-sync): the license merge keys an unnamed entry on its repositoryUrl (#1616) (#1616) - 7299065 fixup! fix(fork-sync): the license merge keys an unnamed entry on its repositoryUrl (#1616) (#1616) Fork-Domain: fork-meta Fork-Tier: core Fork-Upstreamable: no
1 parent f722f9e commit 4738679

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

‎scripts/lib/fork-license-merge.test.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ it("merges top-level keys three ways and appends the fork's new keys", () => {
7272
);
7373
});
7474

75+
it("keys an entry without a name on its repositoryUrl", () => {
76+
const url = (repositoryUrl: string, license?: string) => ({ repositoryUrl, license });
77+
const overrides = (packageOverrides: ReadonlyArray<object>) =>
78+
`${JSON.stringify({ packageOverrides }, null, 2)}\n`;
79+
assert.deepStrictEqual(
80+
merged({
81+
base: overrides([url("https://x/a")]),
82+
upstream: overrides([url("https://x/a", "MIT"), url("https://x/up")]),
83+
fork: overrides([url("https://x/a"), { name: "fork" }]),
84+
}),
85+
{
86+
packageOverrides: [
87+
{ repositoryUrl: "https://x/a", license: "MIT" },
88+
{ repositoryUrl: "https://x/up" },
89+
{ name: "fork" },
90+
],
91+
},
92+
);
93+
});
94+
7595
it("refuses an entry both sides changed apart", () => {
7696
assert.strictEqual(
7797
refusal({
@@ -105,7 +125,7 @@ it("refuses a deleted file, an unnamed or duplicate entry, and invalid JSON", ()
105125
);
106126
assert.strictEqual(
107127
refusal({ base, upstream: base, fork: `{"customNotices":[{"license":"MIT"}]}` }),
108-
"a customNotices entry has no string name",
128+
"a customNotices entry has no string name or repositoryUrl",
109129
);
110130
assert.match(refusal({ base, upstream: base, fork: "{" }), /JSON/);
111131
});

‎scripts/lib/fork-license-merge.ts‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
// @effect-diagnostics nodeBuiltinImport:off - The sync driver runs this resolver before any Effect runtime exists.
22

3-
// The license-list resolver the sync's stop loop runs on a conflicted
4-
// `third-party-licenses.config.json` (RSI-Software/t3code-hyprws#1488).
5-
//
6-
// The config is authored input: `vp run licenses:sync` reads it and never
7-
// reproduces it, so no generator can rebuild a conflicted copy. Both sides
8-
// append entries to the same arrays instead, which is a union keyed on each
9-
// entry's `name`. Every array keeps upstream's order, then the fork's
10-
// additions in the fork's order. A name both sides changed, a delete of an
11-
// entry the other side changed, or an entry without a unique `name` refuses.
3+
// Resolves a conflicted `third-party-licenses.config.json` in the sync's stop loop. The config is
4+
// authored input no generator rebuilds, so arrays union on each entry's `name` (else its
5+
// `repositoryUrl`), upstream's order first, then the fork's additions. A key both sides changed, a
6+
// delete of an entry the other side changed, or an entry without a unique key refuses.
127

138
import * as NodeUtil from "node:util";
149

@@ -26,11 +21,19 @@ const pick = (base: Json, upstream: Json, fork: Json, what: string): Json => {
2621
throw new Refusal(`both sides changed ${what}`);
2722
};
2823

24+
/** An entry's identity: its `name`, or its `repositoryUrl` when upstream omits the name. */
25+
const identity = (entry: Json): unknown => {
26+
const { name, repositoryUrl } =
27+
(entry as { readonly name?: unknown; readonly repositoryUrl?: unknown } | null) ?? {};
28+
return name ?? repositoryUrl;
29+
};
30+
2931
const byName = (entries: ReadonlyArray<Json>, key: string): Map<string, Json> => {
3032
const named = new Map<string, Json>();
3133
for (const entry of entries) {
32-
const name = (entry as { readonly name?: unknown } | null)?.name;
33-
if (typeof name !== "string") throw new Refusal(`a ${key} entry has no string name`);
34+
const name = identity(entry);
35+
if (typeof name !== "string")
36+
throw new Refusal(`a ${key} entry has no string name or repositoryUrl`);
3437
if (named.has(name)) throw new Refusal(`${key} names "${name}" twice`);
3538
named.set(name, entry);
3639
}

0 commit comments

Comments
 (0)