Skip to content

Commit 9a23aff

Browse files
authored
Fix release name for newer versions of neovim on Linux (#205)
* Fix release name for newer versions of neovim on Linux * Fix checksum downloading * Fix indenting issue * Fix broken CI and stable release download * ...and also nightly build * Removed duplicate declaration of `download_url`
1 parent bc39422 commit 9a23aff

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

lua/remote-nvim/providers/utils.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ function M.get_offline_neovim_release_name(os, version, arch, release_type)
154154
end
155155

156156
if os == "Linux" then
157+
if (version == "nightly") or (version == "stable") or is_later_neovim_version(version, "v0.10.3") then
158+
return ("nvim-%s-linux-%s.appimage"):format(version, arch)
159+
end
157160
return ("nvim-%s-linux.appimage"):format(version)
158161
elseif os == "macOS" then
159-
if (version == "nightly") or (version ~= "stable" and is_later_neovim_version(version, "v0.9.5")) then
162+
if (version == "nightly") or (version == "stable") or is_later_neovim_version(version, "v0.9.5") then
160163
return ("nvim-%s-macos-%s.tar.gz"):format(version, arch)
161164
end
162165
return ("nvim-%s-macos.tar.gz"):format(version)

scripts/neovim_download.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fi
1515

1616
function display_help() {
1717
cat <<EOM
18-
Usage: $0 -v <nvim-version> -d <download-path> -o <os-name> -t <download-type>
18+
Usage: $0 -v <nvim-version> -d <download-path> -o <os-name> -t <download-type> -a <architecture>
1919
Options:
2020
-v Specify the desired Neovim version to download.
2121
-d Specify directory inside which Neovim release should be downloaded.
@@ -43,11 +43,13 @@ function download_neovim() {
4343
local version="$2"
4444
local download_dir="$3"
4545
local arch_type="$4"
46-
local download_url=""
4746
local download_path=""
47+
local file_name=""
48+
49+
local download_base_url="https://github.com/neovim/neovim/releases/download"
4850

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

5355
set +e # Prevent termination based on compare_version's return
@@ -56,11 +58,11 @@ function download_neovim() {
5658
set -e # Re-enable termination based on return values
5759

5860
if [[ $version == "nightly" ]] || [[ $version == "stable" ]] || [[ $result -eq 1 ]]; then
59-
download_url="https://github.com/neovim/neovim/releases/download/${version}/nvim-linux-${arch_type}.appimage"
61+
file_name="nvim-linux-${arch_type}.appimage"
6062
download_path="$download_dir/nvim-$version-linux-$arch_type.appimage"
6163
fi
6264
elif [ "$os" == "Darwin" ]; then
63-
download_url="https://github.com/neovim/neovim/releases/download/${version}/nvim-macos.tar.gz"
65+
file_name="nvim-macos.tar.gz"
6466
download_path="$download_dir/nvim-$version-macos.tar.gz"
6567

6668
set +e # Prevent termination based on compare_version's return
@@ -69,14 +71,16 @@ function download_neovim() {
6971
set -e # Re-enable termination based on return values
7072

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

82+
local download_url="$download_base_url/${version}/$file_name"
83+
8084
local checksum_path="$download_path".sha256sum
8185
local expected_checksum=""
8286
# This ensures that they do not match
@@ -94,8 +98,20 @@ function download_neovim() {
9498

9599
echo "Downloading Neovim..."
96100
download "$download_url" "$download_path"
97-
if [[ $version != "nightly" ]]; then
98-
# Nightly versions do not come with checksums
101+
102+
set +e # Prevent termination based on compare_version's return
103+
compare_versions "$version" v0.10.4
104+
local result=$?
105+
set -e # Re-enable termination based on return values
106+
107+
if [[ $version == "nightly" ]] || [[ $version == "stable" ]] || [[ $result -eq 1 ]]; then
108+
# Since v0.11.0, checksums are gathered in shasum.txt,
109+
# so we need to extract the checksum from it
110+
local temp_path="$download_path".sha256sum.tmp
111+
download "$download_base_url/${version}/shasum.txt" "$temp_path"
112+
cat $temp_path | grep "$file_name\$" >> "$checksum_path"
113+
rm $temp_path
114+
else
99115
download "$download_url".sha256sum "$checksum_path"
100116
fi
101117
echo "Download completed."

tests/remote-nvim/providers/provider_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ describe("Provider", function()
684684
provider.offline_mode = true
685685
remote_nvim.config.offline_mode.no_github = true
686686

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

690690
provider:_setup_remote()

tests/remote-nvim/providers/utils_spec.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe("Offline revision names are correct", function()
8383

8484
it("for macOS", function()
8585
assert.equals(
86-
"nvim-stable-macos.tar.gz",
86+
"nvim-stable-macos-x86_64.tar.gz",
8787
utils.get_offline_neovim_release_name("macOS", "stable", "x86_64", "binary")
8888
)
8989
assert.equals(
@@ -102,17 +102,21 @@ describe("Offline revision names are correct", function()
102102

103103
it("for Linux", function()
104104
assert.equals(
105-
"nvim-stable-linux.appimage",
105+
"nvim-stable-linux-x86_64.appimage",
106106
utils.get_offline_neovim_release_name("Linux", "stable", "x86_64", "binary")
107107
)
108108
assert.equals(
109-
"nvim-nightly-linux.appimage",
109+
"nvim-nightly-linux-x86_64.appimage",
110110
utils.get_offline_neovim_release_name("Linux", "nightly", "x86_64", "binary")
111111
)
112112
assert.equals(
113113
"nvim-v0.9.5-linux.appimage",
114114
utils.get_offline_neovim_release_name("Linux", "v0.9.5", "x86_64", "binary")
115115
)
116+
assert.equals(
117+
"nvim-v0.10.4-linux-x86_64.appimage",
118+
utils.get_offline_neovim_release_name("Linux", "v0.10.4", "x86_64", "binary")
119+
)
116120
end)
117121
end)
118122

0 commit comments

Comments
 (0)