aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-11-06 10:17:10 -0600
committerSonarTech <sonartech@sonarsource.com>2019-12-09 20:46:15 +0100
commit0a6525b3f63132a719e96a16233aef04fcf535cd (patch)
tree88eb3964daeb7fc97a4248b50c8fef999a2a38af /sonar-scanner-engine
parent1b7c2ba7e13e675657f58d422d04d548d210da08 (diff)
downloadsonarqube-0a6525b3f63132a719e96a16233aef04fcf535cd.tar.gz
sonarqube-0a6525b3f63132a719e96a16233aef04fcf535cd.zip
SONAR-12668 Drop 'sonar.branch.target'
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfiguration.java21
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/DefaultBranchConfiguration.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java13
7 files changed, 12 insertions, 33 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
index d8f3e6c6606..ca4c9a32cf7 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
@@ -156,7 +156,7 @@ public class MetadataPublisher implements ReportPublisherStep {
builder.setBranchName(branchConfiguration.branchName());
BranchType branchType = toProtobufBranchType(branchConfiguration.branchType());
builder.setBranchType(branchType);
- String referenceBranch = branchConfiguration.longLivingSonarReferenceBranch();
+ String referenceBranch = branchConfiguration.referenceBranchName();
if (referenceBranch != null) {
builder.setMergeBranchName(referenceBranch);
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java
index 790930a6493..1d2414b0b1f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesSupplier.java
@@ -44,7 +44,7 @@ public class ProjectRepositoriesSupplier implements Supplier<ProjectRepositories
public ProjectRepositories get() {
if (project == null) {
Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
- project = loader.load(scannerProperties.getProjectKey(), branchConfig.longLivingSonarReferenceBranch());
+ project = loader.load(scannerProperties.getProjectKey(), branchConfig.referenceBranchName());
profiler.stopInfo();
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
index 9310ba93a6d..8c2153e7bac 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
@@ -36,7 +36,6 @@ import static java.util.Objects.nonNull;
import static org.apache.commons.lang.StringUtils.isNotEmpty;
import static org.sonar.core.config.ScannerProperties.BRANCHES_DOC_LINK;
import static org.sonar.core.config.ScannerProperties.BRANCH_NAME;
-import static org.sonar.core.config.ScannerProperties.BRANCH_TARGET;
import static org.sonar.core.config.ScannerProperties.PULL_REQUEST_BASE;
import static org.sonar.core.config.ScannerProperties.PULL_REQUEST_BRANCH;
import static org.sonar.core.config.ScannerProperties.PULL_REQUEST_KEY;
@@ -83,7 +82,7 @@ public class ProjectReactorValidator {
}
private void validateBranchParamsWhenPluginAbsent(List<String> validationMessages) {
- for (String param : Arrays.asList(BRANCH_NAME, BRANCH_TARGET)) {
+ for (String param : Arrays.asList(BRANCH_NAME)) {
if (isNotEmpty(settings.get(param).orElse(null))) {
validationMessages.add(format("To use the property \"%s\" and analyze branches, Developer Edition or above is required. "
+ "See %s for more information.", param, BRANCHES_DOC_LINK));
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfiguration.java
index 26ab17a7b65..eaa4003f7d3 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfiguration.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfiguration.java
@@ -26,11 +26,6 @@ import javax.annotation.concurrent.Immutable;
public interface BranchConfiguration {
/**
- * The type of the branch we're on, determined by:
- * - If the specified branch exists on the server, then its type
- * - If the branch name matches the pattern of long-lived branches, then it's long-lived
- * - Otherwise it's short-lived
- *
* @return type of the current branch
*/
BranchType branchType();
@@ -40,7 +35,7 @@ public interface BranchConfiguration {
}
/**
- * For long/short living branches, this is the value of sonar.branch.name, and fallback on the default branch name configured in SQ
+ * For branches, this is the value of sonar.branch.name, and fallback on the default branch name configured in SQ
* For PR: the name of the branch containing PR changes (sonar.pullrequest.branch)
*
* @return null if the branch feature is not available or no branch was specified.
@@ -49,24 +44,22 @@ public interface BranchConfiguration {
String branchName();
/**
- * The long living server branch from which we should load project settings/quality profiles/compare changed files/...
- * For long living branches, this is the sonar.branch.target (default to default branch) in case of first analysis,
- * otherwise it's the branch itself.
- * For short living branches, we look at sonar.branch.target (default to default branch). If it exists but is a short living branch or PR, we will
- * transitively use its own target.
+ * The branch from which we should load project settings/quality profiles/compare changed files/...
+ * For branches, it's the to default branch in case of first analysis, otherwise it's the branch itself.
* For PR, we look at sonar.pullrequest.base (default to default branch). If it exists but is a short living branch or PR, we will
* transitively use its own target. If base is not analyzed, we will use default branch.
*
* @return null if the branch feature is not available or no branch was specified.
*/
@CheckForNull
- String longLivingSonarReferenceBranch();
+ String referenceBranchName();
/**
- * Raw value of sonar.branch.target or sonar.pullrequest.base (fallback to the default branch).
+ * For P/Rs, it's the raw value of 'sonar.pullrequest.base'.
+ * For branches it's always null.
* In the scanner side, it will be used by the SCM to compute changed files and changed lines.
*
- * @return null if the branch feature is not available, the branch being analyzed is the main branch or no branch was specified.
+ * @return null if the branch feature is not available or if it's not a P/R.
*/
@CheckForNull
String targetBranchName();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/DefaultBranchConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/DefaultBranchConfiguration.java
index a708727ea4b..b117b4a9546 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/DefaultBranchConfiguration.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/DefaultBranchConfiguration.java
@@ -43,7 +43,7 @@ public class DefaultBranchConfiguration implements BranchConfiguration {
@CheckForNull
@Override
- public String longLivingSonarReferenceBranch() {
+ public String referenceBranchName() {
return null;
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
index 8025b03034b..c769045d1f2 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
@@ -404,7 +404,7 @@ public class ScannerMediumTester extends ExternalResource {
@CheckForNull
@Override
- public String longLivingSonarReferenceBranch() {
+ public String referenceBranchName() {
return longLivingSonarReferenceBranch;
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
index ef3ebfe1611..fc50a63a9dd 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
@@ -108,19 +108,6 @@ public class ProjectReactorValidatorTest {
}
@Test
- public void fail_when_branch_target_is_specified_but_branch_plugin_not_present() {
- ProjectDefinition def = ProjectDefinition.create().setProperty(CoreProperties.PROJECT_KEY_PROPERTY, "foo");
- ProjectReactor reactor = new ProjectReactor(def);
-
- when(settings.get(eq(ScannerProperties.BRANCH_TARGET))).thenReturn(Optional.of("feature1"));
-
- thrown.expect(MessageException.class);
- thrown.expectMessage("To use the property \"sonar.branch.target\" and analyze branches, Developer Edition or above is required");
-
- underTest.validate(reactor);
- }
-
- @Test
public void fail_when_pull_request_id_specified_but_branch_plugin_not_present() {
ProjectDefinition def = ProjectDefinition.create().setProperty(CoreProperties.PROJECT_KEY_PROPERTY, "foo");
ProjectReactor reactor = new ProjectReactor(def);