Skip to content

Conversation

samvrlewis
Copy link
Contributor

Introduces a new 'SwiftVersion' class that can be used for comparing firmware and console versions. This was heavily inspired/ported from the old console and removes the need for the SemVer package.

As part of this, firmware upgrades from before v2.0.0 to after v2.0.0 are not allowed, as in the old console.

Introduces a new 'SwiftVersion' class that can be used for comparing
firmware and console versions. This was heavily inspired/ported from the
old console and removes the need for the SemVer package.

As part of this, firmware upgrades from before v2.0.0 to after v2.0.0
are not allowed, as in the old console.
@samvrlewis samvrlewis requested a review from a team October 21, 2021 03:35

impl PartialEq for SwiftVersion {
fn eq(&self, other: &Self) -> bool {
self.marketing == other.marketing && self.major == other.major && self.minor == other.minor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to treat all dev versions as equivalent.

With regards to namespaces, would this treat Starling 3.0 the same as Piksi Multi 3.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it does, this is a simplification that makes sense with the way we use the class (where we don't ever compare dev versions) but probably doesn't make sense otherwise.

If we don't do this then with the current implementation SwiftVersion::parse("1.1.1-dev") != SwiftVersion::parse("1.1.1") but SwiftVersion::parse("1.1.1-dev").cmp(SwiftVersion::parse("1.1.1")) == Ordering.Equal.

I think the "right" way of handling this might be to only implement PartialOrd and then only allow versions to be compared if the namespace and dev parts are the same. I guess it's probably worth doing in case this class gets used for more than it's currently used for, so that there aren't surprising results. I was just trying to avoid the verbosity of having to check that the comparisons are Some everywhere they're performed.

What do you think @silverjam ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "right" way of handling this might be to only implement PartialOrd and then only allow versions to be compared if the namespace and dev parts are the same. I guess it's probably worth doing in case this class gets used for more than it's currently used for, so that there aren't surprising results. I was just trying to avoid the verbosity of having to check that the comparisons are Some everywhere they're performed.

Yes, this is exactly what I was thinking too.

Copy link
Contributor

@silverjam silverjam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's require namespaces to be equivalent for PartialOrd, then I think we're good to go (also probably only want the pre-2.0 -> 2.0 logic if the namespace is v).

@samvrlewis samvrlewis merged commit e9ea795 into main Oct 22, 2021
@samvrlewis samvrlewis deleted the slewis/cpp-347 branch October 22, 2021 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants