Skip to content

feat: add LFS snapshot support to git strategy#191

Draft
joshfriend wants to merge 1 commit intomainfrom
jf/lfs-snapshot
Draft

feat: add LFS snapshot support to git strategy#191
joshfriend wants to merge 1 commit intomainfrom
jf/lfs-snapshot

Conversation

@joshfriend
Copy link
Contributor

@joshfriend joshfriend commented Mar 13, 2026

When lfs-snapshot-enabled = true in the git strategy block, cachew generates a separate LFS object archive on each snapshot interval, served at GET /git/{host}/{path}/lfs-snapshot.tar.zst.

After each git snapshot, generateAndUploadLFSSnapshot clones the mirror into a temp dir, injects a short-lived GitHub App token, runs git lfs fetch origin HEAD, then archives the resulting .git/lfs/ tree. Paths inside the archive are stored relative to .git/ (i.e. ./lfs/objects/xx/yy/sha256), so a client can extract directly into the repo's .git/ directory. The archive is served via the existing serveCachedArtifact helper with standard 200/304/404 behaviour.

A new snapshot.CreateSubdir helper in the snapshot package supports archiving a named subdirectory within a parent directory while preserving the subdirectory prefix in tar paths.

strategy "git" {
  snapshot-interval    = "1h"
  lfs-snapshot-enabled = true   # off by default; requires git-lfs and a configured GitHub App
}

LFS snapshot jobs run on the same periodic schedule as git snapshots and are registered for both newly cloned repos and repos discovered on startup.

@alecthomas alecthomas changed the title Add LFS snapshot support to git strategy feat: add LFS snapshot support to git strategy Mar 16, 2026
@joshfriend joshfriend force-pushed the jf/lfs-snapshot branch 14 times, most recently from c6c48bf to d582807 Compare March 18, 2026 18:14
When lfs-snapshot-enabled is true, cachew generates a separate LFS object
snapshot (lfs-snapshot.tar.zst) alongside the regular git snapshot. This
archives .git/lfs/objects/ after running git lfs fetch, and serves it at
GET /git/{repo}/lfs-snapshot.tar.zst.

Adds snapshot.CreateSubdir for archiving a named subdirectory with its
path prefix preserved in the tar. LFS snapshot jobs are scheduled on both
startup discovery and first clone of new repos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant