mirror of
https://github.com/nushell/nushell.git
synced 2025-04-10 14:08:40 +02:00
make plugin compatible with nightly nushell version (#15084)
# Description Close: #15083 This pr will set `pre` field of version to `Prerelease::EMPTY`, as nushell does not require this level of checking currently. # User-Facing Changes NaN # Tests + Formatting Added 1 test # After Submitting NaN
This commit is contained in:
parent
442df9e39c
commit
81243c48f0
@ -1,4 +1,5 @@
|
||||
use nu_protocol::ShellError;
|
||||
use semver::Prerelease;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Protocol information, sent as a `Hello` message on initialization. This determines the
|
||||
@ -42,6 +43,12 @@ impl ProtocolInfo {
|
||||
|
||||
versions.sort();
|
||||
|
||||
// The version may be a nightly version (1.2.3-nightly.1).
|
||||
// It's good to mark the prerelease field as empty, so plugins
|
||||
// can work with a nightly version of Nushell.
|
||||
versions[1].pre = Prerelease::EMPTY;
|
||||
versions[0].pre = Prerelease::EMPTY;
|
||||
|
||||
// For example, if the lower version is 1.1.0, and the higher version is 1.2.3, the
|
||||
// requirement is that 1.2.3 matches ^1.1.0 (which it does)
|
||||
Ok(semver::Comparator {
|
||||
|
@ -33,3 +33,20 @@ fn protocol_info_incompatible() -> Result<(), ShellError> {
|
||||
assert!(!ver_1_1_0.is_compatible_with(&ver_2_0_0)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn protocol_info_compatible_with_nightly() -> Result<(), ShellError> {
|
||||
let ver_1_2_3 = ProtocolInfo {
|
||||
protocol: Protocol::NuPlugin,
|
||||
version: "1.2.3".into(),
|
||||
features: vec![],
|
||||
};
|
||||
let ver_1_1_0 = ProtocolInfo {
|
||||
protocol: Protocol::NuPlugin,
|
||||
version: "1.1.0-nightly.1".into(),
|
||||
features: vec![],
|
||||
};
|
||||
assert!(ver_1_1_0.is_compatible_with(&ver_1_2_3)?);
|
||||
assert!(ver_1_2_3.is_compatible_with(&ver_1_1_0)?);
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user