From 832eb6f130fdb52dfb22fdbd30f011c8de0b8f43 Mon Sep 17 00:00:00 2001 From: Arksine Date: Thu, 11 Mar 2021 07:23:05 -0500 Subject: [PATCH] update_manager: explicitly check if a repo path contains a .git folder This allows the repo init sequence to distinguish between a broken git repo and an invalid git repo. Signed-off-by: Eric Callahan --- moonraker/plugins/update_manager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/moonraker/plugins/update_manager.py b/moonraker/plugins/update_manager.py index c107216..6ae63dc 100644 --- a/moonraker/plugins/update_manager.py +++ b/moonraker/plugins/update_manager.py @@ -804,6 +804,11 @@ class GitRepo: async def update_repo_status(self): async with self.git_operation_lock: + if not os.path.isdir(os.path.join(self.git_path, ".git")): + logging.info( + f"Git Repo {self.alias}: path '{self.git_path}'" + " is not a valid git repo") + return False try: resp = await self.cmd_helper.run_cmd_with_response( f"{self.git_cmd} status -u no") @@ -869,8 +874,7 @@ class GitRepo: def _verify_repo(self, check_remote=False): if not self.valid_git_repo: raise self.server.error( - f"Git Repo {self.alias}: '{self.git_path}' " - "not a git repository") + f"Git Repo {self.alias}: repo not initialized") if check_remote: if self.git_remote == "?": raise self.server.error(