refactor: update GitHub owner to openhop-dev and enhance changelog error handling

This commit is contained in:
Lloyd
2026-06-25 21:39:08 +01:00
parent 42cd75e6b0
commit 27ccf5453d
2 changed files with 26 additions and 6 deletions
+10 -6
View File
@@ -41,7 +41,7 @@ logger = logging.getLogger("HTTPServer")
# ---------------------------------------------------------------------------
# Repository constants
# ---------------------------------------------------------------------------
GITHUB_OWNER = "rightup"
GITHUB_OWNER = "openhop-dev"
GITHUB_REPO = "openhop-repeater"
GITHUB_RAW_BASE = f"https://raw.githubusercontent.com/{GITHUB_OWNER}/{GITHUB_REPO}"
GITHUB_API_BASE = f"https://api.github.com/repos/{GITHUB_OWNER}/{GITHUB_REPO}"
@@ -699,11 +699,10 @@ def _fetch_latest_version(channel: str) -> str:
def _fetch_changelog(channel: str, installed: str, max_commits: int = 50) -> List[dict]:
base_tag = _get_latest_tag()
installed_dev = _parse_dev_number(installed)
try:
base_tag = _get_latest_tag()
installed_dev = _parse_dev_number(installed)
if _branch_is_dynamic(channel):
compare_url = f"{GITHUB_API_BASE}/compare/{base_tag}...{channel}?per_page=100"
else:
@@ -1335,7 +1334,12 @@ class UpdateAPIEndpoints:
installed = snap["current_version"]
latest = snap["latest_version"] or ""
commits = _fetch_changelog(channel, installed, max_commits)
try:
commits = _fetch_changelog(channel, installed, max_commits)
except Exception as exc:
logger.warning(f"[Update] Changelog endpoint fallback due to GitHub error: {exc}")
commits = []
return self._ok(
{
"channel": channel,
+16
View File
@@ -250,6 +250,22 @@ def test_channels_set_channel_and_changelog(cherrypy_ctx, isolated_state, monkey
assert c["commits"][0]["title"] == "t"
def test_changelog_guard_when_github_unavailable(cherrypy_ctx, isolated_state, monkeypatch):
request, _ = cherrypy_ctx
request.method = "GET"
api = ue.UpdateAPIEndpoints()
def _raise_fetch(*_args, **_kwargs):
raise RuntimeError("HTTP Error 404: Not Found")
monkeypatch.setattr(ue, "_fetch_changelog", _raise_fetch)
out = api.changelog(channel="dev", max="5")
assert out["success"] is True
assert out["channel"] == "dev"
assert out["commits"] == []
def test_cors_headers_and_error_helpers(cherrypy_ctx):
_, response = cherrypy_ctx
api = ue.UpdateAPIEndpoints()