Merge pull request 'pkgs/clan/lib: Handle basecase of directory functionality' (#4654) from kenji/ke-add-directory into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4654
This commit is contained in:
@@ -16,8 +16,8 @@ def test_get_relative_clan_directory_default(
|
||||
flake = Flake(str(test_flake_with_core.path))
|
||||
relative_dir = get_clan_directory_relative(flake)
|
||||
|
||||
# Default configuration should return "." (which represents current directory)
|
||||
assert relative_dir == "."
|
||||
# Default configuration should return ""
|
||||
assert relative_dir == ""
|
||||
|
||||
|
||||
@pytest.mark.with_core
|
||||
|
||||
@@ -225,9 +225,16 @@ def get_clan_directories(flake: "Flake") -> tuple[str, str]:
|
||||
root_path = Path(root_directory)
|
||||
directory_path = Path(directory)
|
||||
|
||||
# No custom directory is set
|
||||
if root_path == directory_path:
|
||||
return (root_directory, "")
|
||||
|
||||
try:
|
||||
relative_path = directory_path.relative_to(root_path)
|
||||
return (root_directory, str(relative_path))
|
||||
except ValueError as e:
|
||||
msg = f"Directory path '{directory}' is not relative to root directory '{root_directory}'. This indicates a configuration issue with the clan directory setting."
|
||||
msg = (
|
||||
f"Directory path '{directory}' is not relative to root directory '{root_directory}'."
|
||||
"This indicates a configuration issue with the clan directory setting."
|
||||
)
|
||||
raise ClanError(msg) from e
|
||||
|
||||
Reference in New Issue
Block a user