1
0
Fork 0
mirror of synced 2024-06-16 22:01:09 -04:00
zimfw/src/stage2/50_zimfw_check_version.zsh.erb
Eric Nielsen 903e0e5249
Add check and rename version-check to check-version
actions. Return 4 if there's a zimfw update from check-version. Don't
return a specific error code if there are module updates from check, as
it uses zargs to check all and each check runs in a separate shell. Need
to figure out how to propagate all that to a final error code.

See #503
2023-03-26 09:34:07 -05:00

17 lines
745 B
Plaintext

_zimfw_check_version() {
if [[ ${1} -ne 0 ]]; then
# Get latest version (get all `v*` tags from repo, delete `*v` from beginning,
# sort in descending `O`rder `n`umerically, and get the `[1]` first)
local tags
tags=$(command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*') || return 1
>! ${_zversion_target} <<<${${(On)${(f)tags}##*v}[1]} || return 1
fi
local -r zlatest_version=$(<${_zversion_target})
if [[ -n ${zlatest_version} && ${_zversion} != ${zlatest_version} ]]; then
if (( _zprintlevel > 0 )); then
print -u2 -PR "%F{yellow}Latest zimfw version is %B${zlatest_version}%b. You're using version %B${_zversion}%b. Run %Bzimfw upgrade%b to upgrade.%f"
fi
return 4
fi
}