aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java24
2 files changed, 25 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
index 0c1af1a91d7..7995b30cd1b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
@@ -258,7 +258,7 @@ public class ComponentsPublisher implements ReportPublisherStep {
@CheckForNull
private static String getName(DefaultInputModule module) {
if (StringUtils.isNotEmpty(module.definition().getBranch())) {
- return module.definition().getOriginalName() + " " + module.definition().getBranch();
+ return module.definition().getName() + " " + module.definition().getBranch();
} else {
return module.definition().getOriginalName();
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
index 528aa5b968c..00c496be9ab 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
@@ -155,6 +155,30 @@ public class ComponentsPublisherTest {
}
@Test
+ public void should_set_modified_name_with_branch() throws IOException {
+ ProjectAnalysisInfo projectAnalysisInfo = mock(ProjectAnalysisInfo.class);
+ when(projectAnalysisInfo.analysisDate()).thenReturn(DateUtils.parseDate("2012-12-12"));
+
+ ProjectDefinition rootDef = ProjectDefinition.create()
+ .setKey("foo")
+ .setDescription("Root description")
+ .setBaseDir(temp.newFolder())
+ .setWorkDir(temp.newFolder())
+ .setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "my_branch");
+
+ DefaultInputModule root = new DefaultInputModule(rootDef, 1);
+
+ moduleHierarchy = mock(InputModuleHierarchy.class);
+ when(moduleHierarchy.root()).thenReturn(root);
+
+ ComponentsPublisher publisher = new ComponentsPublisher(moduleHierarchy, tree, branchConfiguration);
+ publisher.publish(writer);
+ Component rootProtobuf = reader.readComponent(1);
+ assertThat(rootProtobuf.getKey()).isEqualTo("foo");
+ assertThat(rootProtobuf.getName()).isEqualTo("foo my_branch");
+ }
+
+ @Test
public void should_skip_dir_without_published_files() throws IOException {
ProjectAnalysisInfo projectAnalysisInfo = mock(ProjectAnalysisInfo.class);
when(projectAnalysisInfo.analysisDate()).thenReturn(DateUtils.parseDate("2012-12-12"));