refactor: remove dry run support
This commit is contained in:
+4
-30
@@ -36,22 +36,6 @@ resolve_keep_versions() {
|
||||
printf '%s' "${raw_value}"
|
||||
}
|
||||
|
||||
resolve_dry_run() {
|
||||
local raw_value="${INPUT_DRY_RUN:-true}"
|
||||
|
||||
case "${raw_value,,}" in
|
||||
true|1|yes|on)
|
||||
printf 'true'
|
||||
;;
|
||||
false|0|no|off)
|
||||
printf 'false'
|
||||
;;
|
||||
*)
|
||||
fail "Invalid dry_run: ${raw_value}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
init_repo_context() {
|
||||
local repository="${GITEA_REPOSITORY:-}"
|
||||
|
||||
@@ -192,27 +176,19 @@ collect_package_candidates() {
|
||||
}
|
||||
|
||||
process_candidates() {
|
||||
local dry_run="$1"
|
||||
local name version created_at
|
||||
local deleted_count=0
|
||||
local skipped_count=0
|
||||
local error_count=0
|
||||
|
||||
if [[ ! -s "${CANDIDATES_FILE}" ]]; then
|
||||
log "No delete candidates found"
|
||||
log "Summary: packages=${PACKAGE_COUNT} versions=${TOTAL_VERSION_COUNT} kept=${KEPT_COUNT} candidates=0 deleted=0 skipped=0 errors=0 dry_run=${dry_run}"
|
||||
log "Summary: packages=${PACKAGE_COUNT} versions=${TOTAL_VERSION_COUNT} kept=${KEPT_COUNT} candidates=0 deleted=0 errors=0"
|
||||
return 0
|
||||
fi
|
||||
|
||||
while IFS=$'\t' read -r name version created_at; do
|
||||
[[ -z "${name}" ]] && continue
|
||||
|
||||
if [[ "${dry_run}" == "true" ]]; then
|
||||
log "[DRY-RUN] Would delete package ${name} version ${version} (created: ${created_at})"
|
||||
skipped_count=$((skipped_count + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
if api_request DELETE "/api/v1/packages/${REPO_OWNER}/nuget/${name}/${version}"; then
|
||||
log "Deleted package ${name} version ${version} -> ${API_STATUS_TEXT}"
|
||||
deleted_count=$((deleted_count + 1))
|
||||
@@ -226,11 +202,11 @@ process_candidates() {
|
||||
fi
|
||||
done < "${CANDIDATES_FILE}"
|
||||
|
||||
log "Summary: packages=${PACKAGE_COUNT} versions=${TOTAL_VERSION_COUNT} kept=${KEPT_COUNT} candidates=${CANDIDATE_COUNT} deleted=${deleted_count} skipped=${skipped_count} errors=${error_count} dry_run=${dry_run}"
|
||||
log "Summary: packages=${PACKAGE_COUNT} versions=${TOTAL_VERSION_COUNT} kept=${KEPT_COUNT} candidates=${CANDIDATE_COUNT} deleted=${deleted_count} errors=${error_count}"
|
||||
}
|
||||
|
||||
main() {
|
||||
local token keep_versions dry_run
|
||||
local token keep_versions
|
||||
|
||||
log "Gitea Server Url: ${GITEA_SERVER_URL:-}"
|
||||
log "Gitea Repository: ${GITEA_REPOSITORY:-}"
|
||||
@@ -242,9 +218,7 @@ main() {
|
||||
export RESOLVED_GITEA_TOKEN="$token"
|
||||
init_repo_context
|
||||
keep_versions="$(resolve_keep_versions)"
|
||||
dry_run="$(resolve_dry_run)"
|
||||
log "keep_versions=${keep_versions}"
|
||||
log "dry_run=${dry_run}"
|
||||
log "Token source resolved successfully"
|
||||
|
||||
CANDIDATES_FILE="$(mktemp)"
|
||||
@@ -256,7 +230,7 @@ main() {
|
||||
trap 'rm -f "${CANDIDATES_FILE}"' EXIT
|
||||
|
||||
collect_package_candidates
|
||||
process_candidates "${dry_run}"
|
||||
process_candidates
|
||||
log "Stage 4 complete"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user