Эх сурвалжийг харах

Add try-catch for os.path.commonpath to handle paths on different drives

Enhanced the function to use a try-catch block around os.path.commonpath
to gracefully handle cases where file paths are located on different drives.
This ensures compatibility and prevents errors related to drive differences.

R=aredulla@google.com, ayatane@chromium.org, sokcevic@chromium.org

Bug: b/360206460
Change-Id: Iee51ba282fd85d211194d8678765a72783727db5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6018123
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Zhonghao Huang 9 сар өмнө
parent
commit
b6a5ecc88a

+ 4 - 1
bootstrap/bootstrap.py

@@ -247,7 +247,10 @@ GIT_POSTPROCESS_VERSION = '2'
 
 def _within_depot_tools(path):
     """Returns whether the given path is within depot_tools."""
-    return os.path.commonpath([os.path.abspath(path), ROOT_DIR]) == ROOT_DIR
+    try:
+        return os.path.commonpath([os.path.abspath(path), ROOT_DIR]) == ROOT_DIR
+    except ValueError:
+        return False
 
 
 def _traverse_to_git_root(abspath):