refactor: cache encoded delete paths
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
"title": "trim unit tests",
|
||||
"reason": "This repository intentionally excludes test fixtures and CI workflows."
|
||||
},
|
||||
{
|
||||
"location": "entrypoint.sh:16-18",
|
||||
"title": "url_encode unit tests",
|
||||
"reason": "This repository intentionally excludes test fixtures and CI workflows."
|
||||
},
|
||||
{
|
||||
"location": "entrypoint.sh:30-59",
|
||||
"title": "resolve_package_names unit tests",
|
||||
@@ -15,6 +20,11 @@
|
||||
"title": "parse_repo_context unit tests",
|
||||
"reason": "This repository intentionally excludes test fixtures and CI workflows."
|
||||
},
|
||||
{
|
||||
"location": "entrypoint.sh:35-51",
|
||||
"title": "resolve_keep_count unit tests",
|
||||
"reason": "This repository intentionally excludes test fixtures and CI workflows."
|
||||
},
|
||||
{
|
||||
"location": "entrypoint.sh:78-120",
|
||||
"title": "api_request unit tests",
|
||||
@@ -64,6 +74,16 @@
|
||||
"location": "entrypoint.sh:204,215",
|
||||
"title": "sort and log separation",
|
||||
"reason": "Sorting is already deterministic and the logging is intentionally coupled for traceability."
|
||||
},
|
||||
{
|
||||
"location": "entrypoint.sh:243-286",
|
||||
"title": "repeated url_encode optimization",
|
||||
"reason": "The updated code already caches encoded path components per candidate."
|
||||
},
|
||||
{
|
||||
"location": "entrypoint.sh(整體)",
|
||||
"title": "end-to-end tests",
|
||||
"reason": "This repository intentionally excludes test fixtures and CI workflows."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -72,15 +72,19 @@ jobs:
|
||||
以下審查意見屬於刻意排除,不再以測試或 CI 的形式處理:
|
||||
|
||||
- `entrypoint.sh:10-15` `trim`
|
||||
- `entrypoint.sh:16-18` `url_encode`
|
||||
- `entrypoint.sh:30-59` `resolve_package_names`
|
||||
- `entrypoint.sh:61-76` `parse_repo_context`
|
||||
- `entrypoint.sh:35-51` `resolve_keep_count`
|
||||
- `entrypoint.sh:78-120` `api_request`
|
||||
- `entrypoint.sh:122-181` `fetch_package_versions`
|
||||
- `entrypoint.sh:183-241` `collect_package_candidates`
|
||||
- `entrypoint.sh:243-286` `process_candidates`
|
||||
- `entrypoint.sh(整體)` 新增測試程式碼與測試框架
|
||||
- `entrypoint.sh(整體)` 端對端測試
|
||||
- `entrypoint.sh:7` 結構化 logging
|
||||
- `entrypoint.sh:105` 驗證 `GITEA_SERVER_URL`
|
||||
- `entrypoint.sh:125-126,241` 暫存檔重用與 I/O 微調
|
||||
- `entrypoint.sh:149` 流式 JSON 合併
|
||||
- `entrypoint.sh:204,215` 排序與日誌分離建議
|
||||
- `entrypoint.sh:243-286` 重複 `url_encode` 進一步最佳化
|
||||
|
||||
+6
-1
@@ -40,6 +40,7 @@ resolve_keep_count() {
|
||||
# Parse KEEP_COUNT and ensure it is a non-negative integer.
|
||||
local raw_value="${INPUT_KEEP_COUNT:-2}"
|
||||
|
||||
raw_value="$(trim "${raw_value}")"
|
||||
if [[ -z "${raw_value}" ]]; then
|
||||
raw_value="2"
|
||||
fi
|
||||
@@ -284,6 +285,7 @@ process_candidates() {
|
||||
local deleted_count=0
|
||||
local error_count=0
|
||||
local package_name version _created_at
|
||||
local encoded_owner encoded_package_name encoded_version
|
||||
local body_file headers_file meta http_code status_text request_id
|
||||
|
||||
if [[ ! -s "${candidate_file}" ]]; then
|
||||
@@ -294,12 +296,15 @@ process_candidates() {
|
||||
|
||||
body_file="$(mktemp)"
|
||||
headers_file="$(mktemp)"
|
||||
encoded_owner="$(url_encode "${owner}")"
|
||||
while IFS=$'\t' read -r package_name version _created_at; do
|
||||
[[ -z "${package_name}" ]] && continue
|
||||
|
||||
encoded_package_name="$(url_encode "${package_name}")"
|
||||
encoded_version="$(url_encode "${version}")"
|
||||
: > "${body_file}"
|
||||
: > "${headers_file}"
|
||||
meta="$(api_request DELETE "/api/v1/packages/$(url_encode "${owner}")/nuget/$(url_encode "${package_name}")/$(url_encode "${version}")" "${body_file}" "${headers_file}")"
|
||||
meta="$(api_request DELETE "/api/v1/packages/${encoded_owner}/nuget/${encoded_package_name}/${encoded_version}" "${body_file}" "${headers_file}")"
|
||||
IFS=$'\t' read -r http_code status_text request_id <<< "${meta}"
|
||||
|
||||
if [[ "${http_code}" =~ ^2 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user