[PR #150] [MERGED] fix: Detect and recreate incorrectly ordered releases (#148) #155

Closed
opened 2026-02-27 15:55:20 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/RayLabsHQ/gitea-mirror/pull/150
Author: @arunavo4
Created: 11/8/2025
Status: Merged
Merged: 11/8/2025
Merged by: @arunavo4

Base: mainHead: 148-release-order-again


📝 Commits (1)

  • e951e97 fix: Detect and recreate incorrectly ordered releases (#148)

📊 Changes

1 file changed (+109 additions, -16 deletions)

View changed files

📝 src/lib/gitea.ts (+109 -16)

📄 Description

This fix addresses the persistent release ordering issue by detecting when existing releases in Gitea are in the wrong chronological order and automatically deleting and recreating them in the correct order.

Root Cause:

  • Gitea ALWAYS sorts releases by created_unix DESC, id DESC
  • The Gitea API provides NO way to set created_unix when creating releases
  • Previous fix (PR #146) only worked for NEW releases, not UPDATES
  • When releases are UPDATED, their created_unix timestamp doesn't change
  • So releases created in wrong order initially stayed wrong forever

Solution:
Before processing releases, the code now:

  1. Fetches all existing releases from Gitea
  2. Checks if they're in correct chronological order
  3. If order is wrong: deletes all releases and recreates them in correct order
  4. If order is correct: proceeds with normal update logic

How it works:

  • Maps each release to its expected chronological index (0=oldest, n=newest)
  • Checks if Gitea's releases (sorted by created_unix DESC) match expected order
  • Detects mis-ordering by comparing adjacent releases
  • Logs detailed information about ordering issues found
  • Deletes and recreates only when necessary (optimized)

User Impact:

  • Users who mirrored repos BEFORE PR #146: ordering will be fixed on next mirror
  • First-time mirrors: work correctly (as before)
  • Subsequent mirrors: verify order and fix if needed
  • No manual intervention required

Fixes #148
Related: #129, PR #146


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/RayLabsHQ/gitea-mirror/pull/150 **Author:** [@arunavo4](https://github.com/arunavo4) **Created:** 11/8/2025 **Status:** ✅ Merged **Merged:** 11/8/2025 **Merged by:** [@arunavo4](https://github.com/arunavo4) **Base:** `main` ← **Head:** `148-release-order-again` --- ### 📝 Commits (1) - [`e951e97`](https://github.com/RayLabsHQ/gitea-mirror/commit/e951e97790efb8fcee4c1852479a11520dfa607b) fix: Detect and recreate incorrectly ordered releases (#148) ### 📊 Changes **1 file changed** (+109 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/gitea.ts` (+109 -16) </details> ### 📄 Description This fix addresses the persistent release ordering issue by detecting when existing releases in Gitea are in the wrong chronological order and automatically deleting and recreating them in the correct order. **Root Cause:** - Gitea ALWAYS sorts releases by `created_unix DESC, id DESC` - The Gitea API provides NO way to set `created_unix` when creating releases - Previous fix (PR #146) only worked for NEW releases, not UPDATES - When releases are UPDATED, their `created_unix` timestamp doesn't change - So releases created in wrong order initially stayed wrong forever **Solution:** Before processing releases, the code now: 1. Fetches all existing releases from Gitea 2. Checks if they're in correct chronological order 3. If order is wrong: deletes all releases and recreates them in correct order 4. If order is correct: proceeds with normal update logic **How it works:** - Maps each release to its expected chronological index (0=oldest, n=newest) - Checks if Gitea's releases (sorted by created_unix DESC) match expected order - Detects mis-ordering by comparing adjacent releases - Logs detailed information about ordering issues found - Deletes and recreates only when necessary (optimized) **User Impact:** - Users who mirrored repos BEFORE PR #146: ordering will be fixed on next mirror - First-time mirrors: work correctly (as before) - Subsequent mirrors: verify order and fix if needed - No manual intervention required Fixes #148 Related: #129, PR #146 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 15:55:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gitea-mirror#155
No description provided.