mirror of
https://github.com/mvschwarz/openrig.git
synced 2026-11-08 08:11:17 -10:00
fix(upgrade): preserve non-directory prefixes
This commit is contained in:
1 parent
d66166ad71
commit
13531c176c
4 files changed
+39
-8
No files matched your search
+3
-3
@@ -44,10 +44,10 @@ function same(left, right) {
|
||||
return left?.kind === "file" && right?.kind === "file" && left.hash === right.hash;
|
||||
}
|
||||
|
||||
function hasUnsupportedLiveAncestor(relative, live) {
|
||||
function hasNonDirectoryLiveAncestor(relative, live) {
|
||||
const parts = relative.split("/");
|
||||
return parts.slice(0, -1).some((_, index) => (
|
||||
live.get(parts.slice(0, index + 1).join("/"))?.kind === "unsupported"
|
||||
live.has(parts.slice(0, index + 1).join("/"))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ const paths = [...new Set([
|
||||
])].sort();
|
||||
const actions = paths.map((relative) => ({
|
||||
path: relative,
|
||||
decision: hasUnsupportedLiveAncestor(relative, inventories.live)
|
||||
decision: hasNonDirectoryLiveAncestor(relative, inventories.live)
|
||||
? "preserve-unsupported-type"
|
||||
: classify(
|
||||
inventories.ancestor.get(relative),
|
||||
|
||||
@@ -139,6 +139,37 @@ describe("refresh-managed-plugin helper", () => {
|
||||
expect(fs.existsSync(path.join(external, "SKILL.md"))).toBe(false);
|
||||
expect(fs.lstatSync(path.join(live, "skills/linked")).isSymbolicLink()).toBe(true);
|
||||
});
|
||||
|
||||
it("preserves target descendants beneath live file parents", () => {
|
||||
const root = temporaryRoot();
|
||||
const ancestor = path.join(root, "ancestor");
|
||||
const target = path.join(root, "target");
|
||||
const live = path.join(root, "live");
|
||||
|
||||
fs.mkdirSync(ancestor, { recursive: true });
|
||||
write(target, "skills/blocked/SKILL.md", "new skill");
|
||||
write(live, "skills/blocked", "operator file");
|
||||
|
||||
const planned = runJson("refresh-managed-plugin.mjs", [
|
||||
"--ancestor", ancestor,
|
||||
"--target", target,
|
||||
"--live", live,
|
||||
]);
|
||||
expect(planned.actions).toEqual(expect.arrayContaining([
|
||||
{ path: "skills/blocked", decision: "preserve-live-only" },
|
||||
{ path: "skills/blocked/SKILL.md", decision: "preserve-unsupported-type" },
|
||||
]));
|
||||
|
||||
const applied = runJson("refresh-managed-plugin.mjs", [
|
||||
"--ancestor", ancestor,
|
||||
"--target", target,
|
||||
"--live", live,
|
||||
"--apply-safe",
|
||||
]);
|
||||
expect(applied.written).not.toContain("skills/blocked/SKILL.md");
|
||||
expect(fs.readFileSync(path.join(live, "skills/blocked"), "utf8")).toBe("operator file");
|
||||
expect(fs.existsSync(path.join(live, "skills/blocked/SKILL.md"))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("backup-sqlite helper", () => {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"core/openrig-upgrade/SKILL.md": "7b5987a02eedc3980697432fa24e36fda6e25fa427e203f18d98f00c9f8514fb",
|
||||
"core/openrig-upgrade/scripts/backup-sqlite.mjs": "52fe3015a0399986b586b6603e0664f61136d2210611b1638110a7b6b06e38b4",
|
||||
"core/openrig-upgrade/scripts/inspect-upgrade.mjs": "0f9239f3f8ad75885e985433576ffba9cf155dd8616801dd73d60bf3e9990a2a",
|
||||
"core/openrig-upgrade/scripts/refresh-managed-plugin.mjs": "694ca1b8e8965d4d03e8f02da1d8d0418f3dd57899521f06dd92fd5fe856c666",
|
||||
"core/openrig-upgrade/scripts/refresh-managed-plugin.mjs": "5dec7e53d32da93d07bdf0511daf65470ddc9ced5564ab935e07d9a04156e15a",
|
||||
"core/rig-bundles-and-shareable-artifacts/SKILL.md": "e9d5103f419b971373e374474e6ef464e05f242f3fa25e63acfc0b2106651748",
|
||||
"core/rig-lifecycle/SKILL.md": "8346e01d532795b24c3dba63413ca662c7b44cc5eed39ee2e85568580f40adca",
|
||||
"core/session-source-fork/SKILL.md": "80b5f8dce680d5799ceb30ea3c962a8538f5bd0bd40de75eddcf28a79f424006",
|
||||
@@ -105,7 +105,7 @@
|
||||
"core/openrig-upgrade/SKILL.md": "7b5987a02eedc3980697432fa24e36fda6e25fa427e203f18d98f00c9f8514fb",
|
||||
"core/openrig-upgrade/scripts/backup-sqlite.mjs": "52fe3015a0399986b586b6603e0664f61136d2210611b1638110a7b6b06e38b4",
|
||||
"core/openrig-upgrade/scripts/inspect-upgrade.mjs": "0f9239f3f8ad75885e985433576ffba9cf155dd8616801dd73d60bf3e9990a2a",
|
||||
"core/openrig-upgrade/scripts/refresh-managed-plugin.mjs": "694ca1b8e8965d4d03e8f02da1d8d0418f3dd57899521f06dd92fd5fe856c666",
|
||||
"core/openrig-upgrade/scripts/refresh-managed-plugin.mjs": "5dec7e53d32da93d07bdf0511daf65470ddc9ced5564ab935e07d9a04156e15a",
|
||||
"core/rig-bundles-and-shareable-artifacts/SKILL.md": "e9d5103f419b971373e374474e6ef464e05f242f3fa25e63acfc0b2106651748",
|
||||
"core/rig-lifecycle/SKILL.md": "8346e01d532795b24c3dba63413ca662c7b44cc5eed39ee2e85568580f40adca",
|
||||
"core/session-source-fork/SKILL.md": "80b5f8dce680d5799ceb30ea3c962a8538f5bd0bd40de75eddcf28a79f424006",
|
||||
|
||||
@@ -44,10 +44,10 @@ function same(left, right) {
|
||||
return left?.kind === "file" && right?.kind === "file" && left.hash === right.hash;
|
||||
}
|
||||
|
||||
function hasUnsupportedLiveAncestor(relative, live) {
|
||||
function hasNonDirectoryLiveAncestor(relative, live) {
|
||||
const parts = relative.split("/");
|
||||
return parts.slice(0, -1).some((_, index) => (
|
||||
live.get(parts.slice(0, index + 1).join("/"))?.kind === "unsupported"
|
||||
live.has(parts.slice(0, index + 1).join("/"))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ const paths = [...new Set([
|
||||
])].sort();
|
||||
const actions = paths.map((relative) => ({
|
||||
path: relative,
|
||||
decision: hasUnsupportedLiveAncestor(relative, inventories.live)
|
||||
decision: hasNonDirectoryLiveAncestor(relative, inventories.live)
|
||||
? "preserve-unsupported-type"
|
||||
: classify(
|
||||
inventories.ancestor.get(relative),
|
||||
|
||||
Reference in new issue
Block a user