diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-09-30 12:23:26 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-10-12 20:03:44 +0000 |
commit | 50b12df3787d87958fcef7fbf8c00598b141f1ee (patch) | |
tree | cbc6fd2927bd89d8f68b84d06e00dd419c4025e5 /server/sonar-webserver-es | |
parent | c85e433a567b8580a1fd5e185b4f5bc73b6e53e6 (diff) | |
download | sonarqube-50b12df3787d87958fcef7fbf8c00598b141f1ee.tar.gz sonarqube-50b12df3787d87958fcef7fbf8c00598b141f1ee.zip |
SONAR-17352 Refactor component keys to not include branch suffix
Diffstat (limited to 'server/sonar-webserver-es')
-rw-r--r-- | server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java index 22d72c4b921..fc53b893444 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java @@ -420,14 +420,7 @@ public class IssueQueryFactory { } private List<ComponentDto> getComponentsFromKeys(DbSession dbSession, Collection<String> componentKeys, @Nullable String branch, @Nullable String pullRequest) { - List<ComponentDto> componentDtos; - if (branch != null) { - componentDtos = dbClient.componentDao().selectByKeysAndBranch(dbSession, componentKeys, branch); - } else if (pullRequest != null) { - componentDtos = dbClient.componentDao().selectByKeysAndPullRequest(dbSession, componentKeys, pullRequest); - } else { - componentDtos = dbClient.componentDao().selectByKeys(dbSession, componentKeys); - } + List<ComponentDto> componentDtos = dbClient.componentDao().selectByKeys(dbSession, componentKeys, branch, pullRequest); if (!componentKeys.isEmpty() && componentDtos.isEmpty()) { return singletonList(UNKNOWN_COMPONENT); } @@ -456,12 +449,12 @@ public class IssueQueryFactory { private void setBranch(IssueQuery.Builder builder, ComponentDto component, @Nullable String branch, @Nullable String pullRequest, DbSession session) { - BranchDto branchDto = findComponentBranch(session, component); - String componentBranch = branchDto.isMain() ? null : branchDto.getBranchKey(); builder.branchUuid(branch == null && pullRequest == null ? null : component.branchUuid()); - builder.mainBranch(UNKNOWN_COMPONENT.equals(component) - || (branch == null && pullRequest == null) - || (branch != null && !branch.equals(componentBranch)) - || (pullRequest != null && !pullRequest.equals(branchDto.getPullRequestKey()))); + if (UNKNOWN_COMPONENT.equals(component) || (pullRequest == null && branch == null)) { + builder.mainBranch(true); + } else { + BranchDto branchDto = findComponentBranch(session, component); + builder.mainBranch(branchDto.isMain()); + } } } |