Skip to content

Commit

Permalink
ignore history folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jmagoon committed Nov 26, 2024
1 parent 70d1132 commit 89a4edf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions frontend/server/execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export async function syncExecutionResults(
fs.mkdirSync(localBlockDir, { recursive: true });
}

console.log(`syncing ${localBlockDir} block ${blocksS3Prefix}`);

try {
await syncS3ToLocalDirectory(
blocksS3Prefix,
Expand Down
36 changes: 36 additions & 0 deletions frontend/server/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: "[email protected]",
},
});
}

// 3. Check for changes
const statusMatrix = await git.statusMatrix({ fs, dir: cachePath });
const hasChanges = statusMatrix.some(
Expand Down

0 comments on commit 89a4edf

Please sign in to comment.