Skip to content

Commit

Permalink
Deprecate unused getSubPackagePath
Browse files Browse the repository at this point in the history
While looking at the subpackage code, I was wondering
why more places didn't call getSubPackagePath instead
of getSubPackageName, and that is because subpackages
can only be one level deep.
  • Loading branch information
Geod24 authored and dlang-bot committed Jan 14, 2024
1 parent acbdac1 commit 6860b2f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/dub/recipe/packagerecipe.d
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ import std.process : environment;
example, "packa:packb:packc" references a package named "packc" that is a
sub package of "packb", which in turn is a sub package of "packa".
*/
deprecated("This function is not supported as subpackages cannot be nested")
string[] getSubPackagePath(string package_name) @safe pure
{
return package_name.split(":");
}

deprecated @safe unittest
{
assert(getSubPackagePath("packa:packb:packc") == ["packa", "packb", "packc"]);
assert(getSubPackagePath("pack") == ["pack"]);
}

/**
Returns the name of the top level package for a given (sub) package name of
format `"basePackageName"` or `"basePackageName:subPackageName"`.
Expand All @@ -62,8 +69,6 @@ string getSubPackageName(string package_name) @safe pure

@safe unittest
{
assert(getSubPackagePath("packa:packb:packc") == ["packa", "packb", "packc"]);
assert(getSubPackagePath("pack") == ["pack"]);
assert(getBasePackageName("packa:packb:packc") == "packa");
assert(getBasePackageName("pack") == "pack");
assert(getSubPackageName("packa:packb:packc") == "packb:packc");
Expand Down

0 comments on commit 6860b2f

Please sign in to comment.