From 36a1f26ca7db882da103f7312f8ca7d50948981d Mon Sep 17 00:00:00 2001 From: eshmeshek Date: Sat, 23 May 2026 23:20:02 +0300 Subject: [PATCH] Fix Sync All to update gitea_commit_sha in endpoint_versions Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/src/services/GiteaService.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/src/services/GiteaService.ts b/backend/src/services/GiteaService.ts index f5c21bf..0087009 100644 --- a/backend/src/services/GiteaService.ts +++ b/backend/src/services/GiteaService.ts @@ -389,7 +389,22 @@ class GiteaService { for (const ep of result.rows) { 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++; } catch (err: any) { errors.push(`${ep.name}: ${err.message}`);