mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
62 lines
2.1 KiB
C#
62 lines
2.1 KiB
C#
using System.Threading.Tasks;
|
|
using System.Windows.Controls;
|
|
|
|
namespace SourceGit.Views.Popups {
|
|
/// <summary>
|
|
/// Git-Flow start命令操作面板
|
|
/// </summary>
|
|
public partial class GitFlowStart : Controls.PopupWidget {
|
|
private string repo = null;
|
|
private Models.GitFlowBranchType type = Models.GitFlowBranchType.None;
|
|
|
|
public string BranchName { get; set; }
|
|
|
|
public GitFlowStart(Models.Repository repo, Models.GitFlowBranchType type) {
|
|
this.repo = repo.Path;
|
|
this.type = type;
|
|
|
|
InitializeComponent();
|
|
|
|
ruleBranch.Repo = repo;
|
|
switch (type) {
|
|
case Models.GitFlowBranchType.Feature:
|
|
ruleBranch.Prefix = repo.GitFlow.Feature;
|
|
txtPrefix.Text = repo.GitFlow.Feature;
|
|
break;
|
|
case Models.GitFlowBranchType.Release:
|
|
ruleBranch.Prefix = repo.GitFlow.Release;
|
|
txtPrefix.Text = repo.GitFlow.Release;
|
|
break;
|
|
case Models.GitFlowBranchType.Hotfix:
|
|
ruleBranch.Prefix = repo.GitFlow.Hotfix;
|
|
txtPrefix.Text = repo.GitFlow.Hotfix;
|
|
break;
|
|
}
|
|
}
|
|
|
|
public override string GetTitle() {
|
|
switch (type) {
|
|
case Models.GitFlowBranchType.Feature:
|
|
return App.Text("GitFlow.StartFeatureTitle");
|
|
case Models.GitFlowBranchType.Release:
|
|
return App.Text("GitFlow.StartReleaseTitle");
|
|
case Models.GitFlowBranchType.Hotfix:
|
|
return App.Text("GitFlow.StartHotfixTitle");
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public override Task<bool> Start() {
|
|
txtBranchName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
|
if (Validation.GetHasError(txtBranchName)) return null;
|
|
|
|
return Task.Run(() => {
|
|
Models.Watcher.SetEnabled(repo, false);
|
|
new Commands.GitFlow(repo).Start(type, BranchName);
|
|
Models.Watcher.SetEnabled(repo, true);
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
}
|