2023-03-26 10:34:07 -04:00
_zimfw_check_version() {
2023-06-16 21:24:33 -04:00
if (( ${1} )); then
if (( ${2} )); then
# background check
if [[ -w ${_zversion_target:h} ]]; then
2023-09-15 20:55:43 -04:00
print -R ${${${(f)"$(GIT_HTTP_LOW_SPEED_LIMIT=1000 GIT_HTTP_LOW_SPEED_TIME=30 command git ls-remote --tags --refs --sort=-v:refname \
2023-06-16 21:24:33 -04:00
https://github.com/zimfw/zimfw.git 'v*' 2>/dev/null)"}##*v}[1]} >! ${_zversion_target} &!
fi
else
# foreground check
local tags
2023-09-15 20:55:43 -04:00
tags=$(command git ls-remote --tags --refs --sort=-v:refname https://github.com/zimfw/zimfw.git 'v*') || return 1
>! ${_zversion_target} <<<${${${(f)tags}##*v}[1]} || return 1
2023-06-16 21:24:33 -04:00
fi
2023-03-24 09:40:55 -04:00
fi
2023-06-16 21:24:33 -04:00
if [[ -f ${_zversion_target} ]]; then
local -r zlatest_version=$(<${_zversion_target})
if [[ -n ${zlatest_version} && ${_zversion} != ${zlatest_version} ]]; then
2023-09-16 14:16:19 -04:00
_zimfw_print -u2 -R $'<%= yellow %>Latest zimfw version is <%= bold %>'${zlatest_version}$'<%= normalyellow %>. You\'re using version <%= bold %>'${_zversion}$'<%= normalyellow %>. Run <%= bold %>zimfw upgrade<%= normalyellow %> to upgrade.<%= normal %>'
2023-06-16 21:24:33 -04:00
return 4
fi
2020-01-15 12:35:30 -05:00
fi
}