Exemplo n.º 1
0
 public RepositoryStateDriver(IRemoteRepositoryState repositoryState, IRepositoryOrchestration orchestration, IOrchestrationActions orchestrationActions, IBranchSettings branchSettings)
 {
     this.repositoryState      = repositoryState;
     this.orchestration        = orchestration;
     this.orchestrationActions = orchestrationActions;
     this.branchSettings       = branchSettings;
 }
Exemplo n.º 2
0
        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
        }
Exemplo n.º 3
0
 public RepositoryMediator(IRemoteRepositoryState repositoryState, IBranchSettings branchSettings, IBranchIterationMediator branchIteration, IGitServiceApi gitApi, IOrchestrationActions actions)
 {
     this.repositoryState = repositoryState;
     this.branchSettings  = branchSettings;
     this.branchIteration = branchIteration;
     this.gitApi          = gitApi;
     this.actions         = actions;
 }
Exemplo n.º 4
0
        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
            }
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
 public void DeleteBranch(string branchName, [FromServices] IOrchestrationActions orchestrationActions, [FromQuery] DeleteBranchMode mode = DeleteBranchMode.BranchAndGroup)
 {
     orchestrationActions.DeleteBranch(branchName, mode);
 }
Exemplo n.º 7
0
 public void ConsolidateMerged([FromBody] string sourceBranch, string branchName, [FromServices] IOrchestrationActions orchestrationActions)
 {
     orchestrationActions.ConsolidateMerged(sourceBranch, branchName);
 }
Exemplo n.º 8
0
 public void PromoteServiceLine([FromBody] PromoteServiceLineBody requestBody, [FromServices] IOrchestrationActions orchestrationActions)
 {
     orchestrationActions.ReleaseToServiceLine(requestBody.ReleaseCandidate, requestBody.ServiceLine, requestBody.TagName, requestBody.AutoConsolidate);
 }