예제 #1
0
        async public Task <MergeRequest> SearchMergeRequestAsync(int mergeRequestIId, bool onlyOpen)
        {
            using (MergeRequestOperator mergeRequestOperator = new MergeRequestOperator(
                       _projectKey.HostName, _settings, _networkOperationStatusListener))
            {
                try
                {
                    SearchQuery query = new SearchQuery
                    {
                        IId         = mergeRequestIId,
                        ProjectName = _projectKey.ProjectName,
                        State       = onlyOpen ? "opened" : null,
                        MaxResults  = 1
                    };
                    IEnumerable <MergeRequest> mergeRequests = await mergeRequestOperator.SearchMergeRequestsAsync(query);

                    return(mergeRequests.Any() ? mergeRequests.First() : null);
                }
                catch (OperatorException ex)
                {
                    if (ex.Cancelled)
                    {
                        throw new MergeRequestAccessorCancelledException();
                    }
                    throw new MergeRequestAccessorException("Merge request search failed", ex);
                }
            }
        }
예제 #2
0
        async public Task <MergeRequest> SearchMergeRequestAsync(int mergeRequestIId, bool onlyOpen)
        {
            using (MergeRequestOperator mergeRequestOperator = new MergeRequestOperator(
                       _projectKey.HostName, _settings))
            {
                try
                {
                    SearchCriteria searchCriteria = new SearchCriteria(
                        new object[] { new SearchByIId(_projectKey.ProjectName, mergeRequestIId) });
                    IEnumerable <MergeRequest> mergeRequests =
                        await mergeRequestOperator.SearchMergeRequestsAsync(searchCriteria, null, onlyOpen);

                    return(mergeRequests.Any() ? mergeRequests.First() : null);
                }
                catch (OperatorException)
                {
                    return(null);
                }
            }
        }