2024-02-05 23:08:37 -08:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
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";
|
2024-02-05 23:08:37 -08:00
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public bool KeepBranch
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = false;
|
|
|
|
|
|
2024-06-14 21:44:35 -07:00
|
|
|
|
public GitFlowFinish(Repository repo, Models.Branch branch, string type, string prefix)
|
2024-03-17 18:37:06 -07:00
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
_repo = repo;
|
|
|
|
|
_type = type;
|
2024-06-14 21:44:35 -07:00
|
|
|
|
_prefix = prefix;
|
|
|
|
|
|
|
|
|
|
Branch = branch;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
View = new Views.GitFlowFinish() { DataContext = this };
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public override Task<bool> Sure()
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
_repo.SetWatcherEnabled(false);
|
2024-03-17 18:37:06 -07:00
|
|
|
|
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);
|
2024-02-05 23:08:37 -08:00
|
|
|
|
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;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|