Skip to content

Commit

Permalink
Handle git+https pip urls (#3764)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hind-M authored Jan 23, 2025
1 parent 9c856fd commit 617be25
Show file tree
Hide file tree
Showing 5 changed files with 643 additions and 6 deletions.
14 changes: 14 additions & 0 deletions libmamba/src/specs/package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ namespace mamba::specs
}
}

// A git repository URL over https and used by `pip`
// git+https://<repository-url>@<commit|branch|tag>#egg=<package-name>
if (util::starts_with(str, "git+https"))
{
auto pkg = PackageInfo();
pkg.package_url = str;
const std::string pkg_name_marker = "#egg=";
if (const auto idx = str.rfind(pkg_name_marker); idx != std::string_view::npos)
{
pkg.name = str.substr(idx + pkg_name_marker.length());
}
return pkg;
}

return make_unexpected_parse(fmt::format(R"(Fail to parse PackageInfo URL "{}")", str));
}

Expand Down
9 changes: 9 additions & 0 deletions libmamba/tests/src/specs/test_package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ namespace
static constexpr std::string_view url = "https://conda.anaconda.org/conda-forge/linux-64/pkg.conda";
REQUIRE_FALSE(PackageInfo::from_url(url).has_value());
}

SECTION("git+https://github.com/urllib3/[email protected]#egg=urllib3")
{
static constexpr std::string_view url = "git+https://github.com/urllib3/[email protected]#egg=urllib3";
auto pkg = PackageInfo::from_url(url).value();

REQUIRE(pkg.name == "urllib3");
REQUIRE(pkg.package_url == url);
}
}

TEST_CASE("PackageInfo serialization")
Expand Down
Loading

0 comments on commit 617be25

Please sign in to comment.