Repository navigation
Implement Git LFS backup and restore support - #5
Merged
Merged
Conversation
Fetch all LFS objects into the mirror when a new snapshot is due, pack lfs/objects into <stamp>.lfs.tar with the tar package and record its size in the manifest. Fail fast with exit 2 when git-lfs is missing unless LFS is disabled. Wikis and unchanged repositories skip LFS entirely. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0197EtXcoZj4YJKStpAyaxJH
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0197EtXcoZj4YJKStpAyaxJH
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.
Completes Phase 4 by adding full Git LFS object backup and restore functionality.
Summary
Repositories using Git LFS now have their LFS objects backed up alongside the git bundle. Each snapshot includes an
lfs.tararchive (when LFS objects exist) and a manifest field tracking its size. Restoration follows the documented process: clone the bundle, extract the tar into.git/lfs/objects, and rungit lfs checkout.Key Changes
Core LFS operations (
src/core/lfs.ts):fetchLfs(): Runsgit lfs fetch --all originin the mirror to download all LFS objectshasLfsObjects(): Detects whether the mirror contains any LFS objects (recursive directory scan)createLfsTar(): Creates a portable tar archive oflfs/objectsand returns its byte sizeBackup workflow (
src/core/run.ts):lfsTarBytesadded to manifest when LFS objects existputSnapshot()alongside bundle and manifestPrerequisites and configuration (
src/commands/backup.ts):checkLfs()function verifiesgit-lfsis installed before backup starts--no-lfsoption) if missing--no-lfsflag orGHBACKUP_LFS=falseenvironment variable is setBackupInput.lfsboolean controls whether LFS processing is enabledTesting:
test/unit/lfs.test.ts):hasLfsObjects()andfetchLfs()behaviortest/integration/lfs.test.ts): Full backup→restore cycle with LFS fileslfs.url=file://+lfs.standalonetransferagent=lfs-standalone-file) to avoid needing an LFS server--no-lfsflag, unchanged refs optimization, and wiki exclusiontest/unit/commands.test.ts): Prerequisite check and flag behaviorCI/CD (
.github/workflows/ci.yml):git-lfsis installed on Ubuntu runners before tests runDocumentation:
plans/faz-04-lfs.mdplans/mimari.mdwith LFS workflow detailsImplementation Details
LFS objects are fetched only when snapshot creation is triggered (when refs change), avoiding unnecessary LFS operations on unchanged repositories. The tar archive preserves the
lfs/objects/directory structure needed forgit lfs checkoutto work correctly. Manifest includeslfsTarBytesonly when LFS objects exist, keeping manifests clean for non-LFS repositories.https://claude.ai/code/session_0197EtXcoZj4YJKStpAyaxJH