diff --git a/frontend/server/execution.js b/frontend/server/execution.js index d101bb70..856b377b 100644 --- a/frontend/server/execution.js +++ b/frontend/server/execution.js @@ -44,6 +44,8 @@ export async function syncExecutionResults( fs.mkdirSync(localBlockDir, { recursive: true }); } + console.log(`syncing ${localBlockDir} block ${blocksS3Prefix}`); + try { await syncS3ToLocalDirectory( blocksS3Prefix, diff --git a/frontend/server/git.js b/frontend/server/git.js index 4b9ca985..da2efbef 100644 --- a/frontend/server/git.js +++ b/frontend/server/git.js @@ -3,6 +3,24 @@ import fs from "fs"; import path from "path"; import { cacheJoin } from "./cache.js"; +async function ensureGitignore(dir) { + const gitignorePath = path.join(dir, ".gitignore"); + try { + // Check if .gitignore exists + await fs.promises.access(gitignorePath); + const content = await fs.promises.readFile(gitignorePath, "utf8"); + if (!content.includes("history/")) { + await fs.promises.appendFile(gitignorePath, "\nhistory/\n"); + return true; // indicates .gitignore was modified + } + return false; // indicates no changes were needed + } catch (e) { + // .gitignore doesn't exist, create it + await fs.promises.writeFile(gitignorePath, "history/\n", "utf8"); + return true; // indicates .gitignore was created + } +} + export async function ensureGitRepoAndCommitBlocks( buildContextStatuses, buildPath, @@ -64,6 +82,24 @@ export async function ensureGitRepoAndCommitBlocks( }); } + const gitignoreModified = await ensureGitignore(cachePath); + + if (gitignoreModified) { + // Add and commit .gitignore if it was created or modified + await git.add({ fs, dir: cachePath, filepath: ".gitignore" }); + await git.commit({ + fs, + dir: cachePath, + message: isRepo + ? "chore: update .gitignore" + : "chore: initial commit with .gitignore", + author: { + name: "Pipeline System", + email: "pipeline@system.local", + }, + }); + } + // 3. Check for changes const statusMatrix = await git.statusMatrix({ fs, dir: cachePath }); const hasChanges = statusMatrix.some(