public void Start() { disposable = new CompositeDisposable( orchestration.ProcessActions().Subscribe( onNext: _ => { }, onCompleted: () => { Console.WriteLine("COMPLETED - This shouldn't happen!"); }, onError: _ => { Console.WriteLine("ERROR'D - This shouldn't happen!"); Console.WriteLine(_); } ), repositoryState .RemoteBranches() .Where(branches => branches.Count > 0) .Subscribe(allBranches => // TODO - only push to branches that changed branchSettings.GetAllDownstreamBranches() .SelectMany(all => all.Select(each => each.GroupName).ToObservable()) .SelectMany(downstreamBranch => orchestrationActions.CheckDownstreamMerges(downstreamBranch)) .Subscribe( onNext: _ => { }, onError: (ex) => { Console.WriteLine(ex); } ) ) ); }
public async Task <IActionResult> CreateBranch(string branchName, [FromBody] CreateBranchRequestBody requestBody, [FromServices] IGitCli cli, [FromServices] IOrchestrationActions orchestrationActions) { var checkRefFormat = cli.CheckRefFormat(branchName); await checkRefFormat.ActiveState.DefaultIfEmpty(); if (checkRefFormat.ExitCode != 0) { return(StatusCode(400, new { code = "bad-branch-name", message = "Branch name is not valid." })); } var branch = await branchSettings.GetBranchBasicDetails(branchName).FirstOrDefaultAsync(); if (branch != null) { return(StatusCode(409, new { code = "branch-exists", message = "Branch already exists." })); } using (var unitOfWork = unitOfWorkFactory.CreateUnitOfWork()) { foreach (var addedUpstream in requestBody.AddUpstream) { branchSettings.AddBranchPropagation(addedUpstream, branchName, unitOfWork); } branchSettings.UpdateBranchSetting(branchName, requestBody.UpstreamMergePolicy, requestBody.BranchType, unitOfWork); await unitOfWork.CommitAsync(); } #pragma warning disable CS4014 orchestrationActions.CheckDownstreamMerges(branchName); #pragma warning restore CS4014 return(Ok()); }
public async Task ClearBadBranchStatus(string branchName, [FromServices] IOrchestrationActions orchestrationActions, [FromServices] IRepositoryMediator repository) { await repository.ResetBadBranchStatus(branchName); #pragma warning disable CS4014 orchestrationActions.CheckDownstreamMerges(branchName); #pragma warning restore CS4014 }
public async Task UpdateBranch(string branchName, [FromBody] UpdateBranchRequestBody requestBody, [FromServices] IOrchestrationActions orchestrationActions) { var branchesToCheck = new HashSet <string>(); branchesToCheck.Add(branchName); using (var unitOfWork = unitOfWorkFactory.CreateUnitOfWork()) { foreach (var addedUpstream in requestBody.AddUpstream) { branchSettings.AddBranchPropagation(addedUpstream, branchName, unitOfWork); branchesToCheck.Add(addedUpstream); } foreach (var addedDownstream in requestBody.AddDownstream) { branchSettings.AddBranchPropagation(branchName, addedDownstream, unitOfWork); branchesToCheck.Add(addedDownstream); } foreach (var removeUpstream in requestBody.RemoveUpstream) { branchSettings.RemoveBranchPropagation(removeUpstream, branchName, unitOfWork); branchesToCheck.Add(removeUpstream); } foreach (var removeDownstream in requestBody.RemoveDownstream) { branchSettings.RemoveBranchPropagation(branchName, removeDownstream, unitOfWork); branchesToCheck.Add(removeDownstream); } branchSettings.UpdateBranchSetting(branchName, requestBody.UpstreamMergePolicy, requestBody.BranchType, unitOfWork); await unitOfWork.CommitAsync(); } foreach (var branch in branchesToCheck) { #pragma warning disable CS4014 orchestrationActions.CheckDownstreamMerges(branch); #pragma warning restore CS4014 } }