fix: skip missing sync paths in commit step

This commit is contained in:
2026-05-15 03:04:27 +00:00
parent 93c602b86a
commit 684c35bc00
2 changed files with 17 additions and 1 deletions
+4 -1
View File
@@ -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) {
+13
View File
@@ -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');