From 4f785cfca0b4a5e01c5568b0afbf2a49758594b4 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Fri, 14 Jul 2023 08:03:54 -0400 Subject: [PATCH] update_manager: clarify web client git warning When the parent folder of a web client is a git repo note the specific directory that contians a .git subdirectory. Signed-off-by: Eric Callahan --- moonraker/components/update_manager/update_manager.py | 9 ++++++--- moonraker/utils/source_info.py | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/moonraker/components/update_manager/update_manager.py b/moonraker/components/update_manager/update_manager.py index d9b2e59..9ce09bd 100644 --- a/moonraker/components/update_manager/update_manager.py +++ b/moonraker/components/update_manager/update_manager.py @@ -1219,17 +1219,20 @@ class WebClientDeploy(BaseDeploy): self._is_fallback = False eventloop = self.server.get_event_loop() self.warnings.clear() + repo_parent = source_info.find_git_repo(self.path) + homedir = pathlib.Path("~").expanduser() if not self._path_writable: self.warnings.append( f"Location at option 'path: {self.path}' is not writable." ) elif not self.path.is_dir(): self.warnings.append( - f"Location at option 'path: {self.path}' does not exist." + f"Location at option 'path: {self.path}' is not a directory." ) - elif source_info.within_git_repo(self.path): + elif repo_parent is not None and repo_parent != homedir: self.warnings.append( - f"Location at option 'path: {self.path}' is a git repo." + f"Location at option 'path: {self.path}' is within a git repo. Found " + f".git folder at '{repo_parent.joinpath('.git')}'" ) else: rinfo = self.path.joinpath("release_info.json") diff --git a/moonraker/utils/source_info.py b/moonraker/utils/source_info.py index 925f419..d845199 100644 --- a/moonraker/utils/source_info.py +++ b/moonraker/utils/source_info.py @@ -26,15 +26,15 @@ def is_git_repo(src_path: Optional[pathlib.Path] = None) -> bool: src_path = source_path() return src_path.joinpath(".git").is_dir() -def within_git_repo(src_path: Optional[pathlib.Path] = None) -> bool: +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(): - return True + return src_path for parent in src_path.parents: if parent.joinpath(".git").is_dir(): - return True - return False + return parent + return None def is_dist_package(src_path: Optional[pathlib.Path] = None) -> bool: if src_path is None: