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 <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-07-14 08:03:54 -04:00
parent db27fef6f2
commit 4f785cfca0
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
2 changed files with 10 additions and 7 deletions

View File

@ -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")

View File

@ -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: