enhance: supports checking updates with hotfix version

This commit is contained in:
leo 2024-07-23 14:36:27 +08:00
parent 40d5a7c7f3
commit 183cb8a658
No known key found for this signature in database
3 changed files with 15 additions and 18 deletions

View file

@ -5,11 +5,11 @@ namespace SourceGit.Commands
{ {
public partial class AssumeUnchanged public partial class AssumeUnchanged
{ {
partial class ViewCommand : Command [GeneratedRegex(@"^(\w)\s+(.+)$")]
{ private static partial Regex REG_PARSE();
[GeneratedRegex(@"^(\w)\s+(.+)$")]
private static partial Regex REG();
class ViewCommand : Command
{
public ViewCommand(string repo) public ViewCommand(string repo)
{ {
WorkingDirectory = repo; WorkingDirectory = repo;
@ -25,7 +25,7 @@ namespace SourceGit.Commands
protected override void OnReadline(string line) protected override void OnReadline(string line)
{ {
var match = REG().Match(line); var match = REG_PARSE().Match(line);
if (!match.Success) if (!match.Success)
return; return;

View file

@ -5,7 +5,6 @@ namespace SourceGit.Commands
{ {
public partial class QueryStashChanges : Command public partial class QueryStashChanges : Command
{ {
[GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")] [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")]
private static partial Regex REG_FORMAT(); private static partial Regex REG_FORMAT();

View file

@ -1,10 +1,9 @@
using System.Reflection; using System.Reflection;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
namespace SourceGit.Models namespace SourceGit.Models
{ {
public partial class Version public class Version
{ {
[JsonPropertyName("name")] [JsonPropertyName("name")]
public string Name { get; set; } public string Name { get; set; }
@ -15,21 +14,20 @@ namespace SourceGit.Models
[JsonPropertyName("body")] [JsonPropertyName("body")]
public string Body { get; set; } public string Body { get; set; }
[GeneratedRegex(@"^v(\d+)\.(\d+)$")]
private static partial Regex REG_VERSION_TAG();
public bool IsNewVersion public bool IsNewVersion
{ {
get get
{ {
var match = REG_VERSION_TAG().Match(TagName); try
if (!match.Success) {
System.Version version = new System.Version(TagName.Substring(1));
System.Version current = Assembly.GetExecutingAssembly().GetName().Version!;
return current.CompareTo(version) < 0;
}
catch
{
return false; 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);
} }
} }
} }