Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lua/remote-nvim/providers/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,12 @@ function M.get_offline_neovim_release_name(os, version, arch, release_type)
end

if os == "Linux" then
if (version == "nightly") or (version == "stable") or is_later_neovim_version(version, "v0.10.3") then
return ("nvim-%s-linux-%s.appimage"):format(version, arch)
end
return ("nvim-%s-linux.appimage"):format(version)
elseif os == "macOS" then
if (version == "nightly") or (version ~= "stable" and is_later_neovim_version(version, "v0.9.5")) then
if (version == "nightly") or (version == "stable") or is_later_neovim_version(version, "v0.9.5") then
return ("nvim-%s-macos-%s.tar.gz"):format(version, arch)
end
return ("nvim-%s-macos.tar.gz"):format(version)
Expand Down
31 changes: 24 additions & 7 deletions scripts/neovim_download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi

function display_help() {
cat <<EOM
Usage: $0 -v <nvim-version> -d <download-path> -o <os-name> -t <download-type>
Usage: $0 -v <nvim-version> -d <download-path> -o <os-name> -t <download-type> -a <architecture>
Options:
-v Specify the desired Neovim version to download.
-d Specify directory inside which Neovim release should be downloaded.
Expand Down Expand Up @@ -45,9 +45,12 @@ function download_neovim() {
local arch_type="$4"
local download_url=""
local download_path=""
local file_name=""

local download_base_url="https://github.com/neovim/neovim/releases/download"

if [ "$os" == "Linux" ]; then
download_url="https://github.com/neovim/neovim/releases/download/${version}/nvim.appimage"
file_name="nvim.appimage"
download_path="$download_dir/nvim-$version-linux.appimage"

set +e # Prevent termination based on compare_version's return
Expand All @@ -56,11 +59,11 @@ function download_neovim() {
set -e # Re-enable termination based on return values

if [[ $version == "nightly" ]] || [[ $version == "stable" ]] || [[ $result -eq 1 ]]; then
download_url="https://github.com/neovim/neovim/releases/download/${version}/nvim-linux-${arch_type}.appimage"
file_name="nvim-linux-${arch_type}.appimage"
download_path="$download_dir/nvim-$version-linux-$arch_type.appimage"
fi
elif [ "$os" == "Darwin" ]; then
download_url="https://github.com/neovim/neovim/releases/download/${version}/nvim-macos.tar.gz"
file_name="nvim-macos.tar.gz"
download_path="$download_dir/nvim-$version-macos.tar.gz"

set +e # Prevent termination based on compare_version's return
Expand All @@ -69,14 +72,16 @@ function download_neovim() {
set -e # Re-enable termination based on return values

if [[ $version == "nightly" ]] || [[ $version == "stable" ]] || [[ $result -eq 1 ]]; then
download_url="https://github.com/neovim/neovim/releases/download/${version}/nvim-macos-${arch_type}.tar.gz"
file_name="nvim-macos-${arch_type}.tar.gz"
download_path="$download_dir/nvim-$version-macos-$arch_type.tar.gz"
fi
else
echo "Error: Currently download support is present only for Linux and macOS"
exit 1
fi

local download_url="$download_base_url/${version}/$file_name"

local checksum_path="$download_path".sha256sum
local expected_checksum=""
# This ensures that they do not match
Expand All @@ -94,8 +99,20 @@ function download_neovim() {

echo "Downloading Neovim..."
download "$download_url" "$download_path"
if [[ $version != "nightly" ]]; then
# Nightly versions do not come with checksums

set +e # Prevent termination based on compare_version's return
compare_versions "$version" v0.10.4
local result=$?
set -e # Re-enable termination based on return values

if [[ $version == "nightly" ]] || [[ $version == "stable" ]] || [[ $result -eq 1 ]]; then
# Since v0.11.0, checksums are gathered in shasum.txt,
# so we need to extract the checksum from it
local temp_path="$download_path".sha256sum.tmp
download "$download_base_url/${version}/shasum.txt" "$temp_path"
cat $temp_path | grep "$file_name\$" >> "$checksum_path"
rm $temp_path
else
download "$download_url".sha256sum "$checksum_path"
fi
echo "Download completed."
Expand Down
2 changes: 1 addition & 1 deletion tests/remote-nvim/providers/provider_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ describe("Provider", function()
provider.offline_mode = true
remote_nvim.config.offline_mode.no_github = true

local release_path = ("%s/nvim-stable-linux.appimage"):format(remote_nvim.config.offline_mode.cache_dir)
local release_path = ("%s/nvim-stable-linux-x86_64.appimage"):format(remote_nvim.config.offline_mode.cache_dir)
local release_checksum_path = ("%s.sha256sum"):format(release_path)

provider:_setup_remote()
Expand Down
10 changes: 7 additions & 3 deletions tests/remote-nvim/providers/utils_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("Offline revision names are correct", function()

it("for macOS", function()
assert.equals(
"nvim-stable-macos.tar.gz",
"nvim-stable-macos-x86_64.tar.gz",
utils.get_offline_neovim_release_name("macOS", "stable", "x86_64", "binary")
)
assert.equals(
Expand All @@ -102,17 +102,21 @@ describe("Offline revision names are correct", function()

it("for Linux", function()
assert.equals(
"nvim-stable-linux.appimage",
"nvim-stable-linux-x86_64.appimage",
utils.get_offline_neovim_release_name("Linux", "stable", "x86_64", "binary")
)
assert.equals(
"nvim-nightly-linux.appimage",
"nvim-nightly-linux-x86_64.appimage",
utils.get_offline_neovim_release_name("Linux", "nightly", "x86_64", "binary")
)
assert.equals(
"nvim-v0.9.5-linux.appimage",
utils.get_offline_neovim_release_name("Linux", "v0.9.5", "x86_64", "binary")
)
assert.equals(
"nvim-v0.10.4-linux-x86_64.appimage",
utils.get_offline_neovim_release_name("Linux", "v0.10.4", "x86_64", "binary")
)
end)
end)

Expand Down