diff --git a/docs/developers/share-source.mdx b/docs/developers/share-source.mdx index 317ba2f2e1..0b41a593a6 100644 --- a/docs/developers/share-source.mdx +++ b/docs/developers/share-source.mdx @@ -55,6 +55,11 @@ excluding `index.html` are rejected. Do not exclude assets your composition uses These rules can only exclude files, never re-include credentials or other files blocked by the portable project policy. +Cloud render reads the same file as gitignore syntax, so it may hold rules this +reader rejects, such as `/exports/` or `**/*.mov`. Source capture then stops with +an error. Change detection keeps working and ignores the file's rules, so those +files still count as changes. + The upload uses the workspace's file-count, per-file, project-size and manifest limits. Large media uploads in parts. Only a verified published snapshot that still matches the rendered project can be attached to the video version. The CLI diff --git a/packages/share/src/projectSnapshot.mjs b/packages/share/src/projectSnapshot.mjs index 7370bd839a..09976350a8 100644 --- a/packages/share/src/projectSnapshot.mjs +++ b/packages/share/src/projectSnapshot.mjs @@ -1,7 +1,7 @@ // @ts-check // A project's files as change detection sees them: every file the film can use (isOutsideFilm), keyed by mtime and // size, except html, keyed by content without the data-hf-id stamps. A run's change set and the watcher both read it. -import { readSourceIgnore } from "./sourceIgnore.mjs"; +import { readChangeIgnore } from "./sourceIgnore.mjs"; import fs from "node:fs/promises"; import { constants } from "node:fs"; import path from "node:path"; @@ -61,7 +61,7 @@ async function entryKind(entry, full, followSymlinks) { export async function snapshotProject(dir, { byContent = false, followSymlinks = false } = {}) { /** @type {Snapshot} */ const result = new Map(); - const ignored = await readSourceIgnore(dir); + const ignored = await readChangeIgnore(dir); /** @param {string} current @param {Set} ancestors */ async function walk(current, ancestors) { const real = await fs.realpath(current).catch(() => null); @@ -102,7 +102,7 @@ export function snapshotFingerprint(snapshot) { export async function snapshotFiles(dir, files) { /** @type {Map} */ const result = new Map(); - const ignored = await readSourceIgnore(dir); + const ignored = await readChangeIgnore(dir); for (const file of files) { const full = path.join(dir, file); const stat = await fs.lstat(full).catch(() => null); diff --git a/packages/share/src/sourceIgnore.mjs b/packages/share/src/sourceIgnore.mjs index 3928b94e9f..82953e6943 100644 --- a/packages/share/src/sourceIgnore.mjs +++ b/packages/share/src/sourceIgnore.mjs @@ -63,6 +63,14 @@ export async function readSourceIgnore(root) { return (path) => scratch(path) || entries.some((entry) => entry.test(path)); } +/** The exclusions change detection applies. Change detection must keep working whatever the file holds: the CLI + * reads `.hyperframesignore` as gitignore syntax (`/renders/`, `**`, `!keep`), which this reader refuses. An + * unreadable file then excludes only scratch files, so a scan sees more files, never fewer. Source capture keeps + * the strict reader and still refuses the file. @param {string} root @returns {Promise<(path: string) => boolean>} */ +export async function readChangeIgnore(root) { + return readSourceIgnore(root).catch(() => scratch); +} + /** @param {string} entry */ function ignorePattern(entry) { const path = entry.replace(/\/$/, ""); diff --git a/packages/share/tests/kernel.test.mjs b/packages/share/tests/kernel.test.mjs index ef8d4dd97a..dceaaee6ac 100644 --- a/packages/share/tests/kernel.test.mjs +++ b/packages/share/tests/kernel.test.mjs @@ -649,3 +649,39 @@ test("a video-only retry never replays an unanswered source-bearing export", asy ); assert.equal(creates, 1); }); +test("change detection keeps working when .hyperframesignore uses gitignore syntax", async (t) => { + for (const rule of ["/renders/", "**/*.mov", "!keep.mp4", "assets/*/raw-*.mp4", "a[bc].png"]) { + const dir = await folder(t); + await mkdir(join(dir, "assets")); + await writeFile(join(dir, "index.html"), "
Hello
"); + await writeFile(join(dir, "assets/clip.mov"), "clip"); + await writeFile(join(dir, ".hyperframesignore"), `${rule}\n`); + // The CLI's syntax is not this reader's: nothing is excluded beyond scratch, so a change still counts. + const files = await snapshotProject(dir); + assert.deepEqual([...files.keys()].sort(), ["assets/clip.mov", "index.html"], rule); + // snapshotFiles names every file asked for; an excluded one is keyed undefined. + assert.notEqual( + (await snapshotFiles(dir, ["assets/clip.mov"])).get("assets/clip.mov"), + undefined, + rule, + ); + const before = await projectFingerprint(dir); + await writeFile(join(dir, "assets/clip.mov"), "edited clip"); + assert.notEqual(await projectFingerprint(dir), before, rule); + } +}); +test("change detection keeps working when .hyperframesignore is a link", async (t) => { + const dir = await folder(t); + await writeFile(join(dir, "index.html"), "
Hello
"); + await symlink(join(dir, "index.html"), join(dir, ".hyperframesignore")); + assert.deepEqual([...(await snapshotProject(dir)).keys()], ["index.html"]); +}); +test("change detection still applies a .hyperframesignore it can read", async (t) => { + const dir = await folder(t); + await mkdir(join(dir, "assets")); + await writeFile(join(dir, "index.html"), "
Hello
"); + await writeFile(join(dir, "assets/raw.mov"), "raw"); + await writeFile(join(dir, "debug.log"), "log"); + await writeFile(join(dir, ".hyperframesignore"), "assets/raw.mov\n"); + assert.deepEqual([...(await snapshotProject(dir)).keys()], ["index.html"]); +});