Exemplo n.º 1
0
 public Internal(IGitCli cli, IBranchSettings settings, IRepositoryMediator repository, IUnitOfWorkFactory unitOfWorkFactory, string deletingBranch, DeleteBranchMode mode)
 {
     this.cli               = cli;
     this.settings          = settings;
     this.repository        = repository;
     this.unitOfWorkFactory = unitOfWorkFactory;
     this.deletingBranch    = deletingBranch;
     this.mode              = mode;
 }
 public ConsolidateMergedActionProcess(IGitCli cli, IRepositoryMediator repository, IBranchSettings branchSettings, IRepositoryOrchestration orchestration, IUnitOfWorkFactory workFactory, string sourceBranch, string newBaseBranch)
 {
     this.cli            = cli;
     this.repository     = repository;
     this.branchSettings = branchSettings;
     this.orchestration  = orchestration;
     this.workFactory    = workFactory;
     this.sourceBranch   = sourceBranch;
     this.newBaseBranch  = newBaseBranch;
 }
 public Internal(IGitCli cli, IRepositoryMediator repository, IBranchSettings settings, IBranchIterationMediator branchIteration, IUnitOfWorkFactory unitOfWorkFactory, IRepositoryOrchestration orchestration, IOptions <GitRepositoryOptions> options, string releaseCandidateBranch, string serviceLineBranch, string tagName, bool autoConsolidate)
 {
     this.cli                    = cli;
     this.repository             = repository;
     this.settings               = settings;
     this.branchIteration        = branchIteration;
     this.unitOfWorkFactory      = unitOfWorkFactory;
     this.orchestration          = orchestration;
     this.isReadOnly             = options.Value.ReadOnly;
     this.releaseCandidateBranch = releaseCandidateBranch;
     this.serviceLineBranch      = serviceLineBranch;
     this.tagName                = tagName;
     this.autoConsolidate        = autoConsolidate;
 }
Exemplo n.º 4
0
 public MergeDownstreamActionProcess(IGitCli cli, IGitServiceApi gitServiceApi, IUnitOfWorkFactory workFactory, IRepositoryOrchestration orchestration, IRepositoryMediator repository, IntegrateBranchesOrchestration integrateBranches, IBranchIterationMediator branchIteration, string downstreamBranch, IOptions <GitRepositoryOptions> options, IMergeStrategyManager strategyManager)
 {
     this.cli                   = cli;
     this.gitServiceApi         = gitServiceApi;
     this.integrateBranches     = integrateBranches;
     this.repository            = repository;
     this.orchestration         = orchestration;
     this.branchIteration       = branchIteration;
     this.downstreamBranchGroup = downstreamBranch;
     this.detailsTask           = repository.GetBranchDetails(downstreamBranch).FirstAsync().ToTask();
     this.latestBranchName      = detailsTask.ContinueWith(task => repository.LatestBranchName(task.Result).FirstOrDefaultAsync().ToTask()).Unwrap();
     this.strategyTask          = detailsTask.ContinueWith(task => strategyManager.GetMergeStrategy(task.Result));
     this.isReadOnly            = options.Value.ReadOnly;
     this.workFactory           = workFactory;
 }
        private async Task <string> GetRefFor(string branchName, IGitCli cli)
        {
            await cli.Fetch(branchName).ActiveState;

            return((await cli.ShowRef(branchName).ActiveOutput.FirstOrDefaultAsync()).Message);
        }
Exemplo n.º 6
0
 protected override IReactiveProcess GetCliAction(IGitCli gitCli) =>
 gitCli.CheckoutRemote(branch);
Exemplo n.º 7
0
        public LocalRepositoryState(IReactiveProcessFactory factory, IRepositoryOrchestration orchestration, IOptions <GitRepositoryOptions> options)
        {
            cli = new GitCli(factory, checkoutPath: options.Value.CheckoutPath, repository: options.Value.Repository, userName: options.Value.UserName, userEmail: options.Value.UserEmail);

            this.remoteBranchesAsync = BuildRemoteBranches();
        }
Exemplo n.º 8
0
 public static IObservable <bool> HasOutstandingCommits(this IGitCli cli, string upstreamBranch, string downstreamBranch) =>
 Observable.CombineLatest(
     cli.MergeBase(upstreamBranch, downstreamBranch).FirstOutputMessage(),
     cli.ShowRef(upstreamBranch).FirstOutputMessage(),
     (mergeBaseResult, showRefResult) => mergeBaseResult != showRefResult
     );
Exemplo n.º 9
0
 protected abstract IReactiveProcess GetCliAction(IGitCli gitCli);
 public MergeNextIterationMergeStrategy(NormalMergeStrategy normalStrategy, IGitCli cli, IGitServiceApi gitServiceApi)
 {
     this.normalStrategy = normalStrategy;
     this.cli            = cli;
     this.gitServiceApi  = gitServiceApi;
 }
 public ForceFreshMergeStrategy(MergeNextIterationMergeStrategy mergeNextIteration, IRepositoryMediator repository, IGitCli cli)
 {
     this.mergeNextIteration = mergeNextIteration;
     this.repository         = repository;
     this.cli = cli;
 }
Exemplo n.º 12
0
 public Internal(IGitCli cli, IRemoteRepositoryState repositoryState, string branchName)
 {
     this.cli             = cli;
     this.repositoryState = repositoryState;
     this.branchName      = branchName;
 }
Exemplo n.º 13
0
 public Internal(IGitCli cli, IRemoteRepositoryState repositoryState)
 {
     this.cli             = cli;
     this.repositoryState = repositoryState;
     this.branchName      = null;
 }
Exemplo n.º 14
0
 public Internal(IGitCli cli)
 {
     this.cli = cli;
 }
Exemplo n.º 15
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());
        }
            private async Task <bool> CreateOrFastForwardServiceLine(string latestBranchName, IRepositoryMediator repository, IGitCli cli)
            {
                var showRefResult = await repository.GetBranchRef(serviceLineBranch).Take(1);

                if (showRefResult == null)
                {
                    // create service line
                    await AppendProcess(cli.CheckoutRemote(latestBranchName)).WaitUntilComplete();

                    await AppendProcess(cli.CheckoutNew(serviceLineBranch)).WaitUntilComplete();

                    return(true);
                }
                else
                {
                    // fast-forward
                    await AppendProcess(cli.CheckoutRemote(serviceLineBranch)).WaitUntilComplete();

                    var fastForward = cli.MergeFastForward(latestBranchName);
                    await AppendProcess(fastForward).WaitUntilComplete();

                    var fastForwardResult = fastForward.ExitCode;

                    return(fastForwardResult == 0);
                }
            }