Skip to content

self_update

Best-effort self-update: git pull the installed checkout on every launch.

self_update()

Fast-forward the installed git checkout, if any, before the app starts.

Source code in src/personal_os_setup/tasks/self_update.py
def self_update() -> None:
    """Fast-forward the installed git checkout, if any, before the app starts."""
    repo_root = _find_repo_root()
    if repo_root is None:
        return

    try:
        result = subprocess.run(
            ["git", "-C", str(repo_root), "pull", "--ff-only"],
            check=False,
            capture_output=True,
            text=True,
            timeout=10,
        )
    except (OSError, subprocess.TimeoutExpired) as exc:
        logger.debug(f"self-update skipped: {exc}")
        return

    if result.returncode != 0:
        logger.debug(f"self-update skipped: {result.stderr.strip()}")
        return

    if "Already up to date" not in result.stdout:
        print(f"personal-os-setup updated: {result.stdout.strip()}")