Browse Source

Add better version displays with auto .net8 hash strings

pull/324/head
Ionite 1 year ago
parent
commit
1910cbfe10
No known key found for this signature in database
  1. 5
      StabilityMatrix.Avalonia/ViewModels/Dialogs/UpdateViewModel.cs
  2. 2
      StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs
  3. 24
      StabilityMatrix.Core/Extensions/SemVersionExtensions.cs

5
StabilityMatrix.Avalonia/ViewModels/Dialogs/UpdateViewModel.cs

@ -13,6 +13,7 @@ using StabilityMatrix.Avalonia.Languages;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.Views.Dialogs;
using StabilityMatrix.Core.Attributes;
using StabilityMatrix.Core.Extensions;
using StabilityMatrix.Core.Helper;
using StabilityMatrix.Core.Models.Progress;
using StabilityMatrix.Core.Models.Update;
@ -92,8 +93,8 @@ public partial class UpdateViewModel : ContentDialogViewModelBase
partial void OnUpdateInfoChanged(UpdateInfo? value)
{
CurrentVersionText = $"v{Compat.AppVersion}";
NewVersionText = $"v{value?.Version}";
CurrentVersionText = $"v{Compat.AppVersion.ToDisplayString()}";
NewVersionText = $"v{value?.Version.ToDisplayString()}";
}
public override async Task OnLoadedAsync()

2
StabilityMatrix.Avalonia/ViewModels/Settings/MainSettingsViewModel.cs

@ -78,7 +78,7 @@ public partial class MainSettingsViewModel : PageViewModelBase
// ReSharper disable once MemberCanBeMadeStatic.Global
public string AppVersion =>
$"Version {Compat.AppVersion}" + (Program.IsDebugBuild ? " (Debug)" : "");
$"Version {Compat.AppVersion.ToDisplayString()}" + (Program.IsDebugBuild ? " (Debug)" : "");
// Theme section
[ObservableProperty]

24
StabilityMatrix.Core/Extensions/SemVersionExtensions.cs

@ -0,0 +1,24 @@
using Semver;
namespace StabilityMatrix.Core.Extensions;
public static class SemVersionExtensions
{
public static string ToDisplayString(this SemVersion version)
{
var versionString = $"{version.Major}.{version.Minor}.{version.Patch}";
// Add the build metadata if we have pre-release information
if (version.PrereleaseIdentifiers.Count > 0)
{
versionString += $"-{version.Prerelease}";
if (!string.IsNullOrWhiteSpace(version.Metadata))
{
// First 7 characters of the commit hash
versionString += $"+{version.Metadata[..7]}";
}
}
return versionString;
}
}
Loading…
Cancel
Save