mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-14 05:53:47 -06:00
feat: move a config read at the pin with it
A profile following the branch tip (pin_follows) can carry a config_reads entry read at the build a platform installs, which is the pin itself: advmame's retropie entry reads advmame.rc at 96237a5. bump_commit now advances such a revision with source_commit, and leaves every other revision (another platform's build) alone.
This commit is contained in:
1 parent
cb7700a594
commit
114afee41b
2 files changed
+58
No files matched your search
@@ -3745,6 +3745,8 @@ def bump_commit(
|
||||
expected = dict(document)
|
||||
expected["source_commit"] = report.head
|
||||
new_text = _set_pin(text, document, "source_commit", report.head, "profiled_date")
|
||||
if document.get("pin_follows"):
|
||||
new_text, expected = _follow_config_reads(new_text, expected, document, report.head)
|
||||
if upstream_moves:
|
||||
expected["upstream_commit"] = report.upstream_head
|
||||
new_text = _set_pin(
|
||||
@@ -3801,6 +3803,28 @@ def cites_primary(report: ProfileReport) -> bool:
|
||||
return not parts or any(part.repo is None for part in parts)
|
||||
|
||||
|
||||
def _follow_config_reads(
|
||||
text: str, expected: dict, document: dict, head: str
|
||||
) -> tuple[str, dict]:
|
||||
"""A config_reads entry read at the pin moves with a pin that follows the
|
||||
branch tip: RetroPie installs advmame from the tip, so the build its
|
||||
advmame.rc is read at is the pin itself."""
|
||||
pin = str(document.get("source_commit") or "")
|
||||
reads = document.get("config_reads") or []
|
||||
if not pin or not any(isinstance(r, dict) and r.get("revision") == pin for r in reads):
|
||||
return text, expected
|
||||
text = re.sub(
|
||||
r'^(\s*revision:\s*)(["\']?)' + re.escape(pin) + r"\2\s*$",
|
||||
lambda m: f"{m.group(1)}{m.group(2)}{head}{m.group(2)}",
|
||||
text, flags=re.M,
|
||||
)
|
||||
expected = {**expected, "config_reads": [
|
||||
{**r, "revision": head} if isinstance(r, dict) and r.get("revision") == pin else r
|
||||
for r in reads
|
||||
]}
|
||||
return text, expected
|
||||
|
||||
|
||||
def _set_pin(text: str, document: dict, field: str, value: str, after: str) -> str:
|
||||
"""Write *field* as *value*, replacing its line or adding one after *after*."""
|
||||
current = document.get(field)
|
||||
|
||||
Reference in new issue
Block a user