Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/forge.func
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,13 @@ _forge_release_json() {
local tag_prefix="${4:-}" out="${5:?outfile}"

# The install path arrives here without check_for_release; a Proxmox host has no jq.
ensure_dependencies jq || return 100
# VM scripts load this file without system.func and bring jq themselves.
if declare -F ensure_dependencies >/dev/null; then
ensure_dependencies jq || return 100
elif ! command -v jq >/dev/null 2>&1; then
msg_error "jq is required to read ${repo}'s releases"
return 100
fi

local base repo_path list one
base="$(_forge_descriptor "$forge" base)"
Expand Down
16 changes: 16 additions & 0 deletions tests/forge-release-json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ MOCK_DEPS_RC=1 run
expect "a missing jq stops the lookup" 100 "$?"
expect "nothing is fetched without jq" 0 "$(grep -c curl "$CALLS")"

# VM scripts load forge.func without system.func.
(
unset -f ensure_dependencies
MOCK_BODY='[{"tag_name":"v1.0.0","draft":false,"prerelease":false}]' run
)
expect "without system.func the lookup uses the jq that is there" 0 "$?"
expect "without system.func the release resolves" v1.0.0 "$(jq -r .tag_name "$OUT")"

(
unset -f ensure_dependencies
PATH="$TEST_DIR/no-bin"
run
)
expect "without system.func a missing jq stops the lookup" 100 "$?"
expect "without system.func nothing is fetched without jq" 0 "$(grep -c curl "$CALLS")"

MOCK_BODY='[{"tag_name":"v1.0.0","draft":false,"prerelease":false},{"tag_name":"v2.0.0-rc.1","draft":false,"prerelease":true}]' run
expect "the release list still resolves" 0 "$?"
expect "the stable release wins" v1.0.0 "$(jq -r .tag_name "$OUT")"
Expand Down
Loading