1
0
Fork 0
mirror of synced 2024-11-26 09:15:34 -05:00

Use --sort=-v:refname in _zimfw_check_version

to sort tags, instead of using Zsh's `(On)`. The tags will come sorted
already.
This commit is contained in:
Eric Nielsen 2023-09-15 19:55:43 -05:00
parent e0d067977c
commit d33d632ec1
No known key found for this signature in database
GPG key ID: 678AF5E338C87D99
3 changed files with 9 additions and 13 deletions

View file

@ -1,18 +1,16 @@
_zimfw_check_version() { _zimfw_check_version() {
if (( ${1} )); then if (( ${1} )); 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)
if (( ${2} )); then if (( ${2} )); then
# background check # background check
if [[ -w ${_zversion_target:h} ]]; then if [[ -w ${_zversion_target:h} ]]; then
print -R ${${(On)${(f)"$(GIT_HTTP_LOW_SPEED_LIMIT=1000 GIT_HTTP_LOW_SPEED_TIME=30 command git ls-remote --tags --refs \ print -R ${${${(f)"$(GIT_HTTP_LOW_SPEED_LIMIT=1000 GIT_HTTP_LOW_SPEED_TIME=30 command git ls-remote --tags --refs --sort=-v:refname \
https://github.com/zimfw/zimfw.git 'v*' 2>/dev/null)"}##*v}[1]} >! ${_zversion_target} &! https://github.com/zimfw/zimfw.git 'v*' 2>/dev/null)"}##*v}[1]} >! ${_zversion_target} &!
fi fi
else else
# foreground check # foreground check
local tags local tags
tags=$(command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*') || return 1 tags=$(command git ls-remote --tags --refs --sort=-v:refname https://github.com/zimfw/zimfw.git 'v*') || return 1
>! ${_zversion_target} <<<${${(On)${(f)tags}##*v}[1]} || return 1 >! ${_zversion_target} <<<${${${(f)tags}##*v}[1]} || return 1
fi fi
fi fi
if [[ -f ${_zversion_target} ]]; then if [[ -f ${_zversion_target} ]]; then

View file

@ -4,7 +4,7 @@ class Zim
:clear_line, :ellipsis, :okay, :warn, :error, :done, :failed :clear_line, :ellipsis, :okay, :warn, :error, :done, :failed
def initialize def initialize
@version = "1.12.0" @version = "1.12.1-SNAPSHOT"
@home = "${ZDOTDIR:-${HOME}}" @home = "${ZDOTDIR:-${HOME}}"
@min_zsh_version = "5.2" @min_zsh_version = "5.2"
# Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo # Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo

View file

@ -387,19 +387,17 @@ _zimfw_check_dumpfile() {
_zimfw_check_version() { _zimfw_check_version() {
if (( ${1} )); then if (( ${1} )); 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)
if (( ${2} )); then if (( ${2} )); then
# background check # background check
if [[ -w ${_zversion_target:h} ]]; then if [[ -w ${_zversion_target:h} ]]; then
print -R ${${(On)${(f)"$(GIT_HTTP_LOW_SPEED_LIMIT=1000 GIT_HTTP_LOW_SPEED_TIME=30 command git ls-remote --tags --refs \ print -R ${${${(f)"$(GIT_HTTP_LOW_SPEED_LIMIT=1000 GIT_HTTP_LOW_SPEED_TIME=30 command git ls-remote --tags --refs --sort=-v:refname \
https://github.com/zimfw/zimfw.git 'v*' 2>/dev/null)"}##*v}[1]} >! ${_zversion_target} &! https://github.com/zimfw/zimfw.git 'v*' 2>/dev/null)"}##*v}[1]} >! ${_zversion_target} &!
fi fi
else else
# foreground check # foreground check
local tags local tags
tags=$(command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*') || return 1 tags=$(command git ls-remote --tags --refs --sort=-v:refname https://github.com/zimfw/zimfw.git 'v*') || return 1
>! ${_zversion_target} <<<${${(On)${(f)tags}##*v}[1]} || return 1 >! ${_zversion_target} <<<${${${(f)tags}##*v}[1]} || return 1
fi fi
fi fi
if [[ -f ${_zversion_target} ]]; then if [[ -f ${_zversion_target} ]]; then
@ -446,7 +444,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2023-07-17 23:54:58 UTC, previous commit is 49386ca)' print -R 'zimfw version: '${_zversion}' (built at 2023-09-16 00:51:35 UTC, previous commit is e0d0679)'
local zparam local zparam
for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do
print -R ${(r.22....:.)zparam}${(P)zparam} print -R ${(r.22....:.)zparam}${(P)zparam}
@ -847,7 +845,7 @@ _zimfw_run_tool_action() {
zimfw() { zimfw() {
builtin emulate -L zsh -o EXTENDED_GLOB builtin emulate -L zsh -o EXTENDED_GLOB
local -r _zversion='1.12.0' _zversion_target=${ZIM_HOME}/.latest_version zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b] local -r _zversion='1.12.1-SNAPSHOT' _zversion_target=${ZIM_HOME}/.latest_version zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
Actions: Actions:
%Bbuild%b Build %B${ZIM_HOME}/init.zsh%b and %B${ZIM_HOME}/login_init.zsh%b. %Bbuild%b Build %B${ZIM_HOME}/init.zsh%b and %B${ZIM_HOME}/login_init.zsh%b.