1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-13 03:19:47 +03:00

helpers: make get_topdir return Path (MR 2413)

Since the return value is a file path, let's make it a Path object. Also
update the docstring to reflect reality.
This commit is contained in:
Luca Weiss 2024-09-28 15:32:36 +02:00
parent 75a72725c9
commit 9e3d7af96b
No known key found for this signature in database
GPG key ID: 72D843B89D4DD756

View file

@ -331,18 +331,17 @@ def pull(repo_name: str) -> int:
return 0
def get_topdir(repo: Path) -> str:
def get_topdir(repo: Path) -> Path:
"""Get top-dir of git repo.
:returns: a string with the top dir of the git repository,
or an empty string if it's not a git repository.
:returns: the top dir of the git repository
"""
res = pmb.helpers.run.user(
["git", "rev-parse", "--show-toplevel"], repo, output_return=True, check=False
)
if not isinstance(res, str):
raise RuntimeError("Not a git repository: " + str(repo))
return res.strip()
return Path(res.strip())
def get_files(repo: Path):