Skip to content

Commit

Permalink
No null value for number of approved (#26)
Browse files Browse the repository at this point in the history
* No null value for number of approved

* Replace creation of the extra Optional by an equivalent logic without it, for readability reasons

---------

Co-authored-by: Fábio Pereira <[email protected]>
  • Loading branch information
tuxbr and fbpe authored Feb 23, 2024
1 parent 4ab5242 commit a216a79
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/service/GitLabService.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,10 @@ private boolean isMergeRequestApproved(String gitlabEventUUID, MergeRequest mr)
final Long project = mr.getProjectId();
final Long mrNumber = mr.getIid();
try {
return gitlab.getMergeRequestApi()
Integer approvalsLeft = gitlab.getMergeRequestApi()
.getApprovals(project, mrNumber)
.getApprovalsLeft() <= 0;
.getApprovalsLeft();
return approvalsLeft == null || approvalsLeft <= 0;
} catch (GitLabApiException e) {
assignMrToCascadeResponsible(gitlabEventUUID, mr);
throw new IllegalStateException(String.format("GitlabEvent: '%s' | Cannot retrieve approvals for merge request '!%d' in project '%d'", gitlabEventUUID, mrNumber, project), e);
Expand Down

0 comments on commit a216a79

Please sign in to comment.