Skip to content

Commit

Permalink
Add support for sonar 7.1.
Browse files Browse the repository at this point in the history
Add changelog.
Add version compatibility table.
Resolves https://github.com/s-pw/sonar-branch-community/issues/1
  • Loading branch information
pawel-sw committed Apr 18, 2018
1 parent d4f9b24 commit 16846c2
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 17 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.sonarsource</groupId>
<artifactId>branch</artifactId>
<version>1.0.1</version>
<version>2.0.0</version>
<description>Branch Plugin for SonarQube Community Edition</description>
<packaging>sonar-plugin</packaging>

Expand All @@ -16,7 +16,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<sonar.sonarQubeMinVersion>6.7</sonar.sonarQubeMinVersion>
<sonar.sonarQubeMinVersion>7.1</sonar.sonarQubeMinVersion>
<sonar.pluginName>Branch Plugin Community Edition</sonar.pluginName>
<sonar.pluginClass>org.sonarsource.branch.BranchPlugin</sonar.pluginClass>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private Optional<BranchDto> loadMainBranchByProjectUuid(String projectUuid) {

private Optional<BranchDto> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public String branchTarget() {
public String branchBase() {
return branchBase;
}

// Not supported by the plugin
@Override
public String pullRequestKey() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -23,7 +24,7 @@ public class BranchConfigurationLoaderImpl implements BranchConfigurationLoader
private static final Logger LOGGER = Loggers.get(BranchConfigurationLoaderImpl.class);

@Override
public BranchConfiguration load(Map<String, String> localSettings, Supplier<Map<String, String>> remoteSettingsSupplier, ProjectBranches branches) {
public BranchConfiguration load(Map<String, String> localSettings, Supplier<Map<String, String>> remoteSettingsSupplier, ProjectBranches branches, ProjectPullRequests pullRequests) {
String branchName = StringUtils.trimToNull(localSettings.get("sonar.branch.name"));
if (branchName == null) {
return new DefaultBranchConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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())
);
}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 16846c2

Please sign in to comment.