Menú d'opcions: ocultar no descarregats i comprovar actualitzacions, amb persistència
This commit is contained in:
@@ -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).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user