get_clan_flake_toplevel: fix check
This commit is contained in:
@@ -10,7 +10,7 @@ def get_clan_flake_toplevel() -> Path:
|
|||||||
for project_file in [".clan-flake", ".git", ".hg", ".svn", "flake.nix"]:
|
for project_file in [".clan-flake", ".git", ".hg", ".svn", "flake.nix"]:
|
||||||
initial_path = Path(os.getcwd())
|
initial_path = Path(os.getcwd())
|
||||||
path = Path(initial_path)
|
path = Path(initial_path)
|
||||||
while path.parent == path:
|
while path.parent != path:
|
||||||
if (path / project_file).exists():
|
if (path / project_file).exists():
|
||||||
return path
|
return path
|
||||||
path = path.parent
|
path = path.parent
|
||||||
|
|||||||
@@ -12,3 +12,11 @@ def test_get_clan_flake_toplevel(
|
|||||||
monkeypatch.chdir(temporary_dir)
|
monkeypatch.chdir(temporary_dir)
|
||||||
with pytest.raises(ClanError):
|
with pytest.raises(ClanError):
|
||||||
get_clan_flake_toplevel()
|
get_clan_flake_toplevel()
|
||||||
|
(temporary_dir / ".git").touch()
|
||||||
|
assert get_clan_flake_toplevel() == temporary_dir
|
||||||
|
|
||||||
|
subdir = temporary_dir / "subdir"
|
||||||
|
subdir.mkdir()
|
||||||
|
monkeypatch.chdir(subdir)
|
||||||
|
(subdir / ".clan-flake").touch()
|
||||||
|
assert get_clan_flake_toplevel() == subdir
|
||||||
|
|||||||
Reference in New Issue
Block a user