mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-24 02:40:24 +08:00
fix<CreateBranch>: fix branch name validation
This commit is contained in:
@@ -10,12 +10,14 @@ namespace SourceGit.Views.Popups {
|
||||
private string repo = null;
|
||||
private string basedOn = null;
|
||||
|
||||
public string BranchName { get; set; }
|
||||
public bool AutoStash { get; set; }
|
||||
public string BranchName { get; set; } = "";
|
||||
public bool AutoStash { get; set; } = false;
|
||||
|
||||
public CreateBranch(Models.Repository repo, Models.Branch branch) {
|
||||
this.repo = repo.Path;
|
||||
this.basedOn = branch.Head;
|
||||
this.basedOn = branch.FullName;
|
||||
|
||||
if (!branch.IsLocal) BranchName = branch.Name;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
@@ -37,7 +39,7 @@ namespace SourceGit.Views.Popups {
|
||||
|
||||
public CreateBranch(Models.Repository repo, Models.Tag tag) {
|
||||
this.repo = repo.Path;
|
||||
this.basedOn = tag.SHA;
|
||||
this.basedOn = tag.Name;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
@@ -68,6 +70,8 @@ namespace SourceGit.Views.Popups {
|
||||
} else {
|
||||
AutoStash = true;
|
||||
}
|
||||
} else {
|
||||
new Commands.Discard(repo).Whole();
|
||||
}
|
||||
|
||||
new Commands.Checkout(repo).Branch(BranchName, basedOn);
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace SourceGit.Views.Validations {
|
||||
|
||||
name = Prefix + name;
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user