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-02-05 23:08:37 -08:00
|
|
|
|
public Models.Branch Branch => _branch;
|
|
|
|
|
public bool IsFeature => _type == Models.GitFlowBranchType.Feature;
|
|
|
|
|
public bool IsRelease => _type == Models.GitFlowBranchType.Release;
|
|
|
|
|
public bool IsHotfix => _type == Models.GitFlowBranchType.Hotfix;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public bool KeepBranch
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = false;
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
public GitFlowFinish(Repository repo, Models.Branch branch, Models.GitFlowBranchType type)
|
|
|
|
|
{
|
2024-02-05 23:08:37 -08:00
|
|
|
|
_repo = repo;
|
|
|
|
|
_branch = branch;
|
|
|
|
|
_type = type;
|
|
|
|
|
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-02-05 23:08:37 -08:00
|
|
|
|
var branch = _branch.Name;
|
2024-03-17 18:37:06 -07:00
|
|
|
|
switch (_type)
|
|
|
|
|
{
|
|
|
|
|
case Models.GitFlowBranchType.Feature:
|
|
|
|
|
branch = branch.Substring(_repo.GitFlow.Feature.Length);
|
|
|
|
|
break;
|
|
|
|
|
case Models.GitFlowBranchType.Release:
|
|
|
|
|
branch = branch.Substring(_repo.GitFlow.Release.Length);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
branch = branch.Substring(_repo.GitFlow.Hotfix.Length);
|
|
|
|
|
break;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-02 19:17:47 -07:00
|
|
|
|
SetProgressDescription($"Git Flow - finishing {_branch.Name} ...");
|
2024-02-05 23:08:37 -08:00
|
|
|
|
var succ = new Commands.GitFlow(_repo.FullPath).Finish(_type, branch, KeepBranch);
|
|
|
|
|
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
|
|
|
|
return succ;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 18:37:06 -07:00
|
|
|
|
private readonly Repository _repo = null;
|
|
|
|
|
private readonly Models.Branch _branch = null;
|
|
|
|
|
private readonly Models.GitFlowBranchType _type = Models.GitFlowBranchType.None;
|
2024-02-05 23:08:37 -08:00
|
|
|
|
}
|
2024-03-31 01:54:29 -07:00
|
|
|
|
}
|