Skip to content

Commit

Permalink
git_deploy: remove untracked file warnings
Browse files Browse the repository at this point in the history
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
  • Loading branch information
Arksine committed Jul 24, 2023
1 parent fe52bc5 commit 871c551
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions moonraker/components/update_manager/git_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,9 @@ async def check_diverged(self) -> bool:
return not (await self.is_ancestor("HEAD", descendent))

def log_repo_info(self) -> None:
warnings = ""
if self.repo_warnings:
warnings = "\nRepo Warnings:\n"
warnings += '\n'.join([f" {warn}" for warn in self.repo_warnings])
warnings = self._generate_warn_msg()
if warnings:
warnings = "\nRepo Warnings:\n" + warnings
logging.info(
f"Git Repo {self.alias} Detected:\n"
f"Owner: {self.git_owner}\n"
Expand All @@ -715,10 +714,10 @@ def log_repo_info(self) -> None:
)

def _check_warnings(self) -> None:
self.repo_warnings.clear()
if self.upstream_url == "?":
self.repo_warnings.append("Failed to detect repo url")
return
self.repo_warnings.clear()
upstream_url = self.upstream_url.lower()
if upstream_url[-4:] != ".git":
upstream_url += ".git"
Expand All @@ -738,21 +737,30 @@ def _check_warnings(self) -> None:
"Repo is dirty. Detected the following modifed files: "
f"{self.modified_files}"
)
if self.untracked_files:
self.repo_warnings.append(
f"Repo has untracked source files: {self.untracked_files}"
)
if len(self.managing_instances) > 1:
instances = "\n".join([f" {ins}" for ins in self.managing_instances])
self.repo_warnings.append(
f"Multiple instances of Moonraker managing this repo:\n"
f"{instances}"
)
self._generate_warn_msg()

def _generate_warn_msg(self) -> str:
extra_warnings = []
if self.untracked_files:
extra_warnings.append(
f"Repo has untracked source files: {self.untracked_files}"
)
ro_msg = f"Git Repo {self.alias}: No warnings detected"
if self.repo_warnings:
ro_msg = f"Git Repo {self.alias} Warnings Detected:\n"
ro_msg += "\n".join(self.repo_warnings)
warn_msg = ""
if self.repo_warnings or extra_warnings:
ro_msg = f"Git Repo {self.alias}: Warnings detected:\n"
warn_msg = "\n".join(
[f" {warn}" for warn in self.repo_warnings + extra_warnings]
)
ro_msg += warn_msg
self.server.add_log_rollover_item(f"umgr_{self.alias}_warn", ro_msg, log=False)
return warn_msg

def _verify_repo(self, check_remote: bool = False) -> None:
if not self.valid_git_repo:
Expand Down

0 comments on commit 871c551

Please sign in to comment.