mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-16 16:05:00 +00:00
refactor: git version related commands
* use `--pathspec-from-file=<FILE>` in `git add` command if git >= 2.25.0 * use `--pathspec-from-file=<FILE>` in `git stash push` command if git >= 2.26.0 * use `--staged` in `git stash push` command only if git >= 2.35.0
This commit is contained in:
parent
c939308e4c
commit
b26838ff68
10 changed files with 306 additions and 103 deletions
|
@ -1,13 +1,12 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Styling;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static partial class StringConverters
|
||||
public static class StringConverters
|
||||
{
|
||||
public class ToLocaleConverter : IValueConverter
|
||||
{
|
||||
|
@ -68,22 +67,6 @@ namespace SourceGit.Converters
|
|||
public static readonly FuncValueConverter<string, string> ToShortSHA =
|
||||
new FuncValueConverter<string, string>(v => v == null ? string.Empty : (v.Length > 10 ? v.Substring(0, 10) : v));
|
||||
|
||||
public static readonly FuncValueConverter<string, bool> UnderRecommendGitVersion =
|
||||
new(v =>
|
||||
{
|
||||
var match = REG_GIT_VERSION().Match(v ?? "");
|
||||
if (match.Success)
|
||||
{
|
||||
var major = int.Parse(match.Groups[1].Value);
|
||||
var minor = int.Parse(match.Groups[2].Value);
|
||||
var build = int.Parse(match.Groups[3].Value);
|
||||
|
||||
return new Version(major, minor, build) < MINIMAL_GIT_VERSION;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
public static readonly FuncValueConverter<string, string> TrimRefsPrefix =
|
||||
new FuncValueConverter<string, string>(v =>
|
||||
{
|
||||
|
@ -95,10 +78,5 @@ namespace SourceGit.Converters
|
|||
return v.Substring(13);
|
||||
return v;
|
||||
});
|
||||
|
||||
[GeneratedRegex(@"^[\s\w]*(\d+)\.(\d+)[\.\-](\d+).*$")]
|
||||
private static partial Regex REG_GIT_VERSION();
|
||||
|
||||
private static readonly Version MINIMAL_GIT_VERSION = new Version(2, 23, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue