feature<Preference>: try finding git.exe automatically

This commit is contained in:
李通洲 2021-09-03 22:22:53 +08:00
parent 5e706588a0
commit adce866716

View file

@ -49,12 +49,18 @@ namespace SourceGit.Views {
} }
private void SelectGitPath(object sender, RoutedEventArgs e) { private void SelectGitPath(object sender, RoutedEventArgs e) {
var dialog = new OpenFileDialog(); var sb = new StringBuilder("git.exe");
dialog.Filter = "Git Executable|git.exe"; string dir = PathFindOnPath(sb, null)
dialog.FileName = "git.exe"; ? sb.ToString()
dialog.Title = App.Text("Preference.Dialog.GitExe"); : Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
dialog.CheckFileExists = true; var dialog = new OpenFileDialog {
Filter = "Git Executable|git.exe",
FileName = "git.exe",
Title = App.Text("Preference.Dialog.GitExe"),
InitialDirectory = dir,
CheckFileExists = true,
};
if (dialog.ShowDialog() == true) { if (dialog.ShowDialog() == true) {
Models.Preference.Instance.Git.Path = dialog.FileName; Models.Preference.Instance.Git.Path = dialog.FileName;