From bc42ec6c4b64d8b979a34c9691808981302aaf21 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Mon, 27 Apr 2026 15:37:43 -0400 Subject: [PATCH] script/ptl-tool: get git dir via git command Rather than a manual process. Signed-off-by: Patrick Donnelly --- src/script/ptl-tool.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 = {} -- 2.47.3