sourcegit/src/ViewModels/GitFlowFinish.cs

51 lines
1.4 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class GitFlowFinish : Popup
{
2024-06-14 21:44:35 -07:00
public Models.Branch Branch
{
get;
set;
} = null;
public bool IsFeature => _type == "feature";
public bool IsRelease => _type == "release";
public bool IsHotfix => _type == "hotfix";
public bool KeepBranch
{
get;
set;
} = false;
2024-06-14 21:44:35 -07:00
public GitFlowFinish(Repository repo, Models.Branch branch, string type, string prefix)
{
_repo = repo;
_type = type;
2024-06-14 21:44:35 -07:00
_prefix = prefix;
Branch = branch;
View = new Views.GitFlowFinish() { DataContext = this };
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
return Task.Run(() =>
{
2024-06-14 21:44:35 -07:00
var name = Branch.Name.StartsWith(_prefix) ? Branch.Name.Substring(_prefix.Length) : Branch.Name;
SetProgressDescription($"Git Flow - finishing {_type} {name} ...");
var succ = Commands.GitFlow.Finish(_repo.FullPath, _type, name, KeepBranch);
CallUIThread(() => _repo.SetWatcherEnabled(true));
return succ;
});
}
2024-07-14 09:30:31 -07:00
private readonly Repository _repo;
private readonly string _type;
private readonly string _prefix;
}
}