Skip to content

Commit

Permalink
Fix version sanitization for comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Lolle2000la committed Feb 28, 2020
1 parent 61dc196 commit ca4551f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ImageSort.WindowsUpdater/GitHubUpdateFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ public GitHubUpdateFetcher(GitHubClient client)
var gitVersionInformationType = assembly.GetType("GitVersionInformation");
var versionTag = (string)gitVersionInformationType.GetFields().First(f => f.Name == "SemVer").GetValue(null);
var version = SemVersion.Parse(versionTag);
var prereleaseParts = version.Prerelease.Split('.');

if (prereleaseParts.Length > 1)
{
if (int.TryParse(prereleaseParts[1], out int prerelease))
{
version = version.Change(prerelease: $"{prereleaseParts[0]}.{(prerelease - 1).ToString(CultureInfo.InvariantCulture.NumberFormat)}");
}
}

Release latestFitting;

Expand All @@ -43,8 +52,6 @@ public GitHubUpdateFetcher(GitHubClient client)

var releaseVersion = SemVersion.Parse(release.TagName.Substring(firstIndexOfV + 1));

if (int.TryParse(releaseVersion.Build, out int build)) releaseVersion = releaseVersion.Change(build: (build - 1).ToString(CultureInfo.InvariantCulture.NumberFormat));

var isNewVersion = version.CompareByPrecedence(releaseVersion) < 0;

return prereleaseCondition && isNewVersion;
Expand Down

0 comments on commit ca4551f

Please sign in to comment.