From 86ccec73ec88bac71700e4eee6d100c7bfbb9891 Mon Sep 17 00:00:00 2001 From: zs Date: Mon, 29 Jul 2024 16:48:37 +0800 Subject: [PATCH 1/2] fixup project path for Windows --- core/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/utils.py b/core/utils.py index 891aaac466..3e96d53919 100755 --- a/core/utils.py +++ b/core/utils.py @@ -362,7 +362,13 @@ def get_project_path(filepath): import os dir_path = os.path.dirname(filepath) if get_command_result("git rev-parse --is-inside-work-tree", dir_path) == "true": - return get_command_result("git rev-parse --show-toplevel", dir_path) + path_from_git = get_command_result("git rev-parse --show-toplevel", dir_path) + if get_os_name() == "windows": + path_parts = path_from_git.split("/") + windows_path = path_parts[1] + ":/" + "/".join(path_parts[2:]) + return windows_path + else: + return path_from_git else: return filepath From 5c85839973c375427cc9b21923a35b6fe7b7bb07 Mon Sep 17 00:00:00 2001 From: zs Date: Wed, 31 Jul 2024 20:07:56 +0800 Subject: [PATCH 2/2] convert only a Unix-style path to a Windows-one --- core/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/utils.py b/core/utils.py index 4407173882..bdc3256cc4 100755 --- a/core/utils.py +++ b/core/utils.py @@ -365,8 +365,12 @@ def get_project_path(filepath): path_from_git = get_command_result("git rev-parse --show-toplevel", dir_path) if get_os_name() == "windows": path_parts = path_from_git.split("/") - windows_path = path_parts[1] + ":/" + "/".join(path_parts[2:]) - return windows_path + # if this is a Unix-style absolute path, which should be a Windows-style one + if path_parts[0] == "/": + windows_path = path_parts[1] + ":/" + "/".join(path_parts[2:]) + return windows_path + else: + return path_from_git else: return path_from_git else: