mirror of
https://github.com/zdharma-continuum/zinit.git
synced 2026-09-10 07:36:38 -04:00
Merge pull request #787 from zdharma-continuum/fix/ziextract-install
fix(install): treat non-archive single file gracefully in ziextract.
This commit is contained in:
commit
98b004ba5b
|
|
@ -104,6 +104,39 @@
|
||||||
assert $output contains 'ERROR'
|
assert $output contains 'ERROR'
|
||||||
assert $output contains "doesn't exist"
|
assert $output contains "doesn't exist"
|
||||||
}
|
}
|
||||||
|
@test 'ziextract plain single file (not an archive)' {
|
||||||
|
# A bare gh-r-style release binary: no "unrecognized archive" error,
|
||||||
|
# the file is kept as-is and marked executable.
|
||||||
|
local workdir=$(mktemp -d)
|
||||||
|
printf '#!/bin/sh\necho jq\n' > "$workdir/jq-macos-arm64"
|
||||||
|
_zi_extract_plain() { cd "$workdir" && ziextract jq-macos-arm64 }
|
||||||
|
run _zi_extract_plain
|
||||||
|
assert $state equals 0
|
||||||
|
assert $output does_not_contain "didn't recognize archive type"
|
||||||
|
assert $output contains 'not an archive'
|
||||||
|
assert "$workdir/jq-macos-arm64" is_executable
|
||||||
|
rm -rf "$workdir"
|
||||||
|
}
|
||||||
|
@test 'gh-r appimage: bpick + mv on non-archive asset' {
|
||||||
|
# Real-world recipe for the ziextract non-archive fallback: the AppImage is not
|
||||||
|
# an archive, must be kept, marked executable, and renamed by the mv ice.
|
||||||
|
run zinit as"program" from"gh-r" bpick"*AppImage" mv"gh* -> ghostty" id-as"test/ghostty" for pkgforge-dev/ghostty-appimage
|
||||||
|
assert $state equals 0
|
||||||
|
assert $output does_not_contain 'ERROR'
|
||||||
|
assert $output does_not_contain "didn't recognize archive type"
|
||||||
|
assert "$ZPLUGINS/test---ghostty/ghostty" is_file
|
||||||
|
assert "$ZPLUGINS/test---ghostty/ghostty" is_executable
|
||||||
|
local -a leftovers=( "$ZPLUGINS"/test---ghostty/*.appimage(N) )
|
||||||
|
assert $#leftovers equals 0
|
||||||
|
}
|
||||||
|
@test 'ziextract still errors on unrecognized explicit type' {
|
||||||
|
local workdir=$(mktemp -d)
|
||||||
|
printf 'plain text\n' > "$workdir/somefile"
|
||||||
|
_zi_extract_bogus() { cd "$workdir" && ziextract somefile bogus-type }
|
||||||
|
run _zi_extract_bogus
|
||||||
|
assert $output contains "didn't recognize archive type"
|
||||||
|
rm -rf "$workdir"
|
||||||
|
}
|
||||||
@test 'ziextract plain (no flattening)' {
|
@test 'ziextract plain (no flattening)' {
|
||||||
# extract'' → ziextract with no flags: directory structure is preserved
|
# extract'' → ziextract with no flags: directory structure is preserved
|
||||||
local workdir=$(mktemp -d)
|
local workdir=$(mktemp -d)
|
||||||
|
|
|
||||||
|
|
@ -1754,6 +1754,17 @@ ziextract() {
|
||||||
unfunction -- →zinit-extract →zinit-check
|
unfunction -- →zinit-extract →zinit-check
|
||||||
} else {
|
} else {
|
||||||
integer warning=1
|
integer warning=1
|
||||||
|
# Not an archive and no explicit type claimed — treat as a plain single
|
||||||
|
# file (e.g. a bare gh-r release binary). HTTP downloads carry no exec
|
||||||
|
# bit, so mark the file executable and let the execs collection below
|
||||||
|
# pick it up and report success.
|
||||||
|
if [[ -z $ext ]] {
|
||||||
|
warning=0
|
||||||
|
(( !OPTS[opt_-q,--quiet] )) && \
|
||||||
|
+zi-log "{info}[{pre}ziextract{info}]{rst}" \
|
||||||
|
"\`{file}${file}{rst}' is not an archive — keeping it as a plain file."
|
||||||
|
command chmod a+x "$file"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unfunction -- .zinit-extract-wrapper
|
unfunction -- .zinit-extract-wrapper
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue