feat: show tooltip if git version too low

This commit is contained in:
Gadfly 2024-05-29 17:00:17 +08:00
parent 0b09d210be
commit 2f7ef1ef2b
5 changed files with 37 additions and 4 deletions

View file

@ -69,5 +69,22 @@ namespace SourceGit.Converters
public static readonly FuncValueConverter<string, string> ToShortSHA =
new FuncValueConverter<string, string>(v => v.Length > 10 ? v.Substring(0, 10) : v);
public static readonly FuncValueConverter<string, bool> UnderRecommendGitVersion =
new(v =>
{
if (string.IsNullOrEmpty(v))
return true;
var versionParts = v.Split(new[] { '.', '-' }, StringSplitOptions.RemoveEmptyEntries);
if (versionParts.Length < 3)
return true;
if (!int.TryParse(versionParts[0], out var major) ||
!int.TryParse(versionParts[1], out var minor) ||
!int.TryParse(versionParts[2], out var build))
return true;
var gitVersion = new Version(major, minor, build);
var targetVersion = new Version(2, 23, 0);
return gitVersion < targetVersion;
});
}
}