Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle new release naming convention #251

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
72 changes: 60 additions & 12 deletions src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ pub fn get_file_type() -> &'static str {
/// This function takes an `Option<Version>` as an argument, which represents the version of Neovim.
/// It checks the target operating system and architecture using the `cfg!` macro and returns a string that corresponds to the appropriate Neovim binary for the platform.
/// For Windows, it returns "nvim-win64".
/// For macOS, it checks the version of Neovim. If the version is less than or equal to 0.9.5, it returns "nvim-macos". If the target architecture is "aarch64", it returns "nvim-macos-arm64". Otherwise, it returns "nvim-macos-x86_64".
/// For other operating systems, it returns "nvim-linux64".
/// For macOS, it checks the version of Neovim:
/// - If version <= 0.9.5, returns "nvim-macos"
/// - If version > 0.9.5 and architecture is arm64, returns "nvim-macos-arm64"
/// - If version > 0.9.5 and architecture is x86_64, returns "nvim-macos-x86_64"
/// For Linux, it checks the version of Neovim:
/// - If version <= 0.10.3, returns "nvim-linux64"
/// - If version > 0.10.3 and architecture is arm64, returns "nvim-linux-arm64"
/// - If version > 0.10.3 and architecture is x86_64, returns "nvim-linux-x86_64"
///
/// # Arguments
///
Expand Down Expand Up @@ -70,7 +76,16 @@ pub fn get_platform_name(version: &Option<Version>) -> &'static str {
"nvim-macos-x86_64"
}
} else {
"nvim-linux64"
if version
.as_ref()
.map_or(false, |x| x <= &Version::new(0, 10, 3))
{
"nvim-linux64"
} else if cfg!(target_arch = "arm64") {
"nvim-linux-arm64"
} else {
"nvim-linux-x86_64"
}
}
}

Expand All @@ -79,8 +94,14 @@ pub fn get_platform_name(version: &Option<Version>) -> &'static str {
/// This function takes an `Option<Version>` as an argument, which represents the version of Neovim to be downloaded.
/// It checks the target operating system and architecture using the `cfg!` macro and returns a string that corresponds to the appropriate Neovim download for the platform.
/// For Windows, it returns "nvim-win64".
/// For macOS, it checks the version of Neovim. If the version is less than or equal to 0.9.5, it returns "nvim-macos". If the target architecture is "aarch64", it returns "nvim-macos-arm64". Otherwise, it returns "nvim-macos-x86_64".
/// For other operating systems, it returns "nvim".
/// For macOS, it checks the version of Neovim:
/// - If version <= 0.9.5, returns "nvim-macos"
/// - If version > 0.9.5 and architecture is arm64, returns "nvim-macos-arm64"
/// - If version > 0.9.5 and architecture is x86_64, returns "nvim-macos-x86_64"
/// For Linux, it checks the version of Neovim:
/// - If version <= 0.10.3, returns "nvim"
/// - If version > 0.10.3 and architecture is arm64, returns "nvim-linux-arm64"
/// - If version > 0.10.3 and architecture is x86_64, returns "nvim-linux-x86_64"
///
/// # Arguments
///
Expand Down Expand Up @@ -111,7 +132,16 @@ pub fn get_platform_name_download(version: &Option<Version>) -> &'static str {
"nvim-macos-x86_64"
}
} else {
"nvim"
if version
.as_ref()
.map_or(false, |x| x <= &Version::new(0, 10, 3))
{
"nvim"
} else if cfg!(target_arch = "arm64") {
"nvim-linux-arm64"
} else {
"nvim-linux-x86_64"
}
}
}

Expand All @@ -131,9 +161,18 @@ mod tests {
super::get_platform_name_download(&None),
"nvim-macos-x86_64"
);
} else if cfg!(target_arch = "arm64") {
assert_eq!(super::get_platform_name(&None), "nvim-linux-arm64");
assert_eq!(
super::get_platform_name_download(&None),
"nvim-linux-arm64"
);
} else {
assert_eq!(super::get_platform_name(&None), "nvim-linux64");
assert_eq!(super::get_platform_name_download(&None), "nvim");
assert_eq!(super::get_platform_name(&None), "nvim-linux-x86_64");
assert_eq!(
super::get_platform_name_download(&None),
"nvim-linux-x86_64"
);
}
}

Expand All @@ -146,8 +185,8 @@ mod tests {
assert_eq!(super::get_platform_name(&version), "nvim-macos");
assert_eq!(super::get_platform_name_download(&version), "nvim-macos");
} else {
assert_eq!(super::get_platform_name(&None), "nvim-linux64");
assert_eq!(super::get_platform_name_download(&None), "nvim");
assert_eq!(super::get_platform_name(&version), "nvim-linux64");
assert_eq!(super::get_platform_name_download(&version), "nvim");
}
}

Expand All @@ -168,9 +207,18 @@ mod tests {
super::get_platform_name_download(&version),
"nvim-macos-x86_64"
);
} else if cfg!(target_arch = "arm64") {
assert_eq!(super::get_platform_name(&version), "nvim-linux-arm64");
assert_eq!(
super::get_platform_name_download(&version),
"nvim-linux-arm64"
);
} else {
assert_eq!(super::get_platform_name(&version), "nvim-linux64");
assert_eq!(super::get_platform_name_download(&version), "nvim");
assert_eq!(super::get_platform_name(&version), "nvim-linux-x86_64");
assert_eq!(
super::get_platform_name_download(&version),
"nvim-linux-x86_64"
);
}
}
}