fix: preserve canonical sub-repos normalization semantics

This commit is contained in:
Tom Boucher
2026-05-15 09:25:49 -04:00
parent 12a9f4f038
commit 173743fd9e
3 changed files with 12 additions and 2 deletions

View File

@@ -110,10 +110,11 @@ function normalizeLegacyKeys(parsed) {
if (Object.prototype.hasOwnProperty.call(result, 'sub_repos')) {
const value = result.sub_repos;
const planning = result.planning ?? {};
if (!planning.sub_repos) {
if (planning.sub_repos === undefined) {
result.planning = { ...planning, sub_repos: value };
}
else {
// canonical nested wins — just drop the stale top-level
result.planning = { ...planning };
}
delete result.sub_repos;

View File

@@ -216,6 +216,14 @@ describe('normalizeLegacyKeys', () => {
// canonical nested wins
expect((parsed as Record<string, Record<string, unknown>>).git?.branching_strategy).toBe('phase');
});
it('preserves canonical planning.sub_repos when both top-level and nested exist', () => {
const input = { sub_repos: ['legacy'], planning: { sub_repos: null } };
const { parsed } = normalizeLegacyKeys(input);
expect((parsed as Record<string, Record<string, unknown>>).sub_repos).toBeUndefined();
// canonical nested wins even when explicit null is used to unset
expect((parsed as Record<string, Record<string, unknown>>).planning?.sub_repos).toBeNull();
});
});
// ─── mergeDefaults ───────────────────────────────────────────────────────────

View File

@@ -174,9 +174,10 @@ export function normalizeLegacyKeys(parsed: Record<string, unknown>): Normalizat
if (Object.prototype.hasOwnProperty.call(result, 'sub_repos')) {
const value = result.sub_repos;
const planning = (result.planning as Record<string, unknown> | undefined) ?? {};
if (!planning.sub_repos) {
if (planning.sub_repos === undefined) {
result.planning = { ...planning, sub_repos: value };
} else {
// canonical nested wins — just drop the stale top-level
result.planning = { ...planning };
}
delete result.sub_repos;