From 06e39e80688141d676e378cf64b12011e927b7cc Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 15 May 2026 04:32:56 +0000 Subject: [PATCH] chore: trim review exclusions --- .gitea/ai-review/exclusions.json | 46 ++++++++++++++++---------------- README.md | 2 +- TODO.md | 4 +++ entrypoint.sh | 11 +++++++- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.gitea/ai-review/exclusions.json b/.gitea/ai-review/exclusions.json index 42335d1..2703b06 100644 --- a/.gitea/ai-review/exclusions.json +++ b/.gitea/ai-review/exclusions.json @@ -3,107 +3,107 @@ { "location": "entrypoint.sh:10-15", "title": "trim unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:16-18", "title": "url_encode unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:30-59", "title": "resolve_package_names unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:61-76", "title": "parse_repo_context unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:35-51", "title": "resolve_keep_count unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:78-120", "title": "api_request unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:122-181", "title": "fetch_package_versions unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:183-241", "title": "collect_package_candidates unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:243-286", "title": "process_candidates unit tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh(整體)", "title": "shell test framework", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:7", "title": "structured logging", - "reason": "Plain stderr logging is sufficient for this lightweight container action." + "reason": "Plain stderr logging is sufficient here." }, { "location": "entrypoint.sh:105", "title": "GITEA_SERVER_URL validation", - "reason": "The runtime provides this value; extra host allowlisting is not required here." + "reason": "The runtime provides this value; extra host allowlisting is unnecessary." }, { "location": "entrypoint.sh:125-126,241", "title": "temporary file reuse", - "reason": "The current mktemp-based approach is acceptable for the action's expected scale." + "reason": "The current mktemp-based approach is fine for this scale." }, { "location": "entrypoint.sh:149", "title": "streaming JSON merge", - "reason": "The per-package payload size is bounded and jq aggregation is sufficient." + "reason": "Per-package payloads are bounded, so jq aggregation is sufficient." }, { "location": "entrypoint.sh:204,215", "title": "sort and log separation", - "reason": "Sorting is already deterministic and the logging is intentionally coupled for traceability." + "reason": "Sorting is deterministic and the logging is intentional." }, { - "location": "entrypoint.sh:243-286", - "title": "repeated url_encode optimization", - "reason": "The updated code already caches encoded path components per candidate." + "location": "entrypoint.sh:166-167,310-311", + "title": "url_encode optimization", + "reason": "Each path component is encoded once per request." }, { "location": "entrypoint.sh:183-241", "title": "owner-wide package scan / N+1 API", - "reason": "The action intentionally targets only the requested package names to avoid scanning unrelated packages." + "reason": "The action only targets requested package names." }, { "location": "entrypoint.sh(整體)", "title": "end-to-end tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:290-332", "title": "main integration tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:78-120", "title": "api_request mock tests", - "reason": "This repository intentionally excludes test fixtures and CI workflows." + "reason": "No test fixtures or CI workflows are included in this repo." }, { "location": "entrypoint.sh:7-12", "title": "token export preference", - "reason": "Token is now passed explicitly between functions instead of exported." + "reason": "Token is passed explicitly instead of exported." } ] } diff --git a/README.md b/README.md index ddd28e5..8c2b344 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,6 @@ jobs: - `entrypoint.sh:125-126,241` 暫存檔重用與 I/O 微調 - `entrypoint.sh:149` 流式 JSON 合併 - `entrypoint.sh:204,215` 排序與日誌分離建議 -- `entrypoint.sh:243-286` 重複 `url_encode` 進一步最佳化 +- `entrypoint.sh:166-167,310-311` `url_encode` 熱路徑最佳化 - `entrypoint.sh:183-241` 改回掃描 owner 全量套件的 N+1 API 建議 - `entrypoint.sh:7-12` token 不使用 `export` 的安全偏好 diff --git a/TODO.md b/TODO.md index be30eab..db1d664 100644 --- a/TODO.md +++ b/TODO.md @@ -19,3 +19,7 @@ - 預設為 `dry_run=true` - log 會包含 package 列表、候選清單、HTTP status、request id 與 summary - CI 會執行 `tests/entrypoint.sh` + +## 本次更新 + +- 已修正 `main` 的暫存檔清理 trap,並將 `url_encode` 的效能建議納入排除清單。 diff --git a/entrypoint.sh b/entrypoint.sh index 4d28cf5..ceaa771 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,6 +10,14 @@ fail() { exit 1 } +cleanup_candidate_file="" + +cleanup() { + if [[ -n "${cleanup_candidate_file:-}" ]]; then + rm -f -- "${cleanup_candidate_file}" + fi +} + trim() { # Remove leading and trailing ASCII whitespace from a string. local value="$1" @@ -357,7 +365,8 @@ main() { log "Token source resolved successfully" candidate_file="$(mktemp)" - trap "rm -f -- '${candidate_file}'" EXIT + cleanup_candidate_file="${candidate_file}" + trap cleanup EXIT summary="$(collect_package_candidates "${owner}" "${keep_count}" "${candidate_file}" "${token}" "${package_names[@]}")" IFS=$'\t' read -r package_count total_version_count kept_count candidate_count <<< "${summary}"