summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-11-10 16:07:57 -0500
committerDylan Baker <dylan@pnwbakers.com>2025-11-19 09:59:13 -0800
commitf09048a23a59aee527ceb3b8b90322adaf3bd577 (patch)
treef3fafb69e628dd5e62b26766708ea682d906f611
parent18c1ce716b8fe43cce090daa851b64cbbbdbd532 (diff)
downloadmeson-f09048a23a59aee527ceb3b8b90322adaf3bd577.tar.gz
fix parsing cgit paths
Using os.path.basename on a string such as "/foo/bar/" returns an empty string, which breaks on e.g. Cgit git URLs. The fix uses pathlibs Path class "parent" method, which gets the last component of the path, so "bar" for "/foo/bar/".
-rw-r--r--mesonbuild/cargo/interpreter.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/mesonbuild/cargo/interpreter.py b/mesonbuild/cargo/interpreter.py
index 297ff5e87..25a1b70db 100644
--- a/mesonbuild/cargo/interpreter.py
+++ b/mesonbuild/cargo/interpreter.py
@@ -17,6 +17,7 @@ import pathlib
import collections
import urllib.parse
import typing as T
+from pathlib import PurePath
from . import builder, version
from .cfg import eval_cfg
@@ -799,7 +800,7 @@ def _parse_git_url(url: str, branch: T.Optional[str] = None) -> T.Tuple[str, str
query_branch = query['branch'][0] if 'branch' in query else ''
branch = branch or query_branch
revision = parts.fragment or branch
- directory = os.path.basename(parts.path)
+ directory = PurePath(parts.path).name
if directory.endswith('.git'):
directory = directory[:-4]
if branch: