mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
fix<Remote>: do NOT check remote name if only edit it's URL
This commit is contained in:
parent
f476d758ca
commit
8050d5a2ab
2 changed files with 7 additions and 3 deletions
|
@ -31,6 +31,7 @@ namespace SourceGit.Helpers {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RemoteNameRule : ValidationRule {
|
public class RemoteNameRule : ValidationRule {
|
||||||
public Git.Repository Repo { get; set; }
|
public Git.Repository Repo { get; set; }
|
||||||
|
public Git.Remote Old { get; set; }
|
||||||
|
|
||||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
|
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
|
||||||
var regex = new Regex(@"^[\w\-\.]+$");
|
var regex = new Regex(@"^[\w\-\.]+$");
|
||||||
|
@ -40,9 +41,11 @@ namespace SourceGit.Helpers {
|
||||||
if (string.IsNullOrEmpty(name)) return new ValidationResult(false, "Remote name can NOT be null");
|
if (string.IsNullOrEmpty(name)) return new ValidationResult(false, "Remote name can NOT be null");
|
||||||
if (!regex.IsMatch(name)) return new ValidationResult(false, $"Bad name for remote. Regex: ^[\\w\\-\\.]+$");
|
if (!regex.IsMatch(name)) return new ValidationResult(false, $"Bad name for remote. Regex: ^[\\w\\-\\.]+$");
|
||||||
|
|
||||||
foreach (var t in remotes) {
|
if (Old == null || name != Old.Name) {
|
||||||
if (t.Name == name) {
|
foreach (var t in remotes) {
|
||||||
return new ValidationResult(false, $"Remote '{name}' already exists");
|
if (t.Name == name) {
|
||||||
|
return new ValidationResult(false, $"Remote '{name}' already exists");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
nameValidator.Repo = repo;
|
nameValidator.Repo = repo;
|
||||||
|
nameValidator.Old = remote;
|
||||||
|
|
||||||
if (remote != null) {
|
if (remote != null) {
|
||||||
title.Content = "Edit Remote";
|
title.Content = "Edit Remote";
|
||||||
|
|
Loading…
Reference in a new issue