From: Janos Gyerik Date: Mon, 4 Sep 2017 13:54:52 +0000 (+0200) Subject: SONAR-9626 update log messages (#2472) X-Git-Tag: 6.6-RC1~380^2~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=43a521d0f1c5919ec6511cc369dd99d0830c86ab;p=sonarqube.git SONAR-9626 update log messages (#2472) --- diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java index 244dc9c445a..060b7d21026 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java @@ -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); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java index 0ace33edc7a..0de22581f63 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java @@ -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