From bc86e8c64ba7a104c7965433620df2a1c9e33393 Mon Sep 17 00:00:00 2001 From: Ivy Li Date: Wed, 26 Jun 2024 15:25:31 -0700 Subject: [PATCH] fix test --- .../base/sync/workspace/WorkspaceHelper.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/base/src/com/google/idea/blaze/base/sync/workspace/WorkspaceHelper.java b/base/src/com/google/idea/blaze/base/sync/workspace/WorkspaceHelper.java index b798d66c71b..92142b5cf4a 100644 --- a/base/src/com/google/idea/blaze/base/sync/workspace/WorkspaceHelper.java +++ b/base/src/com/google/idea/blaze/base/sync/workspace/WorkspaceHelper.java @@ -125,29 +125,28 @@ private static Workspace resolveWorkspace(Project project, File absoluteFile) { } BlazeProjectData blazeProjectData = getBlazeProjectData(project); - Path bzelRootPath = Paths.get(blazeProjectData.getBlazeInfo().getOutputBase().getAbsolutePath(), + Path bazelRootPath = Paths.get( + blazeProjectData.getBlazeInfo().getOutputBase().getAbsolutePath(), "external").normalize(); + + logger.debug("the bazelRootPath is " + bazelRootPath); Path path = Paths.get(absoluteFile.getAbsolutePath()).normalize(); // Check if the file path starts with the root directory path - if (!path.startsWith(bzelRootPath)) { + if (!path.startsWith(bazelRootPath)) { return null; } - Path relativePath = bzelRootPath.relativize(path); + Path relativePath = bazelRootPath.relativize(path); if (relativePath.getNameCount() > 0) { String firstFolder = relativePath.getName(0).toString(); - try { - Path workspaceRootPath = Files.createDirectories(bzelRootPath.resolve(firstFolder)); + Path workspaceRootPath = bazelRootPath.resolve(firstFolder); + if (workspaceRootPath.toFile().exists()) { logger.debug("resolveWorkspace: " + workspaceRootPath + " firstFolder: " + firstFolder); return new Workspace(new WorkspaceRoot(workspaceRootPath.toFile()), firstFolder); - } catch (IOException e) { - logger.error("Error creating directories", e); - return null; } - } else { - return null; } + return null; } private static Label deriveLabel( @@ -185,7 +184,6 @@ private static WorkspacePath getPackagePath( return null; } - @VisibleForTesting public static File getExternalSourceRoot(BlazeProjectData projectData) { return new File(projectData.getBlazeInfo().getOutputBase(), "external");