From 684c35bc008c6e4149b555a4ab37d0f4115b6ec8 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 15 May 2026 03:04:27 +0000 Subject: [PATCH] fix: skip missing sync paths in commit step --- app/git.js | 5 ++++- app/git.test.js | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/git.js b/app/git.js index 02637fa..140420d 100644 --- a/app/git.js +++ b/app/git.js @@ -74,7 +74,10 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync) fs.copyFileSync(src, dest); } - run(['add', ...SYNC_PATHS], repoDir); + const existingSyncPaths = SYNC_PATHS.filter(relPath => fs.existsSync(path.join(repoDir, relPath))); + if (existingSyncPaths.length > 0) { + run(['add', ...existingSyncPaths], repoDir); + } const status = run(['status', '--porcelain'], repoDir); if (!status) { diff --git a/app/git.test.js b/app/git.test.js index e1131e3..c9ab8e2 100644 --- a/app/git.test.js +++ b/app/git.test.js @@ -101,6 +101,19 @@ describe('commitAndPush', () => { assert.ok(!addCall.args.includes('README.md')); }); + it('does not add missing sync paths', async () => { + const missingPath = path.join(workspace, '.amazonq/rules/triage-findings.md'); + fs.rmSync(missingPath, { force: true }); + fs.rmSync(path.join(workspace, 'repo', '.amazonq/rules/triage-findings.md'), { force: true }); + const spawn = makeSpawn(); + + await commitAndPush(workspace, path.join(workspace, 'repo'), spawn); + + const addCall = spawn.calls.find(c => c.args[0] === 'add'); + assert.ok(addCall, 'expected git add to run'); + assert.ok(!addCall.args.includes('.amazonq/rules/triage-findings.md')); + }); + it('overwrites existing repo copies with workspace files', async () => { const repoDir = path.join(workspace, 'repo'); fs.writeFileSync(path.join(repoDir, '.github/skills/triage-findings/SKILL.md'), 'stale');