Fix Sync All to update gitea_commit_sha in endpoint_versions

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-23 23:20:02 +03:00
parent 8632e651bf
commit 36a1f26ca7

View File

@@ -389,7 +389,22 @@ class GiteaService {
for (const ep of result.rows) { for (const ep of result.rows) {
try { try {
await this.commitEndpointFiles(ep, cfg.prod_branch || 'main', `Sync: ${ep.name}`); const sha = await this.commitEndpointFiles(ep, cfg.prod_branch || 'main', `Sync: ${ep.name}`);
// Mark published version as synced
if (sha && ep.published_version_id) {
await mainPool.query(
'UPDATE endpoint_versions SET gitea_commit_sha = $1 WHERE id = $2',
[sha, ep.published_version_id]
);
} else if (sha) {
// No published version yet — mark the latest version
await mainPool.query(
`UPDATE endpoint_versions SET gitea_commit_sha = $1
WHERE endpoint_id = $2 AND gitea_commit_sha IS NULL
ORDER BY version_number DESC LIMIT 1`,
[sha, ep.id]
);
}
synced++; synced++;
} catch (err: any) { } catch (err: any) {
errors.push(`${ep.name}: ${err.message}`); errors.push(`${ep.name}: ${err.message}`);