diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2024-03-06 16:48:04 +0100 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2024-03-08 14:18:43 +0100 |
commit | a2ffc06b03cdaf013ddf8825d60b8ee4a9dca431 (patch) | |
tree | 08d0985adb90640f8fdea52d8bb8365347adb99d | |
parent | 197dffc50bed5bce87c142891eee616549670c84 (diff) | |
download | justbuild-a2ffc06b03cdaf013ddf8825d60b8ee4a9dca431.tar.gz |
just-mr: Normalize paths of Git file URLs
... and ensure that paths starting with .// remain relative.
-rw-r--r-- | src/other_tools/root_maps/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/root_maps/commit_git_map.cpp | 10 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS index 9452ca23..42739b92 100644 --- a/src/other_tools/root_maps/TARGETS +++ b/src/other_tools/root_maps/TARGETS @@ -47,6 +47,7 @@ , ["src/other_tools/ops_maps", "critical_git_op_map"] , ["src/other_tools/ops_maps", "import_to_git_map"] , ["src/utils/cpp", "hash_combine"] + , ["src/utils/cpp", "path"] ] , "stage": ["src", "other_tools", "root_maps"] , "private-deps": diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp index a64ccc49..e5910b9b 100644 --- a/src/other_tools/root_maps/commit_git_map.cpp +++ b/src/other_tools/root_maps/commit_git_map.cpp @@ -29,6 +29,7 @@ #include "src/other_tools/just_mr/progress_reporting/statistics.hpp" #include "src/other_tools/root_maps/root_utils.hpp" #include "src/other_tools/utils/curl_url_handle.hpp" +#include "src/utils/cpp/path.hpp" namespace { @@ -38,14 +39,11 @@ namespace { static auto const kRelPath = std::string{"./"}; static auto const kFileScheme = std::string{"file://"}; - if (url.starts_with(kAbsPath)) { - return url; - } - if (url.starts_with(kRelPath)) { - return url.substr(kRelPath.length()); + if (url.starts_with(kAbsPath) or url.starts_with(kRelPath)) { + return ToNormalPath(url).string(); } if (url.starts_with(kFileScheme)) { - return url.substr(kFileScheme.length()); + return ToNormalPath(url.substr(kFileScheme.length())).string(); } return std::nullopt; |