fix: skip missing sync paths in commit step
This commit is contained in:
+4
-1
@@ -74,7 +74,10 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync)
|
|||||||
fs.copyFileSync(src, dest);
|
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);
|
const status = run(['status', '--porcelain'], repoDir);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
|
|||||||
@@ -101,6 +101,19 @@ describe('commitAndPush', () => {
|
|||||||
assert.ok(!addCall.args.includes('README.md'));
|
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 () => {
|
it('overwrites existing repo copies with workspace files', async () => {
|
||||||
const repoDir = path.join(workspace, 'repo');
|
const repoDir = path.join(workspace, 'repo');
|
||||||
fs.writeFileSync(path.join(repoDir, '.github/skills/triage-findings/SKILL.md'), 'stale');
|
fs.writeFileSync(path.join(repoDir, '.github/skills/triage-findings/SKILL.md'), 'stale');
|
||||||
|
|||||||
Reference in New Issue
Block a user