git.commit_file: fix file path & repo path finding

This commit is contained in:
DavHau
2023-09-22 13:24:25 +02:00
parent c34de3194a
commit 0196fd72c3
3 changed files with 42 additions and 4 deletions

View File

@@ -6,8 +6,16 @@ from .errors import ClanError
def get_clan_flake_toplevel() -> Path:
return find_toplevel([".clan-flake", ".git", ".hg", ".svn", "flake.nix"])
def find_git_repo_root() -> Path:
return find_toplevel([".git"])
def find_toplevel(top_level_files: list[str]) -> Path:
"""Returns the path to the toplevel of the clan flake"""
for project_file in [".clan-flake", ".git", ".hg", ".svn", "flake.nix"]:
for project_file in top_level_files:
initial_path = Path(os.getcwd())
path = Path(initial_path)
while path.parent != path: