zimfw/src/stage2/40_zimfw_version_check.zsh.erb

17 lines
773 B
Plaintext

_zimfw_version_check() {
if [[ ${1} -ne 0 || ! -f ${_zversion_target} ]]; 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 1
fi
}