Simplify getting released kitty version

Also if fetching release version fails and local version exists, use it
This commit is contained in:
Kovid Goyal 2022-04-04 10:22:25 +05:30
parent 9520006466
commit c72154782b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -27,6 +27,7 @@ install_dir="$(command dirname "$script_dir")/install"
local_kitty_version_file="$install_dir/installed-kitty-version"
kitty_exe="$install_dir/bin/kitty"
what="installed"
local_kitty_version=""
if [ -r "$local_kitty_version_file" -a -f "$local_kitty_version_file" ]; then
what="updated"
@ -75,8 +76,11 @@ if [ "$OS" = "linux" ]; then
esac
fi
release_version=$(fetch_quiet "https://api.github.com/repos/kovidgoyal/kitty/releases/latest" | command grep tag_name | command head -n1 | command cut -dv -f2 | command cut -d '"' -f1)
[ -z "$release_version" ] && die "Could not get kitty latest release version"
release_version=$(fetch_quiet "https://sw.kovidgoyal.net/kitty/current-version.txt")
[ $? -ne 0 -o -z "$release_version" ] && {
[ -n "$local_kitty_version" ] && exec_kitty "$@"
die "Could not get kitty latest release version"
}
if [ "$OS" = "linux" ]; then
url="https://github.com/kovidgoyal/kitty/releases/download/v$release_version/kitty-$release_version-$arch.txz"