From 706455a6f80738a3a75daee533791bb00e59cd34 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Tue, 11 Feb 2025 16:36:36 -0500 Subject: [PATCH] source_info: include git worktree detection Standard git repos contain a ".git" folder, however worktrees contain a ".git" file. The file provides the path to the worktree's git directory. Signed-off-by: Eric Callahan --- moonraker/utils/source_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/moonraker/utils/source_info.py b/moonraker/utils/source_info.py index a9c75a3..512734c 100644 --- a/moonraker/utils/source_info.py +++ b/moonraker/utils/source_info.py @@ -32,15 +32,15 @@ def source_path() -> pathlib.Path: def is_git_repo(src_path: Optional[pathlib.Path] = None) -> bool: if src_path is None: src_path = source_path() - return src_path.joinpath(".git").is_dir() + return src_path.joinpath(".git").exists() def find_git_repo(src_path: Optional[pathlib.Path] = None) -> Optional[pathlib.Path]: if src_path is None: src_path = source_path() - if src_path.joinpath(".git").is_dir(): + if src_path.joinpath(".git").exists(): return src_path for parent in src_path.parents: - if parent.joinpath(".git").is_dir(): + if parent.joinpath(".git").exists(): return parent return None