Skip to content

Commit 5e9101c

Browse files
authored
Merge pull request #237 from mschoettle/fix-mr-approvals
Use correct endpoint for determining MR approvals
2 parents a562e12 + 83e02b0 commit 5e9101c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/gitlabHelper.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,24 @@ export class GitlabHelper {
151151
return this.allBranches as any[];
152152
}
153153

154-
async getMergeRequestApprovals(pullRequestIid: number): Promise<string[]> {
154+
async getMergeRequestApprovals(mergeRequestIid: number): Promise<string[]> {
155155
try {
156-
let approvals = await this.gitlabApi.MergeRequestApprovals.showConfiguration(
156+
let approvals = await this.gitlabApi.MergeRequestApprovals.configuration(
157157
this.gitlabProjectId,
158158
{
159-
mergerequestIId: pullRequestIid,
159+
mergerequestIid: mergeRequestIid,
160160
},
161161
);
162-
163-
if (approvals.rules[0]) {
164-
return approvals.rules[0].approved_by.map(user => user.username);
162+
if (approvals.approved_by) {
163+
return approvals.approved_by.map(user => user.user.username);
165164
}
166165

167-
console.log(`No approvals found for GitLab merge request !${pullRequestIid}.`)
166+
console.log(`No approvals found for GitLab merge request !${mergeRequestIid}.`)
168167
} catch (err) {
169168
console.error(
170-
`Could not fetch approvals for GitLab merge request !${pullRequestIid}: ${err}`
169+
`Could not fetch approvals for GitLab merge request !${mergeRequestIid}: ${err}`
171170
);
171+
throw err;
172172
}
173173
return [];
174174
}

0 commit comments

Comments
 (0)