Skip to content

Commit 03633fd

Browse files
authored
Exclude Codebox control files from publication snapshots (#1848)
1 parent c30df7f commit 03633fd

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

packages/runtime-core/src/runner-workspace-apply.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ function validatePatchPaths(patch: string, changed: RunnerWorkspaceChangedFile[]
236236
async function snapshotWorkspace(root: string): Promise<RunnerWorkspacePublicationFile[]> {
237237
const output: RunnerWorkspacePublicationFile[] = []
238238
const { stdout } = await execFileAsync("git", ["ls-files", "--cached", "--others", "--exclude-standard", "-z"], { cwd: root, maxBuffer: MAX_PATCH_BYTES })
239-
const paths = stdout.split("\0").filter(Boolean).sort((left, right) => left.localeCompare(right))
239+
const paths = stdout.split("\0")
240+
.filter((path) => path && path !== ".codebox" && !path.startsWith(".codebox/"))
241+
.sort((left, right) => left.localeCompare(right))
240242
for (const path of paths) {
241243
const absolute = resolve(root, path)
242244
if (!pathIsWithinRoot(absolute, root)) throw new Error(`Runner workspace contains a denied path: ${path}`)

tests/runner-workspace-apply.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ const files = [{ path: "/workspace/README.md", relativePath: "README.md", status
130130
await verifyRunnerWorkspaceIntegrity(result.integrity!)
131131
}
132132

133+
{
134+
const input = await fixture(patch, files)
135+
const controlDirectory = join(input.workspace, ".codebox")
136+
await mkdir(controlDirectory)
137+
await writeFile(join(controlDirectory, "request.json"), "before\n")
138+
const result = await applyRunnerWorkspacePatch({
139+
artifactRoot: input.artifacts,
140+
artifactRefs: input.refs,
141+
workspaceRoot: input.workspace,
142+
writablePaths: ["README.md"],
143+
verify: async () => {
144+
await writeFile(join(controlDirectory, "request.json"), "after\n")
145+
await writeFile(join(controlDirectory, "result.json"), "complete\n")
146+
},
147+
})
148+
await verifyRunnerWorkspaceIntegrity(result.integrity!)
149+
}
150+
133151
{
134152
const input = await fixture(patch, files)
135153
await symlink(input.artifacts, join(input.workspace, "publishable-link"))

0 commit comments

Comments
 (0)