mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-13 15:03:23 -05:00
fix: keep the contributors when the request fails
The contributors block is the only part of the README that comes from the network, and a refused request returned an empty list, which deleted the section. That happened during a pipeline run and the result was committed; the freshness check then regenerated the section and failed on the difference. An unavailable list now republishes the one already there and says so. Losing it is a worse answer than a stale one, and it makes an offline regeneration additive rather than destructive. Reverting the change and simulating the same outage empties the section again.
This commit is contained in:
1 parent
31b0cab1d3
commit
3a266be7a5
3 files changed
+102
-1
No files matched your search
@@ -126,6 +126,34 @@ RELEASE_URL = "../../releases/latest"
|
||||
REPO = "Abdess/retrobios"
|
||||
|
||||
|
||||
def _existing_contributor_block(readme_path: str = "README.md") -> list[str]:
|
||||
"""The contributors already published, read back from the file.
|
||||
|
||||
The section is the one part of this document that comes from the network.
|
||||
A refused or rate-limited request used to leave the list empty, which
|
||||
silently deleted the section from a published README and put the local
|
||||
result permanently at odds with what the freshness check regenerates.
|
||||
Keeping what is already there makes an offline run additive-only.
|
||||
"""
|
||||
try:
|
||||
with open(readme_path, encoding="utf-8") as handle:
|
||||
text = handle.read()
|
||||
except OSError:
|
||||
return []
|
||||
start = text.find("## Contributors")
|
||||
if start == -1:
|
||||
return []
|
||||
rest = text[start:].splitlines()
|
||||
block = []
|
||||
for line in rest[1:]:
|
||||
if line.startswith("## "):
|
||||
break
|
||||
block.append(line)
|
||||
while block and not block[-1].strip():
|
||||
block.pop()
|
||||
return ["## Contributors"] + block if block else []
|
||||
|
||||
|
||||
def fetch_contributors() -> list[dict]:
|
||||
"""Fetch contributors from GitHub API, exclude bots."""
|
||||
import urllib.error
|
||||
@@ -518,6 +546,13 @@ def generate_readme(db: dict, platforms_dir: str) -> str:
|
||||
)
|
||||
|
||||
contributors = fetch_contributors()
|
||||
if not contributors:
|
||||
# The request failed. Republish what is already there rather than
|
||||
# dropping the section: losing it is a worse answer than a stale list.
|
||||
kept = _existing_contributor_block("README.md")
|
||||
if kept:
|
||||
print("contributors: request failed, keeping the published list")
|
||||
lines.extend(kept + [""])
|
||||
if contributors:
|
||||
lines.extend(
|
||||
[
|
||||
|
||||
Reference in new issue
Block a user