feat: add LFS snapshot support to git strategy#191
Draft
joshfriend wants to merge 1 commit intomainfrom
Draft
Conversation
3a839c1 to
5b3f47d
Compare
Adds a parallel cachew-native LFS caching path alongside the primary
cigitcache integration. When lfs-snapshot-enabled = true in the git
strategy block, cachew runs git lfs fetch after each snapshot generation
and archives the resulting .git/lfs/ tree as a separate
lfs-snapshot.tar.zst, served at GET /git/{host}/{path}/lfs-snapshot.tar.zst.
The archive stores paths relative to .git/ (./lfs/objects/xx/yy/sha256)
so the blox client can extract it directly into the repo's .git/ directory.
Changes:
- snapshot.CreateSubdir: new helper that archives a named subdirectory
within a parent dir, preserving the subdir prefix in tar paths.
- Strategy.generateAndUploadLFSSnapshot: clones the mirror to a temp dir,
injects a short-lived GitHub App token into the remote URL, runs
git lfs fetch origin HEAD, then calls CreateSubdir on .git/lfs/.
- Strategy.handleLFSSnapshotRequest: serves cached LFS archives via the
existing serveCachedArtifact helper (304 / 200 / 404 behaviour).
- Config.LFSSnapshotEnabled: opt-in per-repo config flag (default false).
- Schedule LFS jobs on the same interval as git snapshots.
This is the fallback path for repos or branches not covered by cigitcache.
5b3f47d to
e7bd5c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
lfs-snapshot-enabled = truein the git strategy block, cachew generates a separate LFS object archive on each snapshot interval, served atGET /git/{host}/{path}/lfs-snapshot.tar.zst.After each git snapshot,
generateAndUploadLFSSnapshotclones the mirror into a temp dir, injects a short-lived GitHub App token, runsgit 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 existingserveCachedArtifacthelper with standard 200/304/404 behaviour.A new
snapshot.CreateSubdirhelper in the snapshot package supports archiving a named subdirectory within a parent directory while preserving the subdirectory prefix in tar paths.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.