From 347ec583e6e21c66b3f6586a936a73f91aa992a5 Mon Sep 17 00:00:00 2001 From: "K. Hodges" Date: Sun, 17 May 2026 16:13:25 -0700 Subject: [PATCH] actually show the logo --- nightshift/web.py | 9 ++++++++- tests/test_web.py | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/nightshift/web.py b/nightshift/web.py index 46c046a..b5bb4f6 100644 --- a/nightshift/web.py +++ b/nightshift/web.py @@ -156,7 +156,7 @@ def create_app(project_root: str | Path = ".", artifact_dir: str | Path = ".nigh @app.get("/assets/logo.png") def logo(): - logo_path = root / "docs" / "images" / "logo.png" + logo_path = _logo_path(root) if not logo_path.exists(): return Response(status=404) response = Response(logo_path.read_bytes(), mimetype="image/png") @@ -182,6 +182,13 @@ def _artifact_paths(run_path: Path) -> list[str]: return sorted(paths, key=lambda item: (priority.get(item, 10), item)) +def _logo_path(project_root: Path) -> Path: + project_logo = project_root / "docs" / "images" / "logo.png" + if project_logo.exists(): + return project_logo + return Path(__file__).resolve().parent.parent / "docs" / "images" / "logo.png" + + def _status_from_summary(summary: str) -> str: for line in summary.splitlines(): normalized = line.strip().lower() diff --git a/tests/test_web.py b/tests/test_web.py index 574450c..0ff0730 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -3,7 +3,7 @@ import tempfile import unittest from nightshift.artifacts import ArtifactStore -from nightshift.web import list_runs, read_artifact, render_dashboard +from nightshift.web import _logo_path, list_runs, read_artifact, render_dashboard class WebDashboardTests(unittest.TestCase): @@ -44,6 +44,10 @@ class WebDashboardTests(unittest.TestCase): self.assertIn("line 119", dashboard) self.assertNotIn("line 19\n", dashboard) + def test_logo_path_falls_back_to_repo_logo(self) -> None: + with tempfile.TemporaryDirectory() as directory: + self.assertTrue(_logo_path(Path(directory)).exists()) + if __name__ == "__main__": unittest.main()