]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21980 Fix Project Binding creation
authorAntoine Vigneau <antoine.vigneau@sonarsource.com>
Thu, 4 Apr 2024 12:47:16 +0000 (14:47 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 4 Apr 2024 20:03:04 +0000 (20:03 +0000)
server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/azuredevops/AzureDevOpsProjectCreator.java
server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketcloud/BitbucketCloudProjectCreator.java
server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreator.java
server/sonar-webserver-common/src/main/java/org/sonar/server/common/almsettings/gitlab/GitlabProjectCreator.java
server/sonar-webserver-common/src/test/java/org/sonar/server/common/almsettings/bitbucketserver/BitbucketServerProjectCreatorTest.java

index 5fff071f009ac8639d1c8884c17de83cb42d3f38..c123ef866a090be3b523ac2208bb6af766ebe79c 100644 (file)
@@ -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());
   }
index 71facf8259279fb3efcb2b0e16e79ddcfaad4bf0..e05f25263065d45008867c5c089143d000d0a54a 100644 (file)
@@ -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());
   }
index ddfc6ee829dd1eba5538070f981be89680d6368c..93ce5f325280bcf85fc7377b439004a869d3856f 100644 (file)
@@ -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());
index de267a716065952609b0512420ed05884ac0b699..a5f2f695d517e914fe396ab6192ea673be380ef4 100644 (file)
@@ -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());
   }
index b5888283c02f499617cbbd1d5ff7190d623fd970..2cbac205c4e05a162916d271b99d1f34b7f3cb2b 100644 (file)
@@ -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();
   }