diff --git a/API_CHANGES.md b/API_CHANGES.md index 39d7b8187b..f2f89c7ac8 100644 --- a/API_CHANGES.md +++ b/API_CHANGES.md @@ -1,3 +1,9 @@ +# 10.7.1 + +## Breaking changes + +* Add a new method to `org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcClient#matchProjectBranch` allowing the backend to check whether the locally checked-out branch matches a requesting server branch + # 10.7 ## Breaking changes diff --git a/backend/analysis-engine/pom.xml b/backend/analysis-engine/pom.xml index 9d848f15db..7c8ceb295d 100644 --- a/backend/analysis-engine/pom.xml +++ b/backend/analysis-engine/pom.xml @@ -3,7 +3,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-analysis-engine diff --git a/backend/cli/pom.xml b/backend/cli/pom.xml index d75c58e8aa..db9d81194e 100644 --- a/backend/cli/pom.xml +++ b/backend/cli/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-backend-cli diff --git a/backend/commons/pom.xml b/backend/commons/pom.xml index 7c86c524ea..b1be145b4d 100644 --- a/backend/commons/pom.xml +++ b/backend/commons/pom.xml @@ -3,7 +3,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-commons diff --git a/backend/core/pom.xml b/backend/core/pom.xml index 7fdb0c0e8d..c8880dec18 100644 --- a/backend/core/pom.xml +++ b/backend/core/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-core diff --git a/backend/core/src/main/java/org/sonarsource/sonarlint/core/branch/SonarProjectBranchTrackingService.java b/backend/core/src/main/java/org/sonarsource/sonarlint/core/branch/SonarProjectBranchTrackingService.java index dd05b58969..daff50b93c 100644 --- a/backend/core/src/main/java/org/sonarsource/sonarlint/core/branch/SonarProjectBranchTrackingService.java +++ b/backend/core/src/main/java/org/sonarsource/sonarlint/core/branch/SonarProjectBranchTrackingService.java @@ -156,11 +156,6 @@ private String matchSonarProjectBranch(String configurationScopeId, SonarLintCan return matchedSonarBranch; } - @CheckForNull - public String getMatchedSonarProjectBranch(String configurationScopeId) { - return cachedMatchingBranchByConfigScope.get(configurationScopeId); - } - @CheckForNull private String requestClientToMatchSonarProjectBranch(String configurationScopeId, String mainSonarBranchName, Set allSonarBranchesNames, SonarLintCancelMonitor cancelMonitor) { diff --git a/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowFixSuggestionRequestHandler.java b/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowFixSuggestionRequestHandler.java index 121e4bd286..7f900fb870 100644 --- a/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowFixSuggestionRequestHandler.java +++ b/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowFixSuggestionRequestHandler.java @@ -51,6 +51,7 @@ import org.sonarsource.sonarlint.core.file.PathTranslationService; import org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcClient; import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.InitializeParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchProjectBranchParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.SonarCloudConnectionParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.SonarQubeConnectionParams; @@ -112,10 +113,10 @@ public void handle(ClassicHttpRequest request, ClassicHttpResponse response, Htt showFixSuggestionQuery.projectKey, (connectionId, configScopeId, cancelMonitor) -> { if (configScopeId != null) { - var matchingBranch = branchTrackingService.getMatchedSonarProjectBranch(configScopeId); - if (matchingBranch != null && !matchingBranch.equals(showFixSuggestionQuery.branch)) { + var localBranchMatchesRequesting = client.matchProjectBranch(new MatchProjectBranchParams(configScopeId, showFixSuggestionQuery.branch)).join().isBranchMatched(); + if (!localBranchMatchesRequesting) { client.showMessage(new ShowMessageParams(MessageType.ERROR, "Attempted to show a fix suggestion for a different branch than the one currently checked out." + - "\nPlease check out the correct branch and try again.")); + "\nPlease make sure the correct branch is checked out and try again.")); return; } showFixSuggestionForScope(configScopeId, showFixSuggestionQuery.issueKey, showFixSuggestionQuery.fixSuggestion); diff --git a/backend/core/src/test/java/org/sonarsource/sonarlint/core/embedded/server/ShowFixSuggestionRequestHandlerTests.java b/backend/core/src/test/java/org/sonarsource/sonarlint/core/embedded/server/ShowFixSuggestionRequestHandlerTests.java index d2ebc80311..45307e5caa 100644 --- a/backend/core/src/test/java/org/sonarsource/sonarlint/core/embedded/server/ShowFixSuggestionRequestHandlerTests.java +++ b/backend/core/src/test/java/org/sonarsource/sonarlint/core/embedded/server/ShowFixSuggestionRequestHandlerTests.java @@ -23,6 +23,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.List; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; @@ -49,6 +50,7 @@ import org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcClient; import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.FeatureFlagsDto; import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.InitializeParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchProjectBranchResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.message.MessageType; import org.sonarsource.sonarlint.core.rpc.protocol.client.message.ShowMessageParams; import org.sonarsource.sonarlint.core.telemetry.TelemetryService; @@ -247,16 +249,16 @@ void should_cancel_flow_when_branch_does_not_match() throws HttpException, IOExc when(connectionConfigurationRepository.findByOrganization(any())).thenReturn(List.of( new SonarCloudConnectionConfiguration(PRODUCTION_URI, "name", "organizationKey", false))); when(configurationRepository.getBoundScopesToConnectionAndSonarProject(any(), any())).thenReturn(List.of(new BoundScope("configScope", "connectionId", "projectKey"))); - when(sonarProjectBranchTrackingService.getMatchedSonarProjectBranch(any())).thenReturn("branch"); - when(sonarProjectBranchTrackingService.getMatchedSonarProjectBranch(any())).thenReturn("anotherBranch"); + when(sonarLintRpcClient.matchProjectBranch(any())).thenReturn(CompletableFuture.completedFuture(new MatchProjectBranchResponse(false))); showFixSuggestionRequestHandler.handle(request, response, context); var showMessageArgumentCaptor = ArgumentCaptor.forClass(ShowMessageParams.class); await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> verify(sonarLintRpcClient).showMessage(showMessageArgumentCaptor.capture())); assertThat(showMessageArgumentCaptor.getValue().getType()).isEqualTo(MessageType.ERROR); - assertThat(showMessageArgumentCaptor.getValue().getText()).isEqualTo("Attempted to show a fix suggestion for a different branch than the one currently checked out." + - "\nPlease check out the correct branch and try again."); + assertThat(showMessageArgumentCaptor.getValue().getText()).isEqualTo("Attempted to show a fix suggestion for a different branch than the one currently checked out.\n" + + "Please make sure the correct branch is checked out and try again."); + verify(sonarLintRpcClient).matchProjectBranch(any()); verifyNoMoreInteractions(sonarLintRpcClient); } diff --git a/backend/http/pom.xml b/backend/http/pom.xml index 971a340c60..2cfc24f65e 100644 --- a/backend/http/pom.xml +++ b/backend/http/pom.xml @@ -3,7 +3,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-http diff --git a/backend/plugin-api/pom.xml b/backend/plugin-api/pom.xml index c17ee99834..a95656d68c 100644 --- a/backend/plugin-api/pom.xml +++ b/backend/plugin-api/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-plugin-api diff --git a/backend/plugin-commons/pom.xml b/backend/plugin-commons/pom.xml index 34ee2feaee..32001778f7 100644 --- a/backend/plugin-commons/pom.xml +++ b/backend/plugin-commons/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-plugin-commons diff --git a/backend/rpc-impl/pom.xml b/backend/rpc-impl/pom.xml index 72731e0919..8d58a3068a 100644 --- a/backend/rpc-impl/pom.xml +++ b/backend/rpc-impl/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-rpc-impl diff --git a/backend/rule-extractor/pom.xml b/backend/rule-extractor/pom.xml index fc0cb88c72..d10d8985eb 100644 --- a/backend/rule-extractor/pom.xml +++ b/backend/rule-extractor/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-rule-extractor diff --git a/backend/server-api/pom.xml b/backend/server-api/pom.xml index 8d9192d4c6..1b1f4d089b 100644 --- a/backend/server-api/pom.xml +++ b/backend/server-api/pom.xml @@ -3,7 +3,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-server-api diff --git a/backend/server-connection/pom.xml b/backend/server-connection/pom.xml index da9faf7ca3..97793d3062 100644 --- a/backend/server-connection/pom.xml +++ b/backend/server-connection/pom.xml @@ -3,7 +3,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-server-connection diff --git a/backend/slf4j-sonar-log/pom.xml b/backend/slf4j-sonar-log/pom.xml index ab148a5ce0..00f2b7c0fb 100644 --- a/backend/slf4j-sonar-log/pom.xml +++ b/backend/slf4j-sonar-log/pom.xml @@ -3,7 +3,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-slf4j-sonar-log diff --git a/backend/telemetry/pom.xml b/backend/telemetry/pom.xml index f6effe0100..0331e7b315 100644 --- a/backend/telemetry/pom.xml +++ b/backend/telemetry/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-telemetry diff --git a/buildSrc/maven-shade-ext-bnd-transformer/pom.xml b/buildSrc/maven-shade-ext-bnd-transformer/pom.xml index 680a9d680c..ff9b02528f 100644 --- a/buildSrc/maven-shade-ext-bnd-transformer/pom.xml +++ b/buildSrc/maven-shade-ext-bnd-transformer/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml maven-shade-ext-bnd-transformer diff --git a/client/java-client-dependencies/pom.xml b/client/java-client-dependencies/pom.xml index 74fc6b146a..83b2af2897 100644 --- a/client/java-client-dependencies/pom.xml +++ b/client/java-client-dependencies/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-java-client-dependencies diff --git a/client/java-client-legacy/pom.xml b/client/java-client-legacy/pom.xml index 3052a14e69..458212bd16 100644 --- a/client/java-client-legacy/pom.xml +++ b/client/java-client-legacy/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-java-client-legacy diff --git a/client/java-client-osgi/pom.xml b/client/java-client-osgi/pom.xml index 339425f44b..842905cad4 100644 --- a/client/java-client-osgi/pom.xml +++ b/client/java-client-osgi/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-java-client-osgi diff --git a/client/java-client-utils/pom.xml b/client/java-client-utils/pom.xml index f0e9afb8ed..136bae51a2 100644 --- a/client/java-client-utils/pom.xml +++ b/client/java-client-utils/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-java-client-utils diff --git a/client/rpc-java-client/pom.xml b/client/rpc-java-client/pom.xml index 51149a0ba6..8e24901183 100644 --- a/client/rpc-java-client/pom.xml +++ b/client/rpc-java-client/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml sonarlint-rpc-java-client diff --git a/client/rpc-java-client/src/main/java/org/sonarsource/sonarlint/core/rpc/client/SonarLintRpcClientDelegate.java b/client/rpc-java-client/src/main/java/org/sonarsource/sonarlint/core/rpc/client/SonarLintRpcClientDelegate.java index 4038e0a420..388da30ccd 100644 --- a/client/rpc-java-client/src/main/java/org/sonarsource/sonarlint/core/rpc/client/SonarLintRpcClientDelegate.java +++ b/client/rpc-java-client/src/main/java/org/sonarsource/sonarlint/core/rpc/client/SonarLintRpcClientDelegate.java @@ -169,6 +169,8 @@ default void showFixSuggestion(String configurationScopeId, String issueKey, Fix String matchSonarProjectBranch(String configurationScopeId, String mainBranchName, Set allBranchesNames, SonarLintCancelChecker cancelChecker) throws ConfigScopeNotFoundException; + boolean matchProjectBranch(String configurationScopeId, String branchNameToMatch, SonarLintCancelChecker cancelChecker) throws ConfigScopeNotFoundException; + void didChangeMatchedSonarProjectBranch(String configScopeId, String newMatchedBranchName); TelemetryClientLiveAttributesResponse getTelemetryLiveAttributes(); diff --git a/client/rpc-java-client/src/main/java/org/sonarsource/sonarlint/core/rpc/client/SonarLintRpcClientImpl.java b/client/rpc-java-client/src/main/java/org/sonarsource/sonarlint/core/rpc/client/SonarLintRpcClientImpl.java index 0f891693eb..ef7bcdd9f5 100644 --- a/client/rpc-java-client/src/main/java/org/sonarsource/sonarlint/core/rpc/client/SonarLintRpcClientImpl.java +++ b/client/rpc-java-client/src/main/java/org/sonarsource/sonarlint/core/rpc/client/SonarLintRpcClientImpl.java @@ -39,15 +39,17 @@ import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.DidChangeAnalysisReadinessParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.DidDetectSecretParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.DidRaiseIssueParams; -import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetInferredAnalysisPropertiesParams; -import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetInferredAnalysisPropertiesResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetFileExclusionsParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetFileExclusionsResponse; +import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetInferredAnalysisPropertiesParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetInferredAnalysisPropertiesResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.AssistBindingParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.AssistBindingResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.NoBindingSuggestionFoundParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.SuggestBindingParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.DidChangeMatchedSonarProjectBranchParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchProjectBranchParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchProjectBranchResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchSonarProjectBranchParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchSonarProjectBranchResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionParams; @@ -311,6 +313,18 @@ public CompletableFuture matchSonarProjectBranc }); } + @Override + public CompletableFuture matchProjectBranch(MatchProjectBranchParams params) { + return requestAsync(cancelChecker -> { + try { + return new MatchProjectBranchResponse( + delegate.matchProjectBranch(params.getConfigurationScopeId(), params.getServerBranchToMatch(), new SonarLintCancelChecker(cancelChecker))); + } catch (ConfigScopeNotFoundException e) { + throw configScopeNotFoundError(params.getConfigurationScopeId()); + } + }); + } + @Override public void didChangeMatchedSonarProjectBranch(DidChangeMatchedSonarProjectBranchParams params) { notify(() -> delegate.didChangeMatchedSonarProjectBranch(params.getConfigScopeId(), params.getNewMatchedBranchName())); diff --git a/its/plugins/custom-sensor-plugin/pom.xml b/its/plugins/custom-sensor-plugin/pom.xml index b59a38805c..a2807be47d 100644 --- a/its/plugins/custom-sensor-plugin/pom.xml +++ b/its/plugins/custom-sensor-plugin/pom.xml @@ -5,14 +5,14 @@ org.sonarsource.sonarlint.core sonarlint-core-its - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml org.sonarsource.plugins.example custom-sensor-plugin sonar-plugin - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT Example Plugin for SonarQube Example of plugin for SonarQube diff --git a/its/plugins/global-extension-plugin/pom.xml b/its/plugins/global-extension-plugin/pom.xml index f864be9189..62442902a2 100644 --- a/its/plugins/global-extension-plugin/pom.xml +++ b/its/plugins/global-extension-plugin/pom.xml @@ -5,7 +5,7 @@ org.sonarsource.sonarlint.core sonarlint-core-its - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml diff --git a/its/plugins/java-custom-rules/pom.xml b/its/plugins/java-custom-rules/pom.xml index 08d883dbc3..82a394a1b5 100644 --- a/its/plugins/java-custom-rules/pom.xml +++ b/its/plugins/java-custom-rules/pom.xml @@ -6,7 +6,7 @@ org.sonarsource.sonarlint.core sonarlint-core-its - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT ../../pom.xml diff --git a/its/pom.xml b/its/pom.xml index f324ab9adf..61579fc73c 100644 --- a/its/pom.xml +++ b/its/pom.xml @@ -3,7 +3,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT sonarlint-core-its SonarLint Core - ITs diff --git a/its/tests/pom.xml b/its/tests/pom.xml index c09b4993d9..40115162cf 100644 --- a/its/tests/pom.xml +++ b/its/tests/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-its - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT sonarlint-core-its-tests SonarLint Core - ITs - Tests diff --git a/its/tests/src/test/java/its/MockSonarLintRpcClientDelegate.java b/its/tests/src/test/java/its/MockSonarLintRpcClientDelegate.java index 7deca7aba8..ccee68a8dd 100644 --- a/its/tests/src/test/java/its/MockSonarLintRpcClientDelegate.java +++ b/its/tests/src/test/java/its/MockSonarLintRpcClientDelegate.java @@ -189,6 +189,10 @@ public String matchSonarProjectBranch(String configurationScopeId, String mainBr return mainBranchName; } + public boolean matchProjectBranch(String configurationScopeId, String branchNameToMatch, SonarLintCancelChecker cancelChecker) throws ConfigScopeNotFoundException { + return true; + } + @Override public void didChangeMatchedSonarProjectBranch(String configScopeId, String newMatchedBranchName) { diff --git a/medium-tests/pom.xml b/medium-tests/pom.xml index 64bd0f05e9..e2e3925722 100644 --- a/medium-tests/pom.xml +++ b/medium-tests/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT sonarlint-medium-tests SonarLint Core - Medium Tests diff --git a/medium-tests/src/test/java/mediumtest/fixtures/SonarLintBackendFixture.java b/medium-tests/src/test/java/mediumtest/fixtures/SonarLintBackendFixture.java index 775f952509..0e34eb4d34 100644 --- a/medium-tests/src/test/java/mediumtest/fixtures/SonarLintBackendFixture.java +++ b/medium-tests/src/test/java/mediumtest/fixtures/SonarLintBackendFixture.java @@ -726,6 +726,11 @@ public String matchSonarProjectBranch(String configurationScopeId, String mainBr return mainBranchName; } + @Override + public boolean matchProjectBranch(String configurationScopeId, String branchNameToMatch, SonarLintCancelChecker cancelChecker) throws ConfigScopeNotFoundException { + return true; + } + @Override public void didChangeMatchedSonarProjectBranch(String configScopeId, String newMatchedBranchName) { diff --git a/medium-tests/src/test/java/mediumtest/sloop/SloopLauncherTests.java b/medium-tests/src/test/java/mediumtest/sloop/SloopLauncherTests.java index 52a87a7fad..49de3db8fa 100644 --- a/medium-tests/src/test/java/mediumtest/sloop/SloopLauncherTests.java +++ b/medium-tests/src/test/java/mediumtest/sloop/SloopLauncherTests.java @@ -37,6 +37,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import org.sonarsource.sonarlint.core.rpc.client.ConfigScopeNotFoundException; import org.sonarsource.sonarlint.core.rpc.client.ConnectionNotFoundException; import org.sonarsource.sonarlint.core.rpc.client.Sloop; import org.sonarsource.sonarlint.core.rpc.client.SloopLauncher; @@ -284,6 +285,11 @@ public String matchSonarProjectBranch(String configurationScopeId, String mainBr return null; } + @Override + public boolean matchProjectBranch(String configurationScopeId, String branchNameToMatch, SonarLintCancelChecker cancelChecker) throws ConfigScopeNotFoundException { + return true; + } + @Override public void didChangeMatchedSonarProjectBranch(String configScopeId, String newMatchedBranchName) { diff --git a/pom.xml b/pom.xml index a509f1386d..84cc10cfd2 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT pom SonarLint Core Library used by SonarLint flavors (Eclipse, IntelliJ, VSCode...) diff --git a/report-aggregate/pom.xml b/report-aggregate/pom.xml index 4e7ea4a9c2..c3d27c020f 100644 --- a/report-aggregate/pom.xml +++ b/report-aggregate/pom.xml @@ -4,7 +4,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT sonarlint-report-aggregate SonarLint Coverage Reports Aggregator diff --git a/rpc-protocol/pom.xml b/rpc-protocol/pom.xml index 5df013e03b..e356470999 100644 --- a/rpc-protocol/pom.xml +++ b/rpc-protocol/pom.xml @@ -7,7 +7,7 @@ org.sonarsource.sonarlint.core sonarlint-core-parent - 10.7-SNAPSHOT + 10.7.1-SNAPSHOT sonarlint-rpc-protocol SonarLint Core - RPC Protocol diff --git a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/SonarLintRpcClient.java b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/SonarLintRpcClient.java index ef1b2965bc..82f7bbbdc9 100644 --- a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/SonarLintRpcClient.java +++ b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/SonarLintRpcClient.java @@ -23,23 +23,23 @@ import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode; import org.eclipse.lsp4j.jsonrpc.services.JsonNotification; import org.eclipse.lsp4j.jsonrpc.services.JsonRequest; -import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.DidDetectSecretParams; -import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetInferredAnalysisPropertiesParams; -import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetInferredAnalysisPropertiesResponse; -import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.RaiseIssuesParams; -import org.sonarsource.sonarlint.core.rpc.protocol.client.plugin.DidSkipLoadingPluginParams; import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.ClientConstantInfoDto; import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.InitializeParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.OpenUrlInBrowserParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.DidChangeAnalysisReadinessParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.DidDetectSecretParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.DidRaiseIssueParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetFileExclusionsParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetFileExclusionsResponse; +import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetInferredAnalysisPropertiesParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.analysis.GetInferredAnalysisPropertiesResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.AssistBindingParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.AssistBindingResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.NoBindingSuggestionFoundParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.SuggestBindingParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.DidChangeMatchedSonarProjectBranchParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchProjectBranchParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchProjectBranchResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchSonarProjectBranchParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.branch.MatchSonarProjectBranchResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionParams; @@ -62,10 +62,12 @@ import org.sonarsource.sonarlint.core.rpc.protocol.client.http.SelectProxiesParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.http.SelectProxiesResponse; import org.sonarsource.sonarlint.core.rpc.protocol.client.info.GetClientLiveInfoResponse; +import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.RaiseIssuesParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.ShowIssueParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.log.LogParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.message.ShowMessageParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.message.ShowSoonUnsupportedMessageParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.plugin.DidSkipLoadingPluginParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.progress.ReportProgressParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.progress.StartProgressParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.promotion.PromoteExtraEnabledLanguagesInConnectedModeParams; @@ -207,6 +209,13 @@ default void showFixSuggestion(ShowFixSuggestionParams params) { @JsonRequest CompletableFuture matchSonarProjectBranch(MatchSonarProjectBranchParams params); + /** + * Used for checking whether a locally checked out branch matches a candidate branch name (not necessarily a Sonar branch). + * For example, in "show fix suggestion" use-case, to match a local branch with a PR branch that originated a fix suggestion + */ + @JsonRequest + CompletableFuture matchProjectBranch(MatchProjectBranchParams params); + @JsonNotification void didChangeMatchedSonarProjectBranch(DidChangeMatchedSonarProjectBranchParams params); diff --git a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/branch/MatchProjectBranchParams.java b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/branch/MatchProjectBranchParams.java new file mode 100644 index 0000000000..0affda2dbe --- /dev/null +++ b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/branch/MatchProjectBranchParams.java @@ -0,0 +1,39 @@ +/* + * SonarLint Core - RPC Protocol + * Copyright (C) 2016-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarsource.sonarlint.core.rpc.protocol.client.branch; + +public class MatchProjectBranchParams { + private final String configurationScopeId; + private final String serverBranchToMatch; + + public MatchProjectBranchParams(String configurationScopeId, String branchNameToMatch) { + this.configurationScopeId = configurationScopeId; + this.serverBranchToMatch = branchNameToMatch; + } + + public String getConfigurationScopeId() { + return configurationScopeId; + } + + public String getServerBranchToMatch() { + return serverBranchToMatch; + } + +} diff --git a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/branch/MatchProjectBranchResponse.java b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/branch/MatchProjectBranchResponse.java new file mode 100644 index 0000000000..00edbcb7c8 --- /dev/null +++ b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/branch/MatchProjectBranchResponse.java @@ -0,0 +1,32 @@ +/* + * SonarLint Core - RPC Protocol + * Copyright (C) 2016-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarsource.sonarlint.core.rpc.protocol.client.branch; + +public class MatchProjectBranchResponse { + private final boolean isBranchMatched; + + public MatchProjectBranchResponse(boolean matchedSonarBranch) { + this.isBranchMatched = matchedSonarBranch; + } + + public boolean isBranchMatched() { + return isBranchMatched; + } +}