internal Task <MergeRequest> CreateMergeRequest(string projectName, CreateNewMergeRequestParameters parameters) { return(callWithSharedClient( async(client) => await OperatorCallWrapper.Call( async() => (MergeRequest)(await client.RunAsync( async(gl) => await gl.Projects.Get(projectName).MergeRequests.CreateNewTaskAsync(parameters)))))); }
async internal static Task <MergeRequestKey?> SubmitNewMergeRequestAsync( SubmitNewMergeRequestParameters parameters, string firstNote, User currentUser, Shortcuts shortcuts) { if (String.IsNullOrEmpty(parameters.ProjectKey.ProjectName) || String.IsNullOrEmpty(parameters.SourceBranch) || String.IsNullOrEmpty(parameters.TargetBranch) || String.IsNullOrEmpty(parameters.Title) || parameters.AssigneeUserName == null || firstNote == null || currentUser == null) { // this is unexpected due to UI restrictions, so don't implement detailed logging here MessageBox.Show("Invalid parameters for a new merge request", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Trace.TraceError("[MergeRequestEditHelper] Invalid parameters for a new merge request"); return(null); } User assignee = await getUserAsync(parameters.AssigneeUserName, shortcuts); checkFoundAssignee(parameters.ProjectKey.HostName, parameters.AssigneeUserName, assignee); string[] labels = parameters.IsHighPriority ? new string[] { Common.Constants.Constants.HighPriorityLabel } : null; int assigneeId = assignee?.Id ?? 0; // 0 means to not assign MR to anyone CreateNewMergeRequestParameters creatorParameters = new CreateNewMergeRequestParameters( parameters.SourceBranch, parameters.TargetBranch, parameters.Title, assigneeId, parameters.Description, parameters.DeleteSourceBranch, parameters.Squash, labels); MergeRequest mergeRequest; try { mergeRequest = await shortcuts .GetMergeRequestCreator(parameters.ProjectKey) .CreateMergeRequest(creatorParameters); } catch (MergeRequestCreatorException ex) { reportErrorToUser(ex); return(null); } MergeRequestKey mrk = new MergeRequestKey(parameters.ProjectKey, mergeRequest.IId); await addComment(mrk, currentUser, firstNote, shortcuts); return(mrk); }
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); } } }