clan create: fix failure when path was single word

This should better be fixed with types. It should be possible to initialize a flake from a Path, making it very clear that a path `foo` is meant and not a remote flake called `foo`
This commit is contained in:
DavHau
2025-07-23 12:33:57 +07:00
parent 377056e80c
commit c94330ee9c
2 changed files with 24 additions and 1 deletions

View File

@@ -84,7 +84,7 @@ def create_clan(opts: CreateOptions) -> None:
# _postprocess_flake_hook must be private to avoid leaking it to the public API
post_process=opts._postprocess_flake_hook, # noqa: SLF001
) as _clan_dir:
flake = Flake(str(opts.dest))
flake = Flake(str(Path(opts.dest).absolute()))
if opts.setup_git:
run(git_command(dest, "init"))

View File

@@ -38,6 +38,29 @@ def test_create_simple(tmp_path: Path, offline_flake_hook: Any) -> None:
assert "instances" in inventory
@pytest.mark.with_core
def test_can_handle_path_without_slash(
tmp_path: Path,
offline_flake_hook: Any,
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""
Tests for a regression, where it broke when the path is a single word like `foo`.
The flake identifier was interpreted as an external flake.
"""
monkeypatch.chdir(tmp_path)
dest = Path("test_clan")
opts = CreateOptions(
dest=dest, template="default", _postprocess_flake_hook=offline_flake_hook
)
create_clan(opts)
assert dest.exists()
assert dest.is_dir()
@pytest.mark.with_core
def test_create_with_name(tmp_path: Path, offline_flake_hook: Any) -> None:
"""