fix: skip git commit/push in removeCustomerChart if file was never tracked
Some checks failed
Build & Release / build (push) Has been cancelled

This commit is contained in:
Ryan Moon
2026-04-03 19:38:46 -05:00
parent c517b1c1cd
commit b8002af82b

View File

@@ -21,7 +21,8 @@ function withRepo<T>(fn: (dir: string, env: NodeJS.ProcessEnv) => T): T {
execSync(`git -C ${dir} config user.email "manager@lunarfront.tech"`, { env });
execSync(`git -C ${dir} config user.name "lunarfront-manager"`, { env });
const result = fn(dir, env);
execSync(`git -C ${dir} push origin main`, { env, stdio: "pipe" });
const unpushed = execSync(`git -C ${dir} log origin/main..HEAD --oneline`, { env }).toString().trim();
if (unpushed) execSync(`git -C ${dir} push origin main`, { env, stdio: "pipe" });
return result;
} finally {
rmSync(dir, { recursive: true, force: true });
@@ -40,7 +41,10 @@ export function addCustomerChart(slug: string, appVersion: string) {
export function removeCustomerChart(slug: string) {
withRepo((dir, env) => {
rmSync(join(dir, "customers", `${slug}.yaml`), { force: true });
const filePath = join(dir, "customers", `${slug}.yaml`);
const tracked = execSync(`git -C ${dir} ls-files customers/${slug}.yaml`, { env }).toString().trim();
if (!tracked) return;
rmSync(filePath, { force: true });
execSync(`git -C ${dir} add customers/${slug}.yaml`, { env });
execSync(`git -C ${dir} commit -m "chore: deprovision customer ${slug}"`, { env });
});