@@ -18,6 +18,7 @@ export enum AcceptMergeRequestResultKind {
1818 CanNotBeMerged ,
1919 RebaseFailed ,
2020 FailedPipeline ,
21+ InvalidPipeline ,
2122 Unauthorized ,
2223}
2324
@@ -47,6 +48,12 @@ interface FailedPipelineResponse {
4748 pipeline : MergeRequestPipeline ;
4849}
4950
51+ interface InvalidPipelineResponse {
52+ kind : AcceptMergeRequestResultKind . InvalidPipeline ;
53+ mergeRequestInfo : MergeRequestInfo ;
54+ pipeline : MergeRequestPipeline | null ;
55+ }
56+
5057interface UnauthorizedResponse {
5158 kind : AcceptMergeRequestResultKind . Unauthorized ;
5259 mergeRequestInfo : MergeRequestInfo ;
@@ -63,6 +70,7 @@ type AcceptMergeRequestResult = SuccessResponse
6370 | CanNotBeMergedResponse
6471 | RebaseFailedResponse
6572 | FailedPipelineResponse
73+ | InvalidPipelineResponse
6674 | UnauthorizedResponse ;
6775
6876interface AcceptMergeRequestOptions {
@@ -152,31 +160,19 @@ export const acceptMergeRequest = async (gitlabApi: GitlabApi, mergeRequest: Mer
152160 }
153161
154162 if ( mergeRequestInfo . pipeline === null ) {
155- if ( ! containsLabel ( mergeRequestInfo . labels , BotLabels . WaitingForPipeline ) ) {
156- tasks . push (
157- gitlabApi . updateMergeRequest ( mergeRequest . project_id , mergeRequest . iid , {
158- labels : [ ...filterBotLabels ( mergeRequestInfo . labels ) , BotLabels . WaitingForPipeline ] . join ( ',' ) ,
159- } ) ,
160- ) ;
161- }
162-
163- console . log ( `[MR] Pipeline doesn't exist, retrying` ) ;
164- await Promise . all ( tasks ) ;
165- continue ;
163+ return {
164+ kind : AcceptMergeRequestResultKind . InvalidPipeline ,
165+ mergeRequestInfo,
166+ pipeline : mergeRequestInfo . pipeline ,
167+ } ;
166168 }
167169
168170 if ( mergeRequestInfo . pipeline . sha !== mergeRequestInfo . sha ) {
169- if ( ! containsLabel ( mergeRequestInfo . labels , BotLabels . WaitingForPipeline ) ) {
170- tasks . push (
171- gitlabApi . updateMergeRequest ( mergeRequest . project_id , mergeRequest . iid , {
172- labels : [ ...filterBotLabels ( mergeRequestInfo . labels ) , BotLabels . WaitingForPipeline ] . join ( ',' ) ,
173- } ) ,
174- ) ;
175- }
176-
177- console . log ( `[MR] Unexpected pipeline sha, retrying` ) ;
178- await Promise . all ( tasks ) ;
179- continue ;
171+ return {
172+ kind : AcceptMergeRequestResultKind . InvalidPipeline ,
173+ mergeRequestInfo,
174+ pipeline : mergeRequestInfo . pipeline ,
175+ } ;
180176 }
181177
182178 if ( mergeRequestInfo . pipeline . status === PipelineStatus . Running || mergeRequestInfo . pipeline . status === PipelineStatus . Pending ) {
0 commit comments