Skip to content

Commit 46185a5

Browse files
authored
Correction of #285. Check the project if MR enabled (#296)
1 parent 197888b commit 46185a5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabSCMSource.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,6 @@ protected void retrieve(
323323
try {
324324
GitLabApi gitLabApi = apiBuilder(this.getOwner(), serverName);
325325
getGitlabProject(gitLabApi);
326-
setProjectId(gitlabProject.getId());
327-
sshRemote = gitlabProject.getSshUrlToRepo();
328-
httpRemote = gitlabProject.getHttpUrlToRepo();
329326
GitLabSCMSourceContext ctx = new GitLabSCMSourceContext(criteria, observer);
330327
try (GitLabSCMSourceRequest request = ctx.withTraits(getTraits()).newRequest(this, listener)) {
331328
request.setGitLabApi(gitLabApi);
@@ -334,7 +331,7 @@ protected void retrieve(
334331
if (request.isFetchBranches()) {
335332
request.setBranches(gitLabApi.getRepositoryApi().getBranches(gitlabProject));
336333
}
337-
if (request.isFetchMRs()) {
334+
if (request.isFetchMRs() && gitlabProject.getMergeRequestsEnabled()) {
338335
// If not authenticated GitLabApi cannot detect if it is a fork
339336
// If `forkedFromProject` is null it doesn't mean anything
340337
if (gitlabProject.getForkedFromProject() == null) {
@@ -410,7 +407,7 @@ public SCMSourceCriteria.Probe create(
410407
}
411408
listener.getLogger().format("%n%d branches were processed%n", count);
412409
}
413-
if (request.isFetchMRs() && !request.isComplete()) {
410+
if (request.isFetchMRs() && !request.isComplete() && gitlabProject.getMergeRequestsEnabled()) {
414411
int count = 0;
415412
listener.getLogger().format("%nChecking merge requests..%n");
416413
HashMap<Long, String> forkMrSources = new HashMap<>();

0 commit comments

Comments
 (0)