Commit Graph
52 Commits
Author SHA1 Message Date
JefferyandClaude Opus 4.8 24bcad7141 fix(release-cleanup): cleanupReleases 防禦 null/異常結構的 release 項目
在刪除迴圈中先檢查項目為非 null 物件,避免對非預期結構解構時拋出未捕捉例外。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 13:59:49 +08:00
AI Review Bot 1bc6ce6d8c chore: update ai-review findings [ai-review-bot][failure] 2026-06-26 05:56:45 +00:00
JefferyandClaude Opus 4.8 7b742ed85e chore(ai-review): 更新 findings.json 與 exclusions.json
CI / AI Code Review (pull_request) Failing after 50s
移除本輪已修復(server URL 正規化、id 整數驗證、整合測試)與重複提報的 finding;
保留 7 條設計取捨(重試/錯誤處理/DoS/TOCTOU/deleteResource 策略);
新增 3 條不適用至 exclusions(baseUrl 由已驗證 config 組成、tag 白名單非必要、
categorizeTags 拆分無益)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 13:55:48 +08:00
JefferyandClaude Opus 4.8 edc933be73 test(release-cleanup): 補上整合測試、server URL 正規化與 id 驗證測試
新增端對端整合測試(列出→刪除舊 release→重列→列 tag→刪孤立 tag 的呼叫順序)、
loadConfig 去尾斜線測試,並將 id 編碼測試改為驗證非整數 id 被略過。測試共 62 項全數通過。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 13:55:48 +08:00
JefferyandClaude Opus 4.8 353a6af7c3 fix(release-cleanup): 去除 server URL 結尾斜線並驗證 release id 為正整數
- loadConfig 去除 GITEA_SERVER_URL 結尾的 /,避免拼出 //api/v1 錯誤路徑
- cleanupReleases 要求 id 為正整數,非整數一律略過(縱深防禦,不僅依賴編碼)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 13:55:48 +08:00
AI Review Bot 888edfea27 chore: update ai-review findings [ai-review-bot][failure] 2026-06-26 03:44:06 +00:00
JefferyandClaude Opus 4.8 b461f72d43 chore(ai-review): 更新 findings.json 與 exclusions.json
CI / AI Code Review (pull_request) Failing after 43s
移除已修復(決定性排序)與多項重複提報的 finding;保留 7 條設計取捨;
新增 6 條不適用/誤報至 exclusions(內部 IP 黑名單會破壞自架 Gitea、
section 排版主觀、無效日期已註記、CI 堆疊輸出無妨、MAX_PAGES 為安全上限、
通用 log 抽象效益低)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:43:16 +08:00
JefferyandClaude Opus 4.8 de094c542f docs(release-cleanup): 更新 README cleanupReleases 連結行號與更新時間
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:43:16 +08:00
JefferyandClaude Opus 4.8 858e628db6 test(release-cleanup): 驗證相同 created_at 時的決定性排序
新增測試:多筆 created_at 相同時,以 id 大小決定保留/刪除順序。測試共 60 項全數通過。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:43:16 +08:00
JefferyandClaude Opus 4.8 9e33cb8ba8 fix(release-cleanup): selectReleasesToDelete 在時間相同時以 id 決定順序
排序加入次要鍵(id 數值,大者視為新),避免多筆 created_at 相同時保留/
刪除的選擇因引擎排序穩定性而不確定。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:43:16 +08:00
AI Review Bot e0ab6f2693 chore: update ai-review findings [ai-review-bot][failure] 2026-06-26 03:34:26 +00:00
JefferyandClaude Opus 4.8 b57180153e chore(ai-review): 更新 findings.json 與 exclusions.json
CI / AI Code Review (pull_request) Failing after 32s
移除本輪已具測試覆蓋的 finding(MAX_PAGES 邊界、刪除失敗記錄)與多項
先前已修復卻被重複提報者;保留 6 條設計取捨類待人工評估;新增 2 條不適用
(_getHeaders 過度設計、排序中間陣列與前次優化衝突)至 exclusions。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:33:45 +08:00
JefferyandClaude Opus 4.8 fd2dfa8732 test(release-cleanup): 補上 MAX_PAGES 邊界與刪除失敗記錄測試
新增 fetchAllPages 於第 MAX_PAGES 頁回空陣列時正常結束的測試,以及
cleanupReleases/cleanupOrphanTags 在 deleteResource 回非 204 時繼續處理
並寫入 stderr 錯誤記錄的測試。測試共 59 項全數通過。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:33:45 +08:00
AI Review Bot 76bccfeea9 chore: update ai-review findings [ai-review-bot][failure] 2026-06-26 03:30:27 +00:00
JefferyandClaude Opus 4.8 1cc217f04e chore(ai-review): 更新 findings.json 與 exclusions.json
CI / AI Code Review (pull_request) Failing after 50s
移除本輪已修復(Date.parse 預算、結束碼/sanitizeBody/logger 測試)的 finding;
保留 7 條設計取捨類(重試/錯誤閾值/SRP/並行化/回應大小 DoS 防護);
將 6 條不適用或誤報(Node<16、push.apply、'null' 字串、已用 Set、env 可注入、
Set 轉換)登記至 exclusions。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:29:30 +08:00
JefferyandClaude Opus 4.8 941d3c0a8c docs(release-cleanup): 更新 README cleanupReleases 連結行號與更新時間
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:29:30 +08:00
JefferyandClaude Opus 4.8 826b559006 test(release-cleanup): 補上結束碼、sanitizeBody 與 logger 輸出測試
新增子行程驗證 index.js 失敗時以非零狀態結束、fetchAllPages 錯誤訊息
清理控制字元與長度限制、以及 logger 各輸出函式格式與 stdout/stderr 分流測試。
測試共 56 項全數通過。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:29:30 +08:00
JefferyandClaude Opus 4.8 87db9030d6 perf(release-cleanup): selectReleasesToDelete 預先計算時間戳
排序前先一次性計算各 release 的 created_at 時間戳,避免在排序比較器中
重複呼叫 Date.parse;排序結果與原行為等價。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:29:30 +08:00
AI Review Bot c0285794ae chore: update ai-review findings [ai-review-bot][failure] 2026-06-26 03:22:50 +00:00
JefferyandClaude Opus 4.8 c11440e139 chore(ai-review): 更新 findings.json 與 exclusions.json
CI / AI Code Review (pull_request) Failing after 46s
移除本輪已修復(MAX_PAGES、URL 編碼)與已具測試/已收斂的 finding;
保留 5 條設計取捨類(重試/錯誤閾值/SRP/並行化)待人工評估;
將 logger 分隔線常數建議登記為不適用於 exclusions。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:21:56 +08:00
JefferyandClaude Opus 4.8 322e42087d docs(release-cleanup): 更新 README gitea-client 連結行號與更新時間
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:21:56 +08:00
JefferyandClaude Opus 4.8 0ba93a40a9 test(release-cleanup): 補上 MAX_PAGES 與刪除 URL 編碼測試
新增 fetchAllPages 超過 MAX_PAGES 中止的測試,以及 cleanupReleases/
cleanupOrphanTags 對含 ../ 的 id/tag 名稱編碼的測試。測試共 50 項全數通過。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:21:56 +08:00
JefferyandClaude Opus 4.8 aa4f6364e2 fix(release-cleanup): 加入分頁上限並編碼刪除 URL 路徑片段
- fetchAllPages 加入 MAX_PAGES(1000)安全斷點,避免 API 異常時無限迴圈
- 刪除 release/tag 時對 id 與 tag 名稱做 encodeURIComponent,
  防止特殊字元造成路徑穿越(正常數值/版本字串編碼後不變)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:21:56 +08:00
AI Review Bot 49ac5d4ec4 chore: update ai-review findings [ai-review-bot][failure] 2026-06-26 03:05:47 +00:00
JefferyandClaude Opus 4.8 8dae4aceaf chore(ai-review): 更新 findings.json
CI / AI Code Review (pull_request) Failing after 1m10s
移除本輪已修復(JSON/陣列處理、sanitize、failError 收斂、常數抽出)與
已存在測試覆蓋的 finding;保留 7 條設計取捨類(重試/TOCTOU/並行化/SRP)待人工評估。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:04:29 +08:00
JefferyandClaude Opus 4.8 2b27da82c0 docs(release-cleanup): README 新增 failError 並更新行號
新增 failError 功能列表/使用範例,更新 validate/gitea-client 連結行號與更新時間。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:04:29 +08:00
JefferyandClaude Opus 4.8 b9d7c4e970 test(release-cleanup): 補強逾時、非陣列、token 邊界與 failError 測試
新增 fetchAllPages 的 AbortError 逾時與非陣列回應測試、loadConfig 的
GITEA_TOKEN 邊界測試,以及 logger.failError 測試。測試共 47 項全數通過。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:04:29 +08:00
JefferyandClaude Opus 4.8 f6d2ebeab2 refactor(release-cleanup): 收斂錯誤輸出並抽出驗證規則常數
- 新增 logger.failError 集中處理 Error/非 Error 的 stderr 輸出與堆疊,
  index.js 改用之,移除重複的 reportFatal
- validate.js 將允許協定與 repository 格式抽為模組常數,便於維護擴充

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:04:29 +08:00
JefferyandClaude Opus 4.8 0f4354bd01 fix(gitea-client): 強化分頁回應的 JSON 與錯誤內容處理
- res.json() 以 try-catch 包裹,解析失敗時補上 URL 上下文
- res.ok 為真時嚴格要求陣列,非陣列回應改為拋錯而非靜默結束
- 改用迴圈逐一 push 取代展開運算子,避免大量項目的堆疊風險
- 錯誤訊息中的回應內容經 sanitize(移除控制字元)防止 log 注入

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 11:04:29 +08:00
AI Review Bot 1623408d02 chore: update ai-review findings [ai-review-bot][failure] 2026-06-26 02:56:30 +00:00
JefferyandClaude Opus 4.8 245f66de8f chore(ai-review): 更新 findings.json 與 exclusions.json
CI / AI Code Review (pull_request) Failing after 36s
移除已修復的 13 條 finding;保留 4 條設計取捨類(重試/TOCTOU/並行化)
待人工評估;將 token log 排版建議登記為誤報於 exclusions.json。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:55:45 +08:00
JefferyandClaude Opus 4.8 a95945262d docs(release-cleanup): 更新 README 功能列表與 Dockerfile 註解排版
README 新增 requireUrl/requireRepository、修正原始碼連結行號與更新時間;
Dockerfile 調整註解冒號/括號前的空白(無邏輯變更)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:55:45 +08:00
JefferyandClaude Opus 4.8 7c225d4122 test(release-cleanup): 補齊 cleanup/config/main 與新驗證函式測試
新增 cleanupReleases、cleanupOrphanTags 的失敗路徑與分類測試、
loadConfig 環境變數驗證測試、main 整合測試,以及 requireUrl/
requireRepository 與 content-type 檢查測試。測試共 41 項全數通過。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:55:45 +08:00
JefferyandClaude Opus 4.8 154ab032bf fix(release-cleanup): 強化輸入驗證、請求逾時與錯誤處理
解決 AI review 的安全性與健壯性問題:
- 驗證 GITEA_SERVER_URL 為合法 http/https URL(降低 SSRF 風險)
- 驗證 GITEA_REPOSITORY 為 owner/repo 形式並拒絕路徑穿越
- 為所有 fetch 請求加上 30 秒逾時(AbortSignal.timeout),避免卡死
- fetchAllPages 解析前檢查 content-type,非 JSON 時拋出明確錯誤
- selectReleasesToDelete 對無效 created_at 防呆,避免 NaN 排序
- index.js 匯出 main 並加上直接執行守衛,錯誤輸出含類型與堆疊

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:55:45 +08:00
JefferyandClaude Opus 4.8 1f27a46f7b docs(README): 建立專案 README 與功能/使用範例
新增專案列表、公開功能列表(連結至 develop 上的原始碼行)與使用範例;
連結指向 develop 分支以確保合併後仍有效。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:46:20 +08:00
JefferyandClaude Opus 4.8 7e6f9ef3f6 docs(release-cleanup): 補齊 config/gitea-client/releases/tags 的 JSDoc
為 loadConfig、GiteaClient(含 fetchAllPages/deleteResource)、
selectReleasesToDelete/cleanupReleases、categorizeTags/cleanupOrphanTags
補上完整 JSDoc(參數、回傳、例外、行為說明)。僅註解變更。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:46:20 +08:00
AI Review Bot 7082fd7311 chore: update ai-review findings [ai-review-bot][failure] 2026-06-26 02:38:03 +00:00
JefferyandClaude Opus 4.8 4bcc6a5014 docs(release-cleanup): 補上 index.js JSDoc 與 ci/cd workflow 註解
CI / AI Code Review (pull_request) Failing after 40s
為進入點主流程 main() 補上 JSDoc;為 ci.yaml/cd.yaml 加上用途說明與逐行註解。
皆為註解變更,不影響任何執行邏輯。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:36:25 +08:00
JefferyandClaude Opus 4.8 15ffa4ffb6 test(release-cleanup): 新增 validate/releases/tags/gitea-client 單元測試
以 node:test 內建測試器涵蓋純函式(isEmptyOrNull/requireValue/requireInteger、
selectReleasesToDelete、categorizeTags)與 GiteaClient 分頁/刪除邏輯,共 19 項測試。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:35:19 +08:00
JefferyandClaude Opus 4.8 b1aa8730a2 refactor(release-cleanup): 將清理邏輯由 bash 改寫為 Node.js 模組
依功能分組為 logger/validate/config/gitea-client/releases/tags 模組,
entrypoint.sh 改為呼叫 node /app/index.js,Dockerfile 改用 node:20-alpine 基底。
對外行為(清理舊 release 與未指定 release 的 tag)維持不變。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:35:19 +08:00
admin b478872c5f 更新 .gitea/workflows/ci.yaml 2026-06-25 16:32:34 +00:00
jiantw83 fef4eaebca 更新 .gitea/workflows/cd.yaml 2026-06-25 14:10:49 +00:00
jiantw83 a9b6f4d7fa 更新 .gitea/workflows/ci.yaml 2026-06-25 14:09:16 +00:00
jiantw83 5e9b7cfea6 更新 .gitea/workflows/ci.yaml 2026-06-25 14:04:35 +00:00
jiantw83 e1c50286ce 更新 .gitea/workflows/cd.yaml 2026-06-25 14:00:02 +00:00
admin 3b0e5225c6 更新 action.yaml 2026-06-25 13:47:57 +00:00
jiantw83 0e91eb6cf3 fix(release cleanup): 改用 GITEA_TOKEN 呼叫 API 2026-06-25 10:58:56 +00:00
jiantw83 034c1ce67b chore(Gitea Actions): 修正工作流程路徑與發版設定 2026-06-25 10:57:32 +00:00
jiantw83 2f0a1b72c1 style(Dockerfile): 整理空白與檔尾換行 2026-06-25 10:57:32 +00:00
jiantw83 91dee30262 fix(release cleanup): 修正 action token 傳遞與中繼資料 2026-06-25 10:57:32 +00:00