From 9e3d7af96b173c0942c2ac735e254b717251dbc0 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Sat, 28 Sep 2024 15:32:36 +0200 Subject: [PATCH] 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. --- pmb/helpers/git.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pmb/helpers/git.py b/pmb/helpers/git.py index 86431f25..ce8361cb 100644 --- a/pmb/helpers/git.py +++ b/pmb/helpers/git.py @@ -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):