mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 21:54:59 +00:00
feature<Preference>: query git config after selecting git path
This commit is contained in:
parent
adce866716
commit
1a5fdc540c
3 changed files with 19 additions and 7 deletions
|
@ -24,12 +24,7 @@ namespace SourceGit.Views {
|
|||
public bool EnableWindowsTerminal { get; set; } = PathFindOnPath(new StringBuilder("wt.exe"), null);
|
||||
|
||||
public Preference() {
|
||||
if (Models.Preference.Instance.IsReady) {
|
||||
User = new Commands.Config().Get("user.name");
|
||||
Email = new Commands.Config().Get("user.email");
|
||||
CRLF = new Commands.Config().Get("core.autocrlf");
|
||||
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
||||
} else {
|
||||
if (!UpdateGitInfoIfReady()) {
|
||||
User = "";
|
||||
Email = "";
|
||||
CRLF = "false";
|
||||
|
@ -42,6 +37,15 @@ namespace SourceGit.Views {
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
private bool UpdateGitInfoIfReady() {
|
||||
if (!Models.Preference.Instance.IsReady) return false;
|
||||
User = new Commands.Config().Get("user.name");
|
||||
Email = new Commands.Config().Get("user.email");
|
||||
CRLF = new Commands.Config().Get("core.autocrlf");
|
||||
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
||||
return true;
|
||||
}
|
||||
|
||||
#region EVENTS
|
||||
private void LocaleChanged(object sender, SelectionChangedEventArgs e) {
|
||||
Models.Locale.Change();
|
||||
|
@ -65,6 +69,11 @@ namespace SourceGit.Views {
|
|||
if (dialog.ShowDialog() == true) {
|
||||
Models.Preference.Instance.Git.Path = dialog.FileName;
|
||||
editGitPath?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
if (UpdateGitInfoIfReady()) {
|
||||
editGitUser?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
editGitEmail?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
editGitCrlf?.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue