fix: preserve canonical sub-repos normalization semantics
This commit is contained in:
@@ -110,10 +110,11 @@ function normalizeLegacyKeys(parsed) {
|
|||||||
if (Object.prototype.hasOwnProperty.call(result, 'sub_repos')) {
|
if (Object.prototype.hasOwnProperty.call(result, 'sub_repos')) {
|
||||||
const value = result.sub_repos;
|
const value = result.sub_repos;
|
||||||
const planning = result.planning ?? {};
|
const planning = result.planning ?? {};
|
||||||
if (!planning.sub_repos) {
|
if (planning.sub_repos === undefined) {
|
||||||
result.planning = { ...planning, sub_repos: value };
|
result.planning = { ...planning, sub_repos: value };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// canonical nested wins — just drop the stale top-level
|
||||||
result.planning = { ...planning };
|
result.planning = { ...planning };
|
||||||
}
|
}
|
||||||
delete result.sub_repos;
|
delete result.sub_repos;
|
||||||
|
|||||||
@@ -216,6 +216,14 @@ describe('normalizeLegacyKeys', () => {
|
|||||||
// canonical nested wins
|
// canonical nested wins
|
||||||
expect((parsed as Record<string, Record<string, unknown>>).git?.branching_strategy).toBe('phase');
|
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 ───────────────────────────────────────────────────────────
|
// ─── mergeDefaults ───────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -174,9 +174,10 @@ export function normalizeLegacyKeys(parsed: Record<string, unknown>): Normalizat
|
|||||||
if (Object.prototype.hasOwnProperty.call(result, 'sub_repos')) {
|
if (Object.prototype.hasOwnProperty.call(result, 'sub_repos')) {
|
||||||
const value = result.sub_repos;
|
const value = result.sub_repos;
|
||||||
const planning = (result.planning as Record<string, unknown> | undefined) ?? {};
|
const planning = (result.planning as Record<string, unknown> | undefined) ?? {};
|
||||||
if (!planning.sub_repos) {
|
if (planning.sub_repos === undefined) {
|
||||||
result.planning = { ...planning, sub_repos: value };
|
result.planning = { ...planning, sub_repos: value };
|
||||||
} else {
|
} else {
|
||||||
|
// canonical nested wins — just drop the stale top-level
|
||||||
result.planning = { ...planning };
|
result.planning = { ...planning };
|
||||||
}
|
}
|
||||||
delete result.sub_repos;
|
delete result.sub_repos;
|
||||||
|
|||||||
Reference in New Issue
Block a user