Skip to content

Commit

Permalink
[#39669] beta versions are older then release
Browse files Browse the repository at this point in the history
-  https://community.openproject.org/work_packages/39669
- adapted version comparison logic
  • Loading branch information
Kharonus committed Nov 8, 2021
1 parent d32caf9 commit f861136
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
This is the Changelog for the OpenProject Revit Add-in. It follows the guidelines described
in https://keepachangelog.com/en/1.0.0/. The versions follow [semantic versioning](https://semver.org/).

## [Unreleased]

### Fixed

- Pre-release versions now are correctly identified as older, when compared to the related release. I.e. when the
version `v2.3.1-beta17` is installed and the version `v2.3.1` is available, the update notification dialog is
displayed.

## [2.3.3] - 2021-11-04

### Added
Expand Down
6 changes: 6 additions & 0 deletions src/OpenProject.Browser/Models/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public int CompareTo(Version other)
if (_patch < other._patch)
return -1;

if (string.IsNullOrWhiteSpace(_suffix) && !string.IsNullOrWhiteSpace(other._suffix))
return 1;

if (!string.IsNullOrWhiteSpace(_suffix) && string.IsNullOrWhiteSpace(other._suffix))
return -1;

var stringComparison = string.CompareOrdinal(_suffix, other._suffix);
return stringComparison > 0 ? 1 : stringComparison < 0 ? -1 : 0;
}
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion test/OpenProject.Tests/Models/VersionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static IEnumerable<object[]> DataForCompare()
yield return new object[] { Version.Parse("1.0.0"), Version.Parse("1.1.0"), -1 };
yield return new object[] { Version.Parse("1.0.0"), Version.Parse("1.0.0"), 0 };
yield return new object[] { Version.Parse("1.1.13"), Version.Parse("1.1.3"), 1 };
yield return new object[] { Version.Parse("1.1.13"), Version.Parse("1.1.13-beta3"), -1 };
yield return new object[] { Version.Parse("1.1.13"), Version.Parse("1.1.13-beta3"), 1 };
yield return new object[] { Version.Parse("1.1.3-abc"), Version.Parse("1.1.3-cba"), -1 };
yield return new object[] { Version.Parse("1.1.3-b3ee44"), Version.Parse("1.1.3-02aa3e"), 1 };
yield return new object[] { Version.Parse("1.1.3-0006"), Version.Parse("1.1.3-0007"), -1 };
Expand Down

0 comments on commit f861136

Please sign in to comment.