mirror of https://github.com/mamba-org/mamba.git
Fix relative path in local channel (#3540)
Fix relative path in local channels
This commit is contained in:
parent
038c4c3613
commit
3d9486fea5
|
@ -113,7 +113,14 @@ namespace mamba::specs
|
|||
|
||||
auto parse_path(std::string_view str) -> std::string
|
||||
{
|
||||
auto out = util::path_to_posix(fs::u8path(str).lexically_normal().string());
|
||||
auto out = fs::u8path(str).lexically_normal().string();
|
||||
// Using `lexically_normal()` removes the information of the relative path
|
||||
// => adding it back if originally there
|
||||
if (str.substr(0, 2) == "./")
|
||||
{
|
||||
out = "./" + out;
|
||||
}
|
||||
out = util::path_to_posix(out);
|
||||
out = util::rstrip(out, '/');
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,15 @@ TEST_SUITE("specs::unresolved_channel")
|
|||
{
|
||||
const auto uc = UnresolvedChannel::parse("./folder/../folder/.").value();
|
||||
CHECK_EQ(uc.type(), Type::Path);
|
||||
CHECK_EQ(uc.location(), "folder");
|
||||
CHECK_EQ(uc.location(), "./folder");
|
||||
CHECK_EQ(uc.platform_filters(), PlatformSet{});
|
||||
}
|
||||
|
||||
SUBCASE("./folder/subfolder/")
|
||||
{
|
||||
const auto uc = UnresolvedChannel::parse("./folder/subfolder/").value();
|
||||
CHECK_EQ(uc.type(), Type::Path);
|
||||
CHECK_EQ(uc.location(), "./folder/subfolder");
|
||||
CHECK_EQ(uc.platform_filters(), PlatformSet{});
|
||||
}
|
||||
|
||||
|
|
|
@ -625,6 +625,19 @@ class TestInstall:
|
|||
res = helpers.install(f"file://{file_path}", "--json", default_channel=False)
|
||||
assert "cph_test_data" in {pkg["name"] for pkg in res["actions"]["LINK"]}
|
||||
|
||||
def test_install_local_package_relative_path(self):
|
||||
"""Attempts to install a locally built package from a relative local path."""
|
||||
spec = "./micromamba/tests/test-server/repo::test-package"
|
||||
res = helpers.install(spec, "--json", default_channel=False)
|
||||
assert res["success"]
|
||||
|
||||
pkgs = res["actions"]["LINK"]
|
||||
assert len(pkgs) == 1
|
||||
pkg = pkgs[0]
|
||||
assert pkg["name"] == "test-package"
|
||||
assert pkg["version"] == "0.1"
|
||||
assert pkg["url"].startswith("file://")
|
||||
|
||||
def test_force_reinstall(self, existing_cache):
|
||||
"""Force reinstall installs existing package again."""
|
||||
res = helpers.install("xtensor", "--json")
|
||||
|
|
Loading…
Reference in New Issue