import fs from 'fs'; import path from 'path'; import { commitFile } from './gitea.js'; import { FINDINGS_PATH } from './config.js'; /** * 透過 Gitea API 將 findings.json push 到來源分支(不需要 git binary) */ export async function commitAndPush(workspace) { try { const fullPath = path.join(workspace, FINDINGS_PATH); const content = fs.readFileSync(fullPath, 'utf8'); const result = await commitFile( FINDINGS_PATH, content, 'chore: update ai-review findings [skip ci]' ); const commitHash = result.commit?.sha?.slice(0, 7) || 'unknown'; console.log(` ✅ persisted findings commit=${commitHash} push=${process.env.PR_HEAD_BRANCH}`); } catch (e) { console.log(` ⚠️ Runner failed: commit/push 失敗: ${e.message}`); } }