From afe40a57354f2284342bdfcc145f2f8093000ae7 Mon Sep 17 00:00:00 2001 From: Grzegorz Siewruk Date: Tue, 11 Jun 2024 12:54:10 +0200 Subject: [PATCH] fix for parent repository search --- .../java/io/mixeway/db/repository/CodeProjectRepository.java | 2 +- .../scanmanager/code/CreateOrGetCodeProjectService.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/mixeway/db/repository/CodeProjectRepository.java b/src/main/java/io/mixeway/db/repository/CodeProjectRepository.java index 82922c6e..b87abe7c 100755 --- a/src/main/java/io/mixeway/db/repository/CodeProjectRepository.java +++ b/src/main/java/io/mixeway/db/repository/CodeProjectRepository.java @@ -51,7 +51,7 @@ public interface CodeProjectRepository extends JpaRepository Optional findByRepoUrlOrRepoUrl(String repoUrl, String s); - Optional findByRepoUrlOrRepoUrlAndName(String repoUrl, String s, String name); + List findByRepoUrlOrRepoUrlAndName(String repoUrl, String s, String name); List findBydTrackUuidNotNullAndRepoUrlNotNull(); @Query("select cp from CodeProject cp where cp.remotename is null and cp.repoUrl is not null and cp.dTrackUuid is null") List getCodeProjectsForSynchro(); diff --git a/src/main/java/io/mixeway/domain/service/scanmanager/code/CreateOrGetCodeProjectService.java b/src/main/java/io/mixeway/domain/service/scanmanager/code/CreateOrGetCodeProjectService.java index a3cd88c6..9e50303d 100644 --- a/src/main/java/io/mixeway/domain/service/scanmanager/code/CreateOrGetCodeProjectService.java +++ b/src/main/java/io/mixeway/domain/service/scanmanager/code/CreateOrGetCodeProjectService.java @@ -21,6 +21,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.security.Principal; +import java.util.List; import java.util.Optional; import java.util.UUID; import java.util.regex.Matcher; @@ -86,8 +87,9 @@ public CodeProject createOrGetCodeProject(String repoUrl, String branch, String String[] repoUrlParts = repo.getPath().split("/"); String name = repoUrlParts[repoUrlParts.length-1]; - Optional codeProject = codeProjectRepository.findByRepoUrlOrRepoUrlAndName(repoUrl, repoUrl+".git", codeProjectName); + List codeProjectList = codeProjectRepository.findByRepoUrlOrRepoUrlAndName(repoUrl, repoUrl+".git", codeProjectName); + Optional codeProject = codeProjectList.stream().filter(cp -> cp.getParent() == null).findFirst(); if (codeProject.isPresent()){ getOrCreateCodeProjectBranchService.getOrCreateCodeProjectBranch(codeProject.get(), branch); return codeProject.get();