diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-08-11 10:58:37 +0200 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-12 10:59:55 +0200 |
commit | 0e99d43112e13db1bcd552896f82e4cce0329fc9 (patch) | |
tree | dc5ceb12e36748fa9c8b2ee495aafb2aa5772df0 /sonar-scanner-engine/src/main/java/org/sonar | |
parent | f87bdd9d007c372556a34e76dca2ab3da4b4b620 (diff) | |
download | sonarqube-0e99d43112e13db1bcd552896f82e4cce0329fc9.tar.gz sonarqube-0e99d43112e13db1bcd552896f82e4cce0329fc9.zip |
SONAR-9701 Skip unchanged components in short living branches
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java index d0a847f828f..b90ab462a6e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/analysis/DefaultAnalysisMode.java @@ -27,6 +27,8 @@ import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.scanner.bootstrap.AbstractAnalysisMode; import org.sonar.scanner.bootstrap.GlobalProperties; +import org.sonar.scanner.scan.BranchConfiguration; +import org.sonar.scanner.scan.BranchConfiguration.BranchType; @Immutable public class DefaultAnalysisMode extends AbstractAnalysisMode { @@ -36,33 +38,34 @@ public class DefaultAnalysisMode extends AbstractAnalysisMode { private boolean scanAllFiles; - public DefaultAnalysisMode(GlobalProperties globalProps, AnalysisProperties props) { - init(globalProps.properties(), props.properties()); + public DefaultAnalysisMode(GlobalProperties globalProps, AnalysisProperties props, BranchConfiguration branchConfig) { + init(globalProps.properties(), props.properties(), branchConfig); } public boolean scanAllFiles() { return scanAllFiles; } - private void init(Map<String, String> globalProps, Map<String, String> analysisProps) { + private void init(Map<String, String> globalProps, Map<String, String> analysisProps, BranchConfiguration branchConfig) { // make sure analysis is consistent with global properties boolean globalPreview = isIssues(globalProps); boolean analysisPreview = isIssues(analysisProps); + boolean shortLivingBranch = branchConfig.branchType() == BranchType.SHORT; if (!globalPreview && analysisPreview) { throw new IllegalStateException("Inconsistent properties: global properties doesn't enable issues mode while analysis properties enables it"); } - load(globalProps, analysisProps); + load(globalProps, analysisProps, shortLivingBranch); } - private void load(Map<String, String> globalProps, Map<String, String> analysisProps) { + private void load(Map<String, String> globalProps, Map<String, String> analysisProps, boolean isShortLivingBranch) { String mode = getPropertyWithFallback(analysisProps, globalProps, CoreProperties.ANALYSIS_MODE); validate(mode); issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode) || CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode); mediumTestMode = "true".equals(getPropertyWithFallback(analysisProps, globalProps, MEDIUM_TEST_ENABLED)); String scanAllStr = getPropertyWithFallback(analysisProps, globalProps, KEY_SCAN_ALL); - scanAllFiles = !issues || "true".equals(scanAllStr); + scanAllFiles = !isShortLivingBranch && (!issues || "true".equals(scanAllStr)); } public void printMode() { |