diff options
author | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-04 15:54:52 +0200 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-12 11:34:58 +0200 |
commit | 43a521d0f1c5919ec6511cc369dd99d0830c86ab (patch) | |
tree | b2c842c7ccfbb1e3d2341ebb6ac3f34816dda3ae /sonar-scanner-engine/src | |
parent | c2954e35714c703c84b0e4c2af4e0249751516b6 (diff) | |
download | sonarqube-43a521d0f1c5919ec6511cc369dd99d0830c86ab.tar.gz sonarqube-43a521d0f1c5919ec6511cc369dd99d0830c86ab.zip |
SONAR-9626 update log messages (#2472)
Diffstat (limited to 'sonar-scanner-engine/src')
2 files changed, 32 insertions, 4 deletions
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 |