From 183cb8a658cb9313799aa72e135661be728e3ec6 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 23 Jul 2024 14:36:27 +0800 Subject: [PATCH] enhance: supports checking updates with hotfix version --- src/Commands/AssumeUnchanged.cs | 10 +++++----- src/Commands/QueryStashChanges.cs | 1 - src/Models/Version.cs | 22 ++++++++++------------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Commands/AssumeUnchanged.cs b/src/Commands/AssumeUnchanged.cs index f4cfe32b..1898122a 100644 --- a/src/Commands/AssumeUnchanged.cs +++ b/src/Commands/AssumeUnchanged.cs @@ -5,11 +5,11 @@ namespace SourceGit.Commands { public partial class AssumeUnchanged { - partial class ViewCommand : Command - { - [GeneratedRegex(@"^(\w)\s+(.+)$")] - private static partial Regex REG(); + [GeneratedRegex(@"^(\w)\s+(.+)$")] + private static partial Regex REG_PARSE(); + class ViewCommand : Command + { public ViewCommand(string repo) { WorkingDirectory = repo; @@ -25,7 +25,7 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { - var match = REG().Match(line); + var match = REG_PARSE().Match(line); if (!match.Success) return; diff --git a/src/Commands/QueryStashChanges.cs b/src/Commands/QueryStashChanges.cs index bf61ca2d..3b8d2db6 100644 --- a/src/Commands/QueryStashChanges.cs +++ b/src/Commands/QueryStashChanges.cs @@ -5,7 +5,6 @@ namespace SourceGit.Commands { public partial class QueryStashChanges : Command { - [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")] private static partial Regex REG_FORMAT(); diff --git a/src/Models/Version.cs b/src/Models/Version.cs index aca1f0fc..35c21778 100644 --- a/src/Models/Version.cs +++ b/src/Models/Version.cs @@ -1,10 +1,9 @@ using System.Reflection; using System.Text.Json.Serialization; -using System.Text.RegularExpressions; namespace SourceGit.Models { - public partial class Version + public class Version { [JsonPropertyName("name")] public string Name { get; set; } @@ -15,21 +14,20 @@ namespace SourceGit.Models [JsonPropertyName("body")] public string Body { get; set; } - [GeneratedRegex(@"^v(\d+)\.(\d+)$")] - private static partial Regex REG_VERSION_TAG(); - public bool IsNewVersion { get { - var match = REG_VERSION_TAG().Match(TagName); - if (!match.Success) + try + { + System.Version version = new System.Version(TagName.Substring(1)); + System.Version current = Assembly.GetExecutingAssembly().GetName().Version!; + return current.CompareTo(version) < 0; + } + catch + { return false; - - var major = int.Parse(match.Groups[1].Value); - var minor = int.Parse(match.Groups[2].Value); - var ver = Assembly.GetExecutingAssembly().GetName().Version!; - return ver.Major < major || (ver.Major == major && ver.Minor < minor); + } } } }