mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
fix<CreateBranch>: fix branch name validation
This commit is contained in:
parent
04f1137f96
commit
001453d6ff
2 changed files with 10 additions and 5 deletions
|
@ -10,12 +10,14 @@ namespace SourceGit.Views.Popups {
|
||||||
private string repo = null;
|
private string repo = null;
|
||||||
private string basedOn = null;
|
private string basedOn = null;
|
||||||
|
|
||||||
public string BranchName { get; set; }
|
public string BranchName { get; set; } = "";
|
||||||
public bool AutoStash { get; set; }
|
public bool AutoStash { get; set; } = false;
|
||||||
|
|
||||||
public CreateBranch(Models.Repository repo, Models.Branch branch) {
|
public CreateBranch(Models.Repository repo, Models.Branch branch) {
|
||||||
this.repo = repo.Path;
|
this.repo = repo.Path;
|
||||||
this.basedOn = branch.Head;
|
this.basedOn = branch.FullName;
|
||||||
|
|
||||||
|
if (!branch.IsLocal) BranchName = branch.Name;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
@ -37,7 +39,7 @@ namespace SourceGit.Views.Popups {
|
||||||
|
|
||||||
public CreateBranch(Models.Repository repo, Models.Tag tag) {
|
public CreateBranch(Models.Repository repo, Models.Tag tag) {
|
||||||
this.repo = repo.Path;
|
this.repo = repo.Path;
|
||||||
this.basedOn = tag.SHA;
|
this.basedOn = tag.Name;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
@ -68,6 +70,8 @@ namespace SourceGit.Views.Popups {
|
||||||
} else {
|
} else {
|
||||||
AutoStash = true;
|
AutoStash = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
new Commands.Discard(repo).Whole();
|
||||||
}
|
}
|
||||||
|
|
||||||
new Commands.Checkout(repo).Branch(BranchName, basedOn);
|
new Commands.Checkout(repo).Branch(BranchName, basedOn);
|
||||||
|
|
|
@ -16,7 +16,8 @@ namespace SourceGit.Views.Validations {
|
||||||
|
|
||||||
name = Prefix + name;
|
name = Prefix + name;
|
||||||
foreach (var t in Repo.Branches) {
|
foreach (var t in Repo.Branches) {
|
||||||
if (t.Name == name) {
|
var check = t.IsLocal ? t.Name : $"{t.Remote}/{t.Name}";
|
||||||
|
if (check == name) {
|
||||||
return new ValidationResult(false, App.Text("DuplicatedBranchName"));
|
return new ValidationResult(false, App.Text("DuplicatedBranchName"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue