tools.func: encode GitHub tag, refine pin logic, add Codeberg (#14473)

* Encode GitHub tag, refine pin logic, add Codeberg

Encode pinned GitHub tag slashes for API requests and avoid stripping a leading 'v' unless followed by a digit. Refactor pinned-version handling to match clean tags to raw tags, report missing pins, and set CHECK_UPDATE_RELEASE/messages appropriately. Add a new check_for_codeberg_release function to query Codeberg releases (uses jq, DNS check, handles legacy migration, pinned/latest comparison) so updates can be detected from Codeberg-hosted repos.

* Update tools.func
This commit is contained in:
CanbiZ (MickLesk)
2026-05-13 22:16:13 +02:00
committed by GitHub
parent cd5816b263
commit 0a81ff53fd
+12 -4
View File
@@ -2394,11 +2394,12 @@ check_for_gh_release() {
# For pinned versions, query the specific release tag directly
if [[ -n "$pinned_version_in" ]]; then
local pinned_version_encoded="${pinned_version_in//\//%2F}"
http_code=$(curl -sSL --max-time 20 -w "%{http_code}" -o /tmp/gh_check.json \
-H 'Accept: application/vnd.github+json' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
"${header_args[@]}" \
"https://api.github.com/repos/${source}/releases/tags/${pinned_version_in}" 2>/dev/null) || true
"https://api.github.com/repos/${source}/releases/tags/${pinned_version_encoded}" 2>/dev/null) || true
if [[ "$http_code" == "200" ]] && [[ -s /tmp/gh_check.json ]]; then
releases_json="[$(</tmp/gh_check.json)]"
@@ -2520,11 +2521,19 @@ check_for_gh_release() {
rm -f "${legacy_files[0]}"
fi
fi
current="${current#v}"
if [[ "$current" =~ ^v[0-9] ]]; then
current="${current:1}"
fi
# Pinned version handling
if [[ -n "$pinned_version_in" ]]; then
local pin_clean="${pinned_version_in#v}"
local pin_clean
if [[ "$pinned_version_in" =~ ^v[0-9] ]]; then
pin_clean="${pinned_version_in:1}"
else
pin_clean="$pinned_version_in"
fi
local match_raw=""
for i in "${!clean_tags[@]}"; do
if [[ "${clean_tags[$i]}" == "$pin_clean" ]]; then
@@ -2562,7 +2571,6 @@ check_for_gh_release() {
msg_ok "No update available: ${app} (${latest_clean})"
return 1
}
# ------------------------------------------------------------------------------
# Checks for new Codeberg release (latest tag).
#