protected override async Task RunProcess()
            {
                var targetBranch = await repository.GetBranchDetails(newBaseBranch).FirstOrDefaultAsync();

                // 1. make sure everything is already merged
                // 2. run consolidate branches SQL
                // 3. delete old branches
                ImmutableList <BranchGroupCompleteData> branchesToRemove = await GetBranchesToRemove(targetBranch);

                if (await MergesInProgress(targetBranch, branchesToRemove))
                {
                    // abort, but queue another attempt
#pragma warning disable CS4014
                    orchestration.EnqueueAction(new ConsolidateMergedAction(sourceBranch: sourceBranch, newBaseBranch: newBaseBranch), skipDuplicateCheck: true);
#pragma warning restore
                    await AppendMessage($"Merges were still in queue, deferring consolidation to {newBaseBranch} from {sourceBranch}.", isError : true);

                    return;
                }
                await AppendMessage($"Consolidating to {newBaseBranch} from {sourceBranch}, removing: {string.Join(", ", branchesToRemove.Select(b => b.GroupName))}.", isError : true);

                // Integration branches remain separate. Even if they have one
                // parent, multiple things could depend on them and you don't
                // want to flatten out those commits too early.
                using (var unitOfWork = workFactory.CreateUnitOfWork())
                {
                    repository.ConsolidateBranches(branchesToRemove.Select(b => b.GroupName), targetBranch.GroupName, unitOfWork);

                    await unitOfWork.CommitAsync();
                }

                // TODO - branches could get deleted here that were ignored in the `ConsolidateBranches` logic.
                await(from branch in branchesToRemove.ToObservable()
                      from actualBranch in branch.Branches
                      from entry in AppendProcess(cli.DeleteRemote(actualBranch.Name)).WaitUntilComplete().ContinueWith <int>((t) => 0)
                      select entry);

                repository.CheckForUpdates();
            }
Exemplo n.º 2
0
 public void Post([FromServices] IRepositoryMediator repository)
 {
     repository.CheckForUpdates();
 }