public async Task Visit(CreateMergeRequestOptions options)
        {
            if (!ValidateConfiguration())
            {
                return;
            }

            var parameters = _parametersHandler.NegotiateCreateMergeRequestParameters(options);

            if (parameters.IsSuccess)
            {
                await _mergesHandler.CreateMergeRequest(parameters.Value);
            }
            else
            {
                ShowError(parameters);
            }
        }
 public Result <CreateMergeRequestParameters> NegotiateCreateMergeRequestParameters(CreateMergeRequestOptions options)
 {
     return(_mergesParametersNegotiator.NegotiateCreateMergeRequestParameters(options, _appSettings.DefaultProject));
 }
        public Result <CreateMergeRequestParameters> NegotiateCreateMergeRequestParameters(CreateMergeRequestOptions options, string defaultProject)
        {
            var project = GetProject(options, defaultProject);

            if (project.IsFailure)
            {
                return(Fail <CreateMergeRequestParameters>(project));
            }

            return(Ok(new CreateMergeRequestParameters(
                          options.Title,
                          options.Source,
                          options.Destination,
                          project.Value,
                          options.Assignee)
            {
                AssignedToCurrentUser = options.AssignMyself
            }));
        }
Exemple #4
0
        public void NegotiateCreateMergeRequestParametersReturnsFailureForMissingProject(CreateMergeRequestOptions options)
        {
            options.Project = "";
            var sut = new MergeRequestsParametersNegotiator();

            sut.NegotiateCreateMergeRequestParameters(options, "").IsFailure.Should().BeTrue();
        }
Exemple #5
0
        public void NegotiateCreateMergeRequestParametersCreatesParametersFromOptions(CreateMergeRequestOptions options, string defaultProject)
        {
            var sut = new MergeRequestsParametersNegotiator();

            sut.NegotiateCreateMergeRequestParameters(options, defaultProject).Value.Should().Match <CreateMergeRequestParameters>(o =>
                                                                                                                                   o.Title == options.Title &&
                                                                                                                                   o.SourceBranch == options.Source &&
                                                                                                                                   o.TargetBranch == options.Destination &&
                                                                                                                                   o.Assignee == options.Assignee &&
                                                                                                                                   o.AssignedToCurrentUser == options.AssignMyself &&
                                                                                                                                   o.Project == options.Project);
        }