1
0
Fork 0
mirror of synced 2024-05-27 04:21:12 -04:00
zimfw/src/stage2/40_zimfw_version_check.zsh.erb
Eric Nielsen cffd456556
Add new degit tool \o/
and rename previous to git.

Tools allow for different install and update scripts. The git tool does
what the previous implementation did (installs and updates using the git
client). The new tool installs and updates with the GitHub API, not
using the git client, but using curl/wget and tar instead.

Closes #373
2021-04-07 17:54:47 -05:00

20 lines
959 B
Plaintext

_zimfw_version_check() {
if (( _zprintlevel > 0 )); then
setopt LOCAL_OPTIONS EXTENDED_GLOB
local -r ztarget=${ZIM_HOME}/.latest_version
# If .latest_version does not exist or was not modified in the last 30 days
if [[ -w ${ztarget:h} && ! -f ${ztarget}(#qNm-30) ]]; 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)
print ${${(On)${(f)"$(command git ls-remote --tags --refs \
https://github.com/zimfw/zimfw.git 'v*' 2>/dev/null)"}##*v}[1]} >! ${ztarget} &!
fi
if [[ -f ${ztarget} ]]; then
local -r zlatest_version=$(<${ztarget})
if [[ -n ${zlatest_version} && ${_zversion} != ${zlatest_version} ]]; 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"$'\n'
fi
fi
fi
}