diff --git a/app/git.js b/app/git.js index 6fb4bcb..d7fc88e 100644 --- a/app/git.js +++ b/app/git.js @@ -5,9 +5,9 @@ import { fileURLToPath } from 'url'; import { GITEA_SERVER_URL, GITEA_REPOSITORY, GITEA_TOKEN, PR_HEAD_BRANCH, FINDINGS_PATH } from './config.js'; const ACTION_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const GENERATED_SYNC_PATHS = [FINDINGS_PATH, '.gitea/ai-review/exclusions.json']; const remoteUrl = `${GITEA_SERVER_URL.replace(/\/$/, '')}/${GITEA_REPOSITORY}.git`; export const SYNC_PATHS = [ - FINDINGS_PATH, '.amazonq/rules/triage-findings.md', '.codex/skills/triage-findings/SKILL.md', '.codex/skills/triage-findings/agents/openai.yaml', @@ -86,6 +86,10 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync, if (existingSyncPaths.length > 0) { run(['add', ...existingSyncPaths], repoDir); } + const generatedSyncPaths = GENERATED_SYNC_PATHS.filter(relPath => fs.existsSync(path.join(repoDir, relPath))); + if (generatedSyncPaths.length > 0) { + run(['add', ...generatedSyncPaths], repoDir); + } const status = run(['status', '--porcelain'], repoDir); if (!status) { diff --git a/app/git.test.js b/app/git.test.js index 7dc33bd..c519d15 100644 --- a/app/git.test.js +++ b/app/git.test.js @@ -94,20 +94,28 @@ describe('commitAndPush', () => { }); it('adds skill and entry files together with findings', async () => { + const repoDir = path.join(workspace, 'repo'); + fs.mkdirSync(path.join(repoDir, '.gitea/ai-review'), { recursive: true }); + fs.writeFileSync(path.join(repoDir, '.gitea/ai-review/findings.json'), '[]\n'); + fs.writeFileSync(path.join(repoDir, '.gitea/ai-review/exclusions.json'), '[]\n'); const spawn = makeSpawn(); - await commitAndPush(workspace, path.join(workspace, 'repo'), spawn, sourceRoot); - const addCall = spawn.calls.find(c => c.args[0] === 'add'); - assert.ok(addCall, 'expected git add to run'); - assert.ok(addCall.args.includes('.github/skills/triage-findings/SKILL.md')); - assert.ok(addCall.args.includes('.codex/skills/triage-findings/SKILL.md')); - assert.ok(addCall.args.includes('.codex/skills/triage-findings/agents/openai.yaml')); - assert.ok(addCall.args.includes('.claude/skills/triage-findings/SKILL.md')); - assert.ok(addCall.args.includes('.gemini/skills/triage-findings/SKILL.md')); - assert.ok(addCall.args.includes('.github/copilot-instructions.md')); - assert.ok(addCall.args.includes('.amazonq/rules/triage-findings.md')); - assert.ok(addCall.args.includes('CLAUDE.md')); - assert.ok(addCall.args.includes('GEMINI.md')); - assert.ok(!addCall.args.includes('README.md')); + await commitAndPush(workspace, repoDir, spawn, sourceRoot); + const addCalls = spawn.calls.filter(c => c.args[0] === 'add'); + const skillAddCall = addCalls.find(c => c.args.includes('.github/skills/triage-findings/SKILL.md')); + const generatedAddCall = addCalls.find(c => c.args.includes('.gitea/ai-review/exclusions.json')); + assert.ok(skillAddCall, 'expected git add for synced skill files'); + assert.ok(generatedAddCall, 'expected git add for generated review files'); + assert.ok(skillAddCall.args.includes('.codex/skills/triage-findings/SKILL.md')); + assert.ok(skillAddCall.args.includes('.codex/skills/triage-findings/agents/openai.yaml')); + assert.ok(skillAddCall.args.includes('.claude/skills/triage-findings/SKILL.md')); + assert.ok(skillAddCall.args.includes('.gemini/skills/triage-findings/SKILL.md')); + assert.ok(skillAddCall.args.includes('.github/copilot-instructions.md')); + assert.ok(skillAddCall.args.includes('.amazonq/rules/triage-findings.md')); + assert.ok(skillAddCall.args.includes('CLAUDE.md')); + assert.ok(skillAddCall.args.includes('GEMINI.md')); + assert.ok(!skillAddCall.args.includes('README.md')); + assert.ok(generatedAddCall.args.includes('.gitea/ai-review/findings.json')); + assert.ok(generatedAddCall.args.includes('.gitea/ai-review/exclusions.json')); }); it('keeps repo copies when the source sync file is missing', async () => {