fix: mirror sync files before commit
This commit is contained in:
+18
-5
@@ -65,19 +65,32 @@ export async function commitAndPush(workspace, repoDir, _spawnSync = spawnSync)
|
||||
run(['config', 'user.email', 'ai-review[bot]@gitea'], repoDir);
|
||||
run(['config', 'user.name', 'AI Review Bot'], repoDir);
|
||||
|
||||
// Always copy source files over the repo copy so skill files stay in sync.
|
||||
const existingSyncPaths = [];
|
||||
const missingSyncPaths = [];
|
||||
|
||||
// Mirror sync files from workspace into the repo copy.
|
||||
for (const relPath of SYNC_PATHS) {
|
||||
const src = path.join(workspace, relPath);
|
||||
const dest = path.join(repoDir, relPath);
|
||||
if (!fs.existsSync(src)) continue;
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
fs.copyFileSync(src, dest);
|
||||
if (fs.existsSync(src)) {
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
fs.copyFileSync(src, dest);
|
||||
existingSyncPaths.push(relPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fs.existsSync(dest)) {
|
||||
fs.rmSync(dest, { force: true });
|
||||
}
|
||||
missingSyncPaths.push(relPath);
|
||||
}
|
||||
|
||||
const existingSyncPaths = SYNC_PATHS.filter(relPath => fs.existsSync(path.join(repoDir, relPath)));
|
||||
if (existingSyncPaths.length > 0) {
|
||||
run(['add', ...existingSyncPaths], repoDir);
|
||||
}
|
||||
if (missingSyncPaths.length > 0) {
|
||||
run(['rm', '--cached', '--ignore-unmatch', '--', ...missingSyncPaths], repoDir);
|
||||
}
|
||||
|
||||
const status = run(['status', '--porcelain'], repoDir);
|
||||
if (!status) {
|
||||
|
||||
Reference in New Issue
Block a user