From: Antoine Vigneau Date: Thu, 4 Apr 2024 12:47:16 +0000 (+0200) Subject: SONAR-21980 Fix Project Binding creation X-Git-Tag: 10.5.0.89998~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=58ff19aa739ab95e3fd605d8a42c84b77451a359;p=sonarqube.git SONAR-21980 Fix Project Binding creation --- diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/azuredevops/AzureDevOpsProjectCreator.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/azuredevops/AzureDevOpsProjectCreator.java index 5fff071f009..c123ef866a0 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/azuredevops/AzureDevOpsProjectCreator.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/azuredevops/AzureDevOpsProjectCreator.java @@ -117,7 +117,6 @@ public class AzureDevOpsProjectCreator implements DevOpsProjectCreator { .setAlmRepo(repository.getName()) .setAlmSlug(repository.getProject().getName()) .setProjectUuid(projectDto.getUuid()) - .setSummaryCommentEnabled(true) .setMonorepo(monorepo); dbClient.projectAlmSettingDao().insertOrUpdate(dbSession, projectAlmSettingDto, almSettingDto.getKey(), projectDto.getName(), projectDto.getKey()); } diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketcloud/BitbucketCloudProjectCreator.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketcloud/BitbucketCloudProjectCreator.java index 71facf82592..e05f2526306 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketcloud/BitbucketCloudProjectCreator.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketcloud/BitbucketCloudProjectCreator.java @@ -109,9 +109,7 @@ public class BitbucketCloudProjectCreator implements DevOpsProjectCreator { ProjectAlmSettingDto projectAlmSettingDto = new ProjectAlmSettingDto() .setAlmSettingUuid(almSettingDto.getUuid()) .setAlmRepo(repoSlug) - .setAlmSlug(null) .setProjectUuid(projectDto.getUuid()) - .setSummaryCommentEnabled(true) .setMonorepo(monorepo); dbClient.projectAlmSettingDao().insertOrUpdate(dbSession, projectAlmSettingDto, almSettingDto.getKey(), projectDto.getName(), projectDto.getKey()); } diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreator.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreator.java index ddfc6ee829d..93ce5f32528 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreator.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreator.java @@ -88,7 +88,7 @@ public class BitbucketServerProjectCreator implements DevOpsProjectCreator { defaultBranchName, creationMethod); ProjectDto projectDto = Optional.ofNullable(componentCreationData.projectDto()).orElseThrow(); - createProjectAlmSettingDto(dbSession, repository.getSlug(), projectDto, almSettingDto, monorepo); + createProjectAlmSettingDto(dbSession, repository, projectDto, almSettingDto, monorepo); return componentCreationData; } @@ -123,14 +123,13 @@ public class BitbucketServerProjectCreator implements DevOpsProjectCreator { return Optional.ofNullable(projectName).orElse(repository.getName()); } - private void createProjectAlmSettingDto(DbSession dbSession, String repoSlug, ProjectDto projectDto, AlmSettingDto almSettingDto, + private void createProjectAlmSettingDto(DbSession dbSession, Repository repository, ProjectDto projectDto, AlmSettingDto almSettingDto, Boolean isMonorepo) { ProjectAlmSettingDto projectAlmSettingDto = new ProjectAlmSettingDto() .setAlmSettingUuid(almSettingDto.getUuid()) - .setAlmRepo(repoSlug) - .setAlmSlug(null) + .setAlmRepo(repository.getProject().getKey()) + .setAlmSlug(repository.getSlug()) .setProjectUuid(projectDto.getUuid()) - .setSummaryCommentEnabled(true) .setMonorepo(isMonorepo); dbClient.projectAlmSettingDao().insertOrUpdate(dbSession, projectAlmSettingDto, almSettingDto.getKey(), projectDto.getName(), projectDto.getKey()); diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/gitlab/GitlabProjectCreator.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/gitlab/GitlabProjectCreator.java index de267a71606..a5f2f695d51 100644 --- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/gitlab/GitlabProjectCreator.java +++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/gitlab/GitlabProjectCreator.java @@ -135,9 +135,7 @@ public class GitlabProjectCreator implements DevOpsProjectCreator { ProjectAlmSettingDto projectAlmSettingDto = new ProjectAlmSettingDto() .setAlmSettingUuid(almSettingDto.getUuid()) .setAlmRepo(gitlabProjectId) - .setAlmSlug(null) .setProjectUuid(projectDto.getUuid()) - .setSummaryCommentEnabled(true) .setMonorepo(monorepo); dbClient.projectAlmSettingDao().insertOrUpdate(dbSession, projectAlmSettingDto, almSettingDto.getKey(), projectDto.getName(), projectDto.getKey()); } diff --git a/server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreatorTest.java b/server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreatorTest.java index b5888283c02..2cbac205c4e 100644 --- a/server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreatorTest.java +++ b/server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreatorTest.java @@ -144,7 +144,8 @@ class BitbucketServerProjectCreatorTest { ProjectAlmSettingDto createdProjectAlmSettingDto = projectAlmSettingCaptor.getValue(); assertThat(createdProjectAlmSettingDto.getAlmSettingUuid()).isEqualTo(ALM_SETTING_UUID); - assertThat(createdProjectAlmSettingDto.getAlmRepo()).isEqualTo(DOP_REPOSITORY_ID); + assertThat(createdProjectAlmSettingDto.getAlmRepo()).isEqualTo(DOP_PROJECT_ID); + assertThat(createdProjectAlmSettingDto.getAlmSlug()).isEqualTo(DOP_REPOSITORY_ID); assertThat(createdProjectAlmSettingDto.getProjectUuid()).isEqualTo(PROJECT_UUID); assertThat(createdProjectAlmSettingDto.getMonorepo()).isTrue(); } @@ -167,7 +168,8 @@ class BitbucketServerProjectCreatorTest { ProjectAlmSettingDto createdProjectAlmSettingDto = projectAlmSettingCaptor.getValue(); assertThat(createdProjectAlmSettingDto.getAlmSettingUuid()).isEqualTo(ALM_SETTING_UUID); - assertThat(createdProjectAlmSettingDto.getAlmRepo()).isEqualTo(DOP_REPOSITORY_ID); + assertThat(createdProjectAlmSettingDto.getAlmRepo()).isEqualTo(DOP_PROJECT_ID); + assertThat(createdProjectAlmSettingDto.getAlmSlug()).isEqualTo(DOP_REPOSITORY_ID); assertThat(createdProjectAlmSettingDto.getProjectUuid()).isEqualTo(PROJECT_UUID); assertThat(createdProjectAlmSettingDto.getMonorepo()).isTrue(); }