Skip to content

Commit

Permalink
Do not build draft MRs (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
basilevs authored Feb 9, 2024
1 parent b60d443 commit aa4df93
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -323,14 +324,18 @@ protected void retrieve(
try {
GitLabApi gitLabApi = apiBuilder(this.getOwner(), serverName);
getGitlabProject(gitLabApi);
GitLabSCMSourceContext ctx = new GitLabSCMSourceContext(criteria, observer);
try (GitLabSCMSourceRequest request = ctx.withTraits(getTraits()).newRequest(this, listener)) {
GitLabSCMSourceContext ctx = new GitLabSCMSourceContext(criteria, observer).withTraits(getTraits());
try (GitLabSCMSourceRequest request = ctx.newRequest(this, listener)) {
request.setGitLabApi(gitLabApi);
request.setProject(gitlabProject);
request.setMembers(getMembers());
if (request.isFetchBranches()) {
request.setBranches(gitLabApi.getRepositoryApi().getBranches(gitlabProject));
}
Predicate<MergeRequest> filter = ignore -> false;
if (ctx.alwaysIgnoreMRWorkInProgress()) {
filter = mr -> !mr.getWorkInProgress();
}
if (request.isFetchMRs() && gitlabProject.getMergeRequestsEnabled()) {
// If not authenticated GitLabApi cannot detect if it is a fork
// If `forkedFromProject` is null it doesn't mean anything
Expand All @@ -342,6 +347,7 @@ protected void retrieve(
.getMergeRequests(gitlabProject, Constants.MergeRequestState.OPENED);
mrs = mrs.stream()
.filter(mr -> mr.getSourceProjectId() != null)
.filter(filter)
.collect(Collectors.toList());
request.setMergeRequests(mrs);
} else if (ctx.buildMRForksNotMirror()) {
Expand All @@ -356,6 +362,7 @@ protected void retrieve(
.equals(gitlabProject
.getForkedFromProject()
.getId()))
.filter(filter)
.collect(Collectors.toList());
request.setMergeRequests(mrs);
} else {
Expand Down

0 comments on commit aa4df93

Please sign in to comment.