@@ -16,6 +16,7 @@ export enum AcceptMergeRequestResultKind {
1616 ClosedMergeRequest ,
1717 ReassignedMergeRequest ,
1818 CanNotBeMerged ,
19+ RebaseFailed ,
1920 FailedPipeline ,
2021 Unauthorized ,
2122}
@@ -51,10 +52,16 @@ interface UnauthorizedResponse {
5152 mergeRequestInfo : MergeRequestInfo ;
5253}
5354
55+ interface RebaseFailedResponse {
56+ kind : AcceptMergeRequestResultKind . RebaseFailed ;
57+ mergeRequestInfo : MergeRequestInfo ;
58+ }
59+
5460type AcceptMergeRequestResult = SuccessResponse
5561 | ClosedMergeRequestResponse
5662 | ReassignedMergeRequestResponse
5763 | CanNotBeMergedResponse
64+ | RebaseFailedResponse
5865 | FailedPipelineResponse
5966 | UnauthorizedResponse ;
6067
@@ -109,9 +116,9 @@ export const acceptMergeRequest = async (gitlabApi: GitlabApi, mergeRequest: Mer
109116 throw new Error ( `Unexpected MR status: ${ mergeRequestInfo . state } ` ) ;
110117 }
111118
112- if ( mergeRequestInfo . merge_status !== MergeStatus . CanBeMerged || mergeRequestInfo . work_in_progress ) {
119+ if ( mergeRequestInfo . merge_error !== null ) {
113120 return {
114- kind : AcceptMergeRequestResultKind . CanNotBeMerged ,
121+ kind : AcceptMergeRequestResultKind . RebaseFailed ,
115122 mergeRequestInfo,
116123 } ;
117124 }
@@ -122,6 +129,13 @@ export const acceptMergeRequest = async (gitlabApi: GitlabApi, mergeRequest: Mer
122129 continue ;
123130 }
124131
132+ if ( mergeRequestInfo . merge_status !== MergeStatus . CanBeMerged || mergeRequestInfo . work_in_progress ) {
133+ return {
134+ kind : AcceptMergeRequestResultKind . CanNotBeMerged ,
135+ mergeRequestInfo,
136+ } ;
137+ }
138+
125139 if ( mergeRequestInfo . diverged_commits_count > 0 ) {
126140 await gitlabApi . updateMergeRequest ( mergeRequest . project_id , mergeRequest . iid , {
127141 labels : [ ...filterBotLabels ( mergeRequestInfo . labels ) , BotLabels . Rebasing ] . join ( ',' ) ,
0 commit comments