From 6f6466b3f6b45e7449cb62aeeb5d155f51f54e46 Mon Sep 17 00:00:00 2001 From: limiting-factor Date: Sat, 22 Feb 2025 15:55:38 +0000 Subject: [PATCH] feat: ${FORGEJO_INSTANCE:=https://codeberg.org} (#542) Do not hardcode https://codeberg.org, use the FORGEJO_INSTANCE variable instead. It can be overriden when codeberg.org is unavailable. Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/542 Reviewed-by: earl-warren Co-authored-by: limiting-factor Co-committed-by: limiting-factor --- lib/lib.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/lib.sh b/lib/lib.sh index 1750eb79..3a4cec81 100644 --- a/lib/lib.sh +++ b/lib/lib.sh @@ -35,6 +35,7 @@ export DOT_FORGEJO_CURL=$DIR/forgejo-curl export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 : ${FORGEJO_USER:=root} : ${FORGEJO_PASSWORD:=admin1234} +: ${FORGEJO_INSTANCE:=https://codeberg.org} ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) function log_info() { @@ -93,7 +94,7 @@ function full_version() { local owner=$2 if [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then - full_version=$(curl -sS "https://codeberg.org/api/v1/repos/$owner/forgejo/releases?limit=50" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1) + full_version=$(curl -sS "$FORGEJO_INSTANCE/api/v1/repos/$owner/forgejo/releases?limit=50" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1) echo ${full_version#v} else echo $version @@ -110,7 +111,7 @@ function download_forgejo() { if test "$full_version" = ""; then continue fi - if wget -O $DIR_BINARIES/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64; then + if wget -O $DIR_BINARIES/forgejo-$version --quiet $FORGEJO_INSTANCE/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64; then break fi done