Exemplo n.º 1
0
            protected override async Task RunProcess()
            {
                if (mode == DeleteBranchMode.ActualBranchOnly)
                {
                    await AppendProcess(cli.DeleteRemote(deletingBranch)).WaitUntilComplete();

                    await repository.BranchUpdated(deletingBranch, null, await repository.GetBranchRef(deletingBranch).Take(1));
                }
                else
                {
                    var details = await repository.GetBranchDetails(deletingBranch).FirstAsync();

                    using (var unitOfWork = unitOfWorkFactory.CreateUnitOfWork())
                    {
                        settings.DeleteBranchSettings(deletingBranch, unitOfWork);

                        await unitOfWork.CommitAsync();
                    }

                    if (mode != DeleteBranchMode.GroupOnly)
                    {
                        foreach (var branch in details.Branches)
                        {
                            await AppendProcess(cli.DeleteRemote(branch.Name)).WaitUntilComplete();

                            await repository.BranchUpdated(branch.Name, null, await repository.GetBranchRef(branch.Name).Take(1));
                        }
                    }
                }
            }
            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();
            }