]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9626 update log messages (#2472)
authorJanos Gyerik <janos.gyerik@sonarsource.com>
Mon, 4 Sep 2017 13:54:52 +0000 (15:54 +0200)
committerJanos Gyerik <janos.gyerik@sonarsource.com>
Tue, 12 Sep 2017 09:34:58 +0000 (11:34 +0200)
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java

index 244dc9c445a37f1a30b40baae11fab143b4eea7c..060b7d2102694c296a34cc8b023a649e35dea0ff 100644 (file)
@@ -234,13 +234,14 @@ public class ProjectScanContainer extends ComponentContainer {
     }
     String branch = tree.root().definition().getBranch();
     if (branch != null) {
-      LOG.info("Branch key (deprecated): {}", branch);
+      LOG.info("Branch key: {}", branch);
+      LOG.warn("The use of \"sonar.branch\" is deprecated and replaced by \"sonar.branch.name\". See https://redirect.sonarsource.com/doc/branches.html.");
     }
 
     String branchName = props.property(ScannerProperties.BRANCH_NAME);
     if (branchName != null) {
       BranchConfiguration branchConfig = getComponentByType(BranchConfiguration.class);
-      LOG.info("Branch name: {}, type: {}", branchName, branchConfig.branchType().toString().toLowerCase());
+      LOG.info("Branch name: {}, type: {}", branchName, toDisplayName(branchConfig.branchType()));
     }
 
     LOG.debug("Start recursive analysis of project modules");
@@ -251,6 +252,15 @@ public class ProjectScanContainer extends ComponentContainer {
     }
   }
 
+  private static String toDisplayName(BranchConfiguration.BranchType branchType) {
+    if (branchType == BranchConfiguration.BranchType.LONG) {
+      return "long living";
+    } else if (branchType == BranchConfiguration.BranchType.SHORT) {
+      return "short living";
+    }
+    throw new UnsupportedOperationException("unknown branch type: " + branchType);
+  }
+
   private void scanRecursively(InputModuleHierarchy tree, DefaultInputModule module) {
     for (DefaultInputModule child : tree.children(module)) {
       scanRecursively(tree, child);
index 0ace33edc7afe72fc652f8ed852f0b94a57a2e53..0de22581f630f99cdfe5eb2907008502b8a81131 100644 (file)
@@ -151,7 +151,7 @@ public class FileSystemMediumTest {
     builder = createBuilder();
     builder.put("sonar.branch", "my-branch");
     File srcDir = new File(baseDir, "src");
-    srcDir.mkdir();
+    assertThat(srcDir.mkdir()).isTrue();
 
     File xooFile = new File(srcDir, "sample.xoo");
     FileUtils.write(xooFile, "Sample xoo\ncontent");
@@ -163,7 +163,25 @@ public class FileSystemMediumTest {
       .execute();
 
     assertThat(logs.getAllAsString()).contains("Project key: com.foo.project");
-    assertThat(logs.getAllAsString()).contains("Branch key (deprecated): my-branch");
+    assertThat(logs.getAllAsString()).contains("Branch key: my-branch");
+    assertThat(logs.getAllAsString()).contains("The use of \"sonar.branch\" is deprecated and replaced by \"sonar.branch.name\".");
+  }
+
+  @Test
+  public void logBranchNameAndType() throws IOException {
+    builder = createBuilder();
+    builder.put("sonar.branch.name", "my-branch");
+    File srcDir = new File(baseDir, "src");
+    assertThat(srcDir.mkdir()).isTrue();
+
+    tester.newTask()
+      .properties(builder
+        .put("sonar.sources", "src")
+        .build())
+      .execute();
+
+    assertThat(logs.getAllAsString()).contains("Project key: com.foo.project");
+    assertThat(logs.getAllAsString()).contains("Branch name: my-branch, type: long living");
   }
 
   @Test