fix<Remote>: do NOT validate remote's name when edit only remote's URL

This commit is contained in:
leo 2021-06-16 20:02:05 +08:00
parent 8b538e7963
commit be8098ebe3

View file

@ -31,8 +31,10 @@ namespace SourceGit.Views.Popups {
} }
public override Task<bool> Start() { public override Task<bool> Start() {
if (remote == null || remote.Name != RemoteName) {
txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtName)) return null; if (Validation.GetHasError(txtName)) return null;
}
txtUrl.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtUrl.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtUrl)) return null; if (Validation.GetHasError(txtUrl)) return null;
@ -44,11 +46,13 @@ namespace SourceGit.Views.Popups {
if (succ) new Commands.Fetch(repo.Path, RemoteName, true, UpdateProgress).Exec(); if (succ) new Commands.Fetch(repo.Path, RemoteName, true, UpdateProgress).Exec();
} else { } else {
if (remote.URL != RemoteURL) { if (remote.URL != RemoteURL) {
new Commands.Remote(repo.Path).SetURL(remote.Name, RemoteURL); var succ = new Commands.Remote(repo.Path).SetURL(remote.Name, RemoteURL);
if (succ) remote.URL = RemoteURL;
} }
if (remote.Name != RemoteName) { if (remote.Name != RemoteName) {
new Commands.Remote(repo.Path).Rename(remote.Name, RemoteName); var succ = new Commands.Remote(repo.Path).Rename(remote.Name, RemoteName);
if (succ) remote.Name = RemoteName;
} }
} }
Models.Watcher.SetEnabled(repo.Path, true); Models.Watcher.SetEnabled(repo.Path, true);