From: Patrick Donnelly Date: Mon, 27 Apr 2026 19:37:43 +0000 (-0400) Subject: script/ptl-tool: get git dir via git command X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bc42ec6c4b64d8b979a34c9691808981302aaf21;p=ceph.git script/ptl-tool: get git dir via git command Rather than a manual process. Signed-off-by: Patrick Donnelly --- diff --git a/src/script/ptl-tool.py b/src/script/ptl-tool.py index 4848190f12b5..ef98e272e548 100755 --- a/src/script/ptl-tool.py +++ b/src/script/ptl-tool.py @@ -227,13 +227,10 @@ log.addHandler(logging.StreamHandler()) log.setLevel(logging.INFO) # find containing git dir -git_dir = GITDIR -max_levels = 6 -while not os.path.exists(git_dir + '/.git'): - git_dir += '/..' - max_levels -= 1 - if max_levels < 0: - break +try: + git_dir = git.Repo(GITDIR, search_parent_directories=True).working_tree_dir +except (git.NoSuchPathError, git.InvalidGitRepositoryError) as e: + raise SystemExit(f"error: not a git repository: {GITDIR}") from e CONTRIBUTORS = {} NEW_CONTRIBUTORS = {}