mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-07 17:33:16 +02:00
refactor: update GitHub owner to openhop-dev and enhance changelog error handling
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user