mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 20:54:59 +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
|
@ -37,6 +37,15 @@ namespace SourceGit.Views
|
|||
set => SetValue(GitVersionProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<bool> ShowGitVersionWarningProperty =
|
||||
AvaloniaProperty.Register<Preference, bool>(nameof(ShowGitVersionWarning));
|
||||
|
||||
public bool ShowGitVersionWarning
|
||||
{
|
||||
get => GetValue(ShowGitVersionWarningProperty);
|
||||
set => SetValue(ShowGitVersionWarningProperty, value);
|
||||
}
|
||||
|
||||
public bool EnableGPGCommitSigning
|
||||
{
|
||||
get;
|
||||
|
@ -93,7 +102,6 @@ namespace SourceGit.Views
|
|||
var pref = ViewModels.Preference.Instance;
|
||||
DataContext = pref;
|
||||
|
||||
var ver = string.Empty;
|
||||
if (pref.IsGitConfigured())
|
||||
{
|
||||
var config = new Commands.Config(null).ListAll();
|
||||
|
@ -122,12 +130,10 @@ namespace SourceGit.Views
|
|||
EnableHTTPSSLVerify = sslVerify == "true";
|
||||
else
|
||||
EnableHTTPSSLVerify = true;
|
||||
|
||||
ver = new Commands.Version().Query();
|
||||
}
|
||||
|
||||
UpdateGitVersion();
|
||||
InitializeComponent();
|
||||
GitVersion = ver;
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
||||
|
@ -207,7 +213,7 @@ namespace SourceGit.Views
|
|||
if (selected.Count == 1)
|
||||
{
|
||||
ViewModels.Preference.Instance.GitInstallPath = selected[0].Path.LocalPath;
|
||||
GitVersion = new Commands.Version().Query();
|
||||
UpdateGitVersion();
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
|
@ -328,6 +334,11 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnGitInstallPathChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
UpdateGitVersion();
|
||||
}
|
||||
|
||||
private void OnAddOpenAIService(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var service = new Models.OpenAIService() { Name = "Unnamed Service" };
|
||||
|
@ -346,5 +357,11 @@ namespace SourceGit.Views
|
|||
SelectedOpenAIService = null;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void UpdateGitVersion()
|
||||
{
|
||||
GitVersion = Native.OS.GitVersionString;
|
||||
ShowGitVersionWarning = !string.IsNullOrEmpty(GitVersion) && Native.OS.GitVersion < Models.GitVersions.MINIMAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue