diff --git a/server/src/GitlabApi.ts b/server/src/GitlabApi.ts index f8d28c6..9ee8284 100644 --- a/server/src/GitlabApi.ts +++ b/server/src/GitlabApi.ts @@ -117,7 +117,6 @@ export interface MergeRequestInfo extends MergeRequest { base_sha: string; head_sha: string; }; - pipeline: MergeRequestPipeline | null; head_pipeline: MergeRequestPipeline | null; diverged_commits_count: number; rebase_in_progress: boolean; diff --git a/server/src/MergeRequestAcceptor.ts b/server/src/MergeRequestAcceptor.ts index c450d72..d8209d3 100644 --- a/server/src/MergeRequestAcceptor.ts +++ b/server/src/MergeRequestAcceptor.ts @@ -315,18 +315,6 @@ export const acceptMergeRequest = async ( }; } - if ( - mergeRequestInfo.pipeline !== null && - startingOrInProgressPipelineStatuses.includes(mergeRequestInfo.pipeline.status) - ) { - return { - kind: AcceptMergeRequestResultKind.PipelineInProgress, - mergeRequestInfo, - user, - pipeline: mergeRequestInfo.pipeline, - }; - } - // the latest pipeline is incomplete / has failed if ( mergeRequestInfo.head_pipeline !== null && @@ -446,7 +434,7 @@ const resolveCurrentPipeline = async ( user: User, mergeRequestInfo: MergeRequestInfo, ): Promise => { - let currentPipeline: MergeRequestPipeline | null = mergeRequestInfo.pipeline; + let currentPipeline: MergeRequestPipeline | null = mergeRequestInfo.head_pipeline; if (currentPipeline === null || currentPipeline.sha !== mergeRequestInfo.sha) { const pipelines = await gitlabApi.getMergeRequestPipelines( @@ -460,7 +448,7 @@ const resolveCurrentPipeline = async ( if (currentPipelineCandidate === undefined) { const message = - mergeRequestInfo.pipeline === null + mergeRequestInfo.head_pipeline === null ? `[MR][${mergeRequestInfo.iid}] Merge request can't be merged. Pipeline does not exist` : `[MR][${mergeRequestInfo.iid}] Merge request can't be merged. The latest pipeline is not executed on the latest commit`; console.log(message); @@ -638,7 +626,7 @@ export const runAcceptingMergeRequest = async ( kind: AcceptMergeRequestResultKind.InvalidPipeline, mergeRequestInfo, user, - pipeline: mergeRequestInfo.pipeline, + pipeline: mergeRequestInfo.head_pipeline, }; } diff --git a/server/src/PipelineCanceller.ts b/server/src/PipelineCanceller.ts index 38cc35e..8659a11 100644 --- a/server/src/PipelineCanceller.ts +++ b/server/src/PipelineCanceller.ts @@ -5,24 +5,24 @@ export const tryCancelPipeline = async ( mergeRequestInfo: MergeRequestInfo, user: User, ): Promise => { - if (mergeRequestInfo.pipeline === null) { + if (mergeRequestInfo.head_pipeline === null) { return; } if ( - mergeRequestInfo.pipeline.status !== PipelineStatus.Running && - mergeRequestInfo.pipeline.status !== PipelineStatus.Pending + mergeRequestInfo.head_pipeline.status !== PipelineStatus.Running && + mergeRequestInfo.head_pipeline.status !== PipelineStatus.Pending ) { return; } const mergeRequestPipeline = await gitlabApi.getPipeline( mergeRequestInfo.project_id, - mergeRequestInfo.pipeline.id, + mergeRequestInfo.head_pipeline.id, ); if (mergeRequestPipeline.user.id !== user.id) { return; } - await gitlabApi.cancelPipeline(mergeRequestInfo.project_id, mergeRequestInfo.pipeline.id); + await gitlabApi.cancelPipeline(mergeRequestInfo.project_id, mergeRequestInfo.head_pipeline.id); };