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); } } }
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); } } }
async public Task <MergeRequest> CreateMergeRequest(CreateNewMergeRequestParameters parameters) { using (MergeRequestOperator mergeRequestOperator = new MergeRequestOperator( _projectKey.HostName, _hostProperties, _networkOperationStatusListener)) { try { return(await mergeRequestOperator.CreateMergeRequest(_projectKey.ProjectName, parameters)); } catch (OperatorException ex) { if (ex.Cancelled) { throw new MergeRequestCreatorCancelledException(); } if (ex.InnerException is GitLabRequestException glx) { throw new MergeRequestCreatorException("Cannot create MR", glx); } throw new MergeRequestCreatorException("Cannot create MR by unknown reason", null); } } }
async public Task <MergeRequest> Merge(AcceptMergeRequestParameters parameters) { using (MergeRequestOperator mergeRequestOperator = new MergeRequestOperator( _mrk.ProjectKey.HostName, _hostProperties)) { try { return(await mergeRequestOperator.AcceptMergeRequest(_mrk, parameters)); } catch (OperatorException ex) { if (ex.Cancelled) { throw new MergeRequestEditorCancelledException(); } if (ex.InnerException is GitLabRequestException glx) { throw new MergeRequestEditorException("Cannot merge MR", glx); } throw new MergeRequestEditorException("Cannot merge MR by unknown reason", null); } } }
async public Task <MergeRequestRebaseResponse> Rebase(bool?skipCI) { using (MergeRequestOperator mergeRequestOperator = new MergeRequestOperator( _mrk.ProjectKey.HostName, _hostProperties)) { try { return(await mergeRequestOperator.RebaseMergeRequest(_mrk, skipCI)); } catch (OperatorException ex) { if (ex.Cancelled) { throw new MergeRequestEditorCancelledException(); } if (ex.InnerException is GitLabRequestException glx) { throw new MergeRequestEditorException("Cannot rebase MR", glx); } throw new MergeRequestEditorException("Cannot rebase MR by unknown reason", null); } } }