MCPcopy
hub / github.com/iterative/cml / prAutoMerge

Method prAutoMerge

src/drivers/gitlab.js:322–353  ·  view source on GitHub ↗

* @param {{ pullRequestId: string }} param0 * @returns {Promise }

({ pullRequestId, mergeMode, mergeMessage })

Source from the content-addressed store, hash-verified

320 * @returns {Promise<void>}
321 */
322 async prAutoMerge({ pullRequestId, mergeMode, mergeMessage }) {
323 if (mergeMode === 'rebase')
324 throw new Error(`Rebase auto-merge mode not implemented for GitLab`);
325
326 const projectPath = await this.projectPath();
327
328 const endpoint = `/projects/${projectPath}/merge_requests/${pullRequestId}/merge`;
329 const body = new URLSearchParams();
330 body.set('merge_when_pipeline_succeeds', true);
331 body.set('squash', mergeMode === 'squash');
332 if (mergeMessage) body.set(`${mergeMode}_commit_message`, mergeMessage);
333
334 try {
335 await backOff(() =>
336 this.request({
337 endpoint,
338 method: 'PUT',
339 body
340 })
341 );
342 } catch ({ message }) {
343 logger.warn(
344 `Failed to enable auto-merge: ${message}. Trying to merge immediately...`
345 );
346 body.set('merge_when_pipeline_succeeds', false);
347 this.request({
348 endpoint,
349 method: 'PUT',
350 body
351 });
352 }
353 }
354
355 async issueCommentUpsert(opts = {}) {
356 const projectPath = await this.projectPath();

Callers 1

prCreateMethod · 0.95

Calls 3

projectPathMethod · 0.95
requestMethod · 0.95
warnMethod · 0.45

Tested by

no test coverage detected