diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..41a316f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog +All notable changes to this project will be documented in this file. + +## [2.0.0] - 2018-04-17 +### Added +- Support for SonarQube 7.1 + +## [1.0.1] - 2018-04-17 +### Changed +- Improved initial scan detection. It will accept `sonar.branch.name=master` during the initial scan + +## [1.0.0] - 2018-04-16 +### Added +- Initial implementation for SonarQube 6.7+ and 7.0 diff --git a/README.md b/README.md index 7710b5c..f110807 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,7 @@ Drop plugin jar file in SonarQube `/extensions/plugins` directory and restart th ## Compatibility -The plugin is compatible with SonarQube `6.7+ (LTS)` and `7.0`. +| Plugin Version | Compatible SonarQube | +| ------------- | -------------------- | +| 1.x.x | 6.7+, 7.0 | +| 2.0.0 | 7.1 | diff --git a/pom.xml b/pom.xml index 5ec4517..ae9fd3f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.sonarsource branch - 1.0.1 + 2.0.0 Branch Plugin for SonarQube Community Edition sonar-plugin @@ -16,7 +16,7 @@ 1.8 1.8 - 6.7 + 7.1 Branch Plugin Community Edition org.sonarsource.branch.BranchPlugin diff --git a/src/main/java/org/sonarsource/branch/computeengine/BranchImpl.java b/src/main/java/org/sonarsource/branch/computeengine/BranchImpl.java index 173c31b..45ac9d1 100644 --- a/src/main/java/org/sonarsource/branch/computeengine/BranchImpl.java +++ b/src/main/java/org/sonarsource/branch/computeengine/BranchImpl.java @@ -62,4 +62,10 @@ public String generateKey(Component module, @Nullable Component component) { : ComponentKeys.createEffectiveKey(module.getKey(), StringUtils.trimToNull(component.getPath())); return main ? mainBranchKey : mainBranchKey + ComponentDto.BRANCH_KEY_SEPARATOR + branchName; } + + // Not supported by the plugin + @Override + public String getPullRequestId() { + return null; + } } diff --git a/src/main/java/org/sonarsource/branch/computeengine/BranchLoaderDelegateImpl.java b/src/main/java/org/sonarsource/branch/computeengine/BranchLoaderDelegateImpl.java index 92891a7..8a2924f 100644 --- a/src/main/java/org/sonarsource/branch/computeengine/BranchLoaderDelegateImpl.java +++ b/src/main/java/org/sonarsource/branch/computeengine/BranchLoaderDelegateImpl.java @@ -74,7 +74,7 @@ private Optional loadMainBranchByProjectUuid(String projectUuid) { private Optional loadBranchByKey(String projectUuid, String key) { try (DbSession dbSession = dbClient.openSession(false)) { - return dbClient.branchDao().selectByKey(dbSession, projectUuid, key); + return dbClient.branchDao().selectByBranchKey(dbSession, projectUuid, key); } } } diff --git a/src/main/java/org/sonarsource/branch/scanner/BranchConfigurationImpl.java b/src/main/java/org/sonarsource/branch/scanner/BranchConfigurationImpl.java index cd0f161..99d6f21 100644 --- a/src/main/java/org/sonarsource/branch/scanner/BranchConfigurationImpl.java +++ b/src/main/java/org/sonarsource/branch/scanner/BranchConfigurationImpl.java @@ -38,4 +38,10 @@ public String branchTarget() { public String branchBase() { return branchBase; } + + // Not supported by the plugin + @Override + public String pullRequestKey() { + return null; + } } diff --git a/src/main/java/org/sonarsource/branch/scanner/BranchConfigurationLoaderImpl.java b/src/main/java/org/sonarsource/branch/scanner/BranchConfigurationLoaderImpl.java index 2ee9755..bcf69d0 100644 --- a/src/main/java/org/sonarsource/branch/scanner/BranchConfigurationLoaderImpl.java +++ b/src/main/java/org/sonarsource/branch/scanner/BranchConfigurationLoaderImpl.java @@ -14,6 +14,7 @@ import org.sonar.scanner.scan.branch.BranchType; import org.sonar.scanner.scan.branch.DefaultBranchConfiguration; import org.sonar.scanner.scan.branch.ProjectBranches; +import org.sonar.scanner.scan.branch.ProjectPullRequests; import org.sonarsource.branch.PropertyDefinitions; /** @@ -23,7 +24,7 @@ public class BranchConfigurationLoaderImpl implements BranchConfigurationLoader private static final Logger LOGGER = Loggers.get(BranchConfigurationLoaderImpl.class); @Override - public BranchConfiguration load(Map localSettings, Supplier> remoteSettingsSupplier, ProjectBranches branches) { + public BranchConfiguration load(Map localSettings, Supplier> remoteSettingsSupplier, ProjectBranches branches, ProjectPullRequests pullRequests) { String branchName = StringUtils.trimToNull(localSettings.get("sonar.branch.name")); if (branchName == null) { return new DefaultBranchConfiguration(); diff --git a/src/test/java/org/sonarsource/branch/computeengine/BranchLoaderDelegateImplTest.java b/src/test/java/org/sonarsource/branch/computeengine/BranchLoaderDelegateImplTest.java index 490ae6d..54f6582 100644 --- a/src/test/java/org/sonarsource/branch/computeengine/BranchLoaderDelegateImplTest.java +++ b/src/test/java/org/sonarsource/branch/computeengine/BranchLoaderDelegateImplTest.java @@ -12,7 +12,7 @@ import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.task.projectanalysis.analysis.Branch; import org.sonar.server.computation.task.projectanalysis.analysis.MutableAnalysisMetadataHolder; -import org.sonar.server.computation.task.projectanalysis.analysis.Project; +import org.sonar.server.project.Project; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -114,8 +114,8 @@ public void testLoad_with_target() { mergeBranchDto.setKey("master"); mergeBranchDto.setUuid(PROJECT_UUID); mergeBranchDto.setProjectUuid(PROJECT_UUID); - when(branchDao.selectByKey(dbSession, PROJECT_UUID, "test")).thenReturn(Optional.of(branchDto)); - when(branchDao.selectByKey(dbSession, PROJECT_UUID, "master")).thenReturn(Optional.of(mergeBranchDto)); + when(branchDao.selectByBranchKey(dbSession, PROJECT_UUID, "test")).thenReturn(Optional.of(branchDto)); + when(branchDao.selectByBranchKey(dbSession, PROJECT_UUID, "master")).thenReturn(Optional.of(mergeBranchDto)); branchLoaderDelegate.load(metadata); diff --git a/src/test/java/org/sonarsource/branch/scanner/BranchConfigurationLoaderImplTest.java b/src/test/java/org/sonarsource/branch/scanner/BranchConfigurationLoaderImplTest.java index f78fdd1..e3b6a1a 100644 --- a/src/test/java/org/sonarsource/branch/scanner/BranchConfigurationLoaderImplTest.java +++ b/src/test/java/org/sonarsource/branch/scanner/BranchConfigurationLoaderImplTest.java @@ -10,6 +10,7 @@ import org.sonar.scanner.scan.branch.BranchType; import org.sonar.scanner.scan.branch.DefaultBranchConfiguration; import org.sonar.scanner.scan.branch.ProjectBranches; +import org.sonar.scanner.scan.branch.ProjectPullRequests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -24,7 +25,8 @@ public void load_default() { BranchConfiguration configuration = branchConfigurationLoader.load( ImmutableMap.of("",""), () -> ImmutableMap.of("",""), - new ProjectBranches(Collections.emptyList()) + new ProjectBranches(Collections.emptyList()), + new ProjectPullRequests(Collections.emptyList()) ); assertNotNull(configuration); @@ -36,7 +38,8 @@ public void load_default_master() { BranchConfiguration configuration = branchConfigurationLoader.load( ImmutableMap.of("sonar.branch.name", "master"), () -> ImmutableMap.of("",""), - new ProjectBranches(Collections.emptyList()) + new ProjectBranches(Collections.emptyList()), + new ProjectPullRequests(Collections.emptyList()) ); assertNotNull(configuration); @@ -48,7 +51,8 @@ public void load_no_project_branches() { branchConfigurationLoader.load( ImmutableMap.of("sonar.branch.name", "test"), () -> ImmutableMap.of("",""), - new ProjectBranches(Collections.emptyList()) + new ProjectBranches(Collections.emptyList()), + new ProjectPullRequests(Collections.emptyList()) ); } @@ -57,7 +61,8 @@ public void load_main() { BranchConfiguration configuration = branchConfigurationLoader.load( ImmutableMap.of("sonar.branch.name", "master"), () -> ImmutableMap.of("",""), - new ProjectBranches(ImmutableList.of(new BranchInfo("master", BranchType.LONG, false, null))) + new ProjectBranches(ImmutableList.of(new BranchInfo("master", BranchType.LONG, false, null))), + new ProjectPullRequests(Collections.emptyList()) ); assertNotNull(configuration); @@ -77,7 +82,8 @@ public void load_target() { new ProjectBranches(ImmutableList.of( new BranchInfo("test", BranchType.SHORT, false, "master"), new BranchInfo("master", BranchType.LONG, true, null) - )) + )), + new ProjectPullRequests(Collections.emptyList()) ); assertNotNull(configuration); @@ -98,7 +104,8 @@ public void load_nested_target() { new BranchInfo("test", BranchType.SHORT, false, "branch"), new BranchInfo("branch", BranchType.SHORT, false, "master"), new BranchInfo("master", BranchType.LONG, true, null) - )) + )), + new ProjectPullRequests(Collections.emptyList()) ); assertNotNull(configuration); @@ -117,7 +124,8 @@ public void load_regex_default() { () -> ImmutableMap.of("",""), new ProjectBranches(ImmutableList.of( new BranchInfo("master", BranchType.LONG, true, null) - )) + )), + new ProjectPullRequests(Collections.emptyList()) ); assertNotNull(configuration); @@ -136,7 +144,8 @@ public void load_regex_custom() { () -> ImmutableMap.of("sonar.branch.longLivedBranches.regex","test"), new ProjectBranches(ImmutableList.of( new BranchInfo("master", BranchType.LONG, true, null) - )) + )), + new ProjectPullRequests(Collections.emptyList()) ); assertNotNull(configuration); @@ -155,7 +164,8 @@ public void load_regex_custom_not_matching() { () -> ImmutableMap.of("sonar.branch.longLivedBranches.regex","notmatching"), new ProjectBranches(ImmutableList.of( new BranchInfo("master", BranchType.LONG, true, null) - )) + )), + new ProjectPullRequests(Collections.emptyList()) ); assertNotNull(configuration);