}
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");
}
}
+ 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);
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");
.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