Menú d'opcions: ocultar no descarregats i comprovar actualitzacions, amb persistència

This commit is contained in:
2026-05-29 21:29:12 +02:00
parent 9d13c2434b
commit 235a3966d2
7 changed files with 200 additions and 6 deletions
+24
View File
@@ -52,6 +52,30 @@ def is_installed(root: Path, game: Game) -> bool:
return (repo_dir(root, game.id) / ".git").exists()
def check_update(root: Path, game: Game, log: LogFn = _noop) -> bool:
"""Hace fetch y devuelve True si el clone local está por detrás del remoto.
No modifica el árbol de trabajo: solo cuenta los commits de origin/<rama> que no
están en HEAD. Devuelve False si el juego no está descargado.
"""
repo = repo_dir(root, game.id)
if not (repo / ".git").exists():
return False
_run_git(["fetch", "origin", "--prune"], repo, log)
target = (
load_meta(root, game.id).default_branch
or _detect_origin_head(repo, log)
or "HEAD"
)
try:
behind = _run_git(
["rev-list", "--count", f"HEAD..origin/{target}"], repo, log
)
except RuntimeError:
return False
return int(behind or "0") > 0
def download(root: Path, game: Game, log: LogFn = _noop) -> GameMeta:
"""Clona (si no existe) o trae el remoto forzado (descartando cambios locales).