Beispiel #1
0
        public async Task ListMerges(ListMergesParameters parameters)
        {
            var mergesResult = await _gitLabFacade.ListMergeRequests(parameters);

            if (mergesResult.IsFailure)
            {
                _presenter.ShowError("Failed to retrieve merge requests", mergesResult.Error);
                return;
            }

            var merges = mergesResult.Value;

            if (merges.Count == 0)
            {
                _presenter.ShowSuccess($"No merge requests found in project {parameters.Project}");
                return;
            }

            _presenter.ShowGrid(
                $"Found ({merges.Count}) merge requests in project {parameters.Project}",
                new GridColumn <int>("Merge request Id", 20, merges.Select(s => s.Id)),
                new GridColumn("Title", 100, merges.Select(s => s.Title)),
                new GridColumn("Assignee", 50, merges.Select(s => s.Assignee)));
        }
Beispiel #2
0
 public async Task <Result <IReadOnlyList <MergeRequest> > > ListMergeRequests(ListMergesParameters parameters)
 => _mapper.Map(await SafeGetResult(() => _mergesFacade.ListMergeRequests(parameters)));
Beispiel #3
0
        public async Task <Result <IReadOnlyList <MergeRequest> > > ListMergeRequests(ListMergesParameters parameters)
        {
            var client = await _clientFactory.Create();

            int?projectId = await GetProjectId(client, parameters.Project);

            if (!projectId.HasValue)
            {
                return(Result.Fail <IReadOnlyList <MergeRequest> >($"Project {parameters.Project} was not found"));
            }

            IEnumerable <MergeRequest> issues = parameters.State.HasValue ?
                                                await client.MergeRequests.GetAsync(projectId.Value, o => o.State = _mapper.Map(parameters.State.Value)) :
                                                await client.MergeRequests.GetAsync(projectId.Value);

            int?assigneeId = await GetUserId(client, parameters.AssignedToCurrentUser, parameters.Assignee);

            if (assigneeId.HasValue)
            {
                issues = issues.Where(i => i.Assignee?.Id == assigneeId);
            }

            return(Result.Ok <IReadOnlyList <MergeRequest> >(issues.ToList()));
        }