Files
bambuddy/backend
maziggy be17b62480 fix(backup): halve the provider round-trips, and stop losing commit metadata (#2656)
The three remaining review items, all in the read path.

    E1 — four provider calls where two would do. preview() called list_commits
    twice: once inside _resolve_ref to turn HEAD into a SHA, once more at limit=20
    purely to find the entry describing that same SHA. And list_tree's recursive
    tree GET was thrown away, so fetch_files immediately fetched the identical tree
    again to map path -> blob SHA. _resolve_ref now returns the entry it already
    has, and list_tree returns its blob_shas map for fetch_files to take as an
    optional argument. GitLab reads files by path and ignores it.

    E2 — `commit: null` for a ref outside the 20 most recent. Two causes, and the
    second is the one that actually bit: REF_PATTERN accepts a 7-character ref while
    providers return the full 40, so the exact `==` in the scan never matched an
    abbreviated SHA *even when the commit was in the window*. Fixed by prefix
    comparison, plus a get_commit(ref) on the GitHub and GitLab backends for the
    genuinely-outside-the-window case. Gitea and Forgejo inherit GitHub's. Still
    best-effort: it is a subject line and a date, so a failed lookup renders the
    preview without them rather than failing it.

    E7 — the two tree readers disagreed, and each was wrong in the other's
    direction. GitHub's recursive trees endpoint is not paginated and signals
    overflow with truncated=true, which _blob_shas_at hard-fails on. Gitea and
    Forgejo *do* page that endpoint, and inherited that single GET unchanged — so a
    large backup repo returned only the first page and every category beyond it
    looked absent from the commit. GiteaBackend now has its own paging
    _blob_shas_at. GitLab had the mirror-image bug the review did not name: at its
    50-page cap it exited through the while condition and returned success: True
    with a silently partial path list. Both now fail loudly, which is what the
    GitHub version was always doing.

    Both halves of E7 are the same failure the module already refuses to allow: a
    restore that skips categories and calls it "not present in this backup commit".

    24 new or changed tests, all failing against this commit's parent.
2026-08-15 14:13:51 +02:00
..