mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
A --clone VM's clone is now seeded with a snapshot, not git push, and gets everything a working copy has. devvm clone fetch brings it all back, and devvm rm and clone off check it before deleting. - Refs: every branch, tag and notes ref, and a detached HEAD. - Uncommitted changes: staged, unstaged and untracked files; files skip-worktree by hand get the index's version, named. - Operations in progress (merge, rebase, cherry-pick, revert, bisect) and the stash; a stash's untracked part goes as its own branch. - The repo's settings and hooks, sent as settings only where they live in the repo (husky); ORIG_HEAD never goes. - Partial clones, with their promisor remote, and messages per network tier when it can't be reached. - Initialised submodules, nested ones too, each with a clone of its own; a submodule's own folder is refused as a top-level --clone. vm.json gains an optional `submodules` field. - Git LFS both ways: objects hash-checked, written under os.Root with no link followed, a question past 2 GiB; the filter is set only in the clone's repos; git-lfs 3.8.1 in base, pinned by SHA-256. - rm and clone off keep the VM when anything the VM has didn't come back, and name it. - Every shell script embedded in Go is shellchecked. - clone.md is a guide that leads with commands; TestUserPageProse covers it and coding-agents.md. After you upgrade: base and every image on it build again once, for git-lfs. Fixes #40, reported by @Josuesp1620. Thanks to @dhruv1220 for #42, which found the cause (receive-pack refusing a shallow push); its receive.shallowUpdate setting stays in the VM's repos. Co-authored-by: Dhruv Arora <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
55 lines
3.4 KiB
Plaintext
55 lines
3.4 KiB
Plaintext
# --clone of a partial clone (git clone --filter=blob:none): its clone in
|
|
# the VM has what it has, in a promisor pack, with its promisor remote,
|
|
# whose git fetches the rest when it needs it. devvm says when the VM
|
|
# can't: a promisor on this machine (a file:// URL), or a host the VM's
|
|
# network policy blocks. A partial plus sparse clone is copied too.
|
|
# (The stubs keep the VM's files in $STUB_DIR/vmfs.)
|
|
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
|
|
exec git init -q -b main $WORK/src
|
|
exec sh -c 'cd "$WORK/src" && echo old > old && mkdir a b && echo a > a/f && echo b > b/f && git add . && git commit -qm one && git rm -q old && git commit -qm two'
|
|
exec git -C $WORK/src config uploadpack.allowFilter true
|
|
|
|
# A promisor on this machine: copied, and named, as the VM can't reach it.
|
|
exec git clone -q --filter=blob:none file://$WORK/src $WORK/web
|
|
cd $WORK/web
|
|
exec devvm --clone --network open
|
|
stderr '^devvm: clone_partial_unreachable dir=/\S*/web remote=origin url=file:///\S*/src$'
|
|
stdout '^==> clone_ready branch=main remote=devvm$'
|
|
exec sh -c 'c="$STUB_DIR/vmfs$(pwd -P)"; git -C "$c" log --format=%s && git -C "$c" config remote.origin.promisor && ls "$c"/.git/objects/pack/*.promisor >/dev/null && git -C "$c" status --porcelain && echo ok'
|
|
stdout '^two\none\ntrue\nok$'
|
|
|
|
# Work in the VM that names a blob neither side has doesn't come back, as
|
|
# the VM's upload-pack fetches nothing to send it: devvm says what to do.
|
|
exec sh -c 'c="$STUB_DIR/vmfs$(pwd -P)"; b=$(git -C "$WORK/src" rev-parse HEAD~1:old) && t=$(printf "100644 blob %s\tcopy\n" "$b" | git -C "$c" mktree --missing) && x=$(git -C "$c" commit-tree "$t" -p HEAD -m needs) && git -C "$c" update-ref refs/heads/needs "$x"'
|
|
! exec devvm clone fetch
|
|
stderr '^devvm: clone_fetch_partial path=\.$'
|
|
exec devvm rm --force --no-export --no-clone-check
|
|
|
|
# A promisor the VM's allowlist doesn't have: named, with how to allow it.
|
|
# Sparse too: only a/ is checked out, here and in the VM.
|
|
exec git clone -q --filter=blob:none --sparse file://$WORK/src $WORK/app
|
|
cd $WORK/app
|
|
exec git sparse-checkout set a
|
|
exec git remote set-url origin https://git.example.com/x/src.git
|
|
exec devvm --clone --network allowlist
|
|
stderr '^devvm: clone_partial_blocked dir=/\S*/app host=git\.example\.com remote=origin$'
|
|
exec sh -c 'c="$STUB_DIR/vmfs$(pwd -P)"; test -e "$c/a/f" && test ! -e "$c/b/f" && git -C "$c" status --porcelain && echo sparse'
|
|
stdout '^sparse$'
|
|
exec devvm rm --force --no-export --no-clone-check
|
|
|
|
# A folder of repos with a partial clone in it, on the none tier: the
|
|
# partial one is copied, named with how to reach its promisor; a promisor
|
|
# remote that stays (a URL of a kind devvm doesn't copy) is named.
|
|
mkdir $WORK/ws
|
|
exec git clone -q --filter=blob:none file://$WORK/src $WORK/ws/part
|
|
exec git -C $WORK/ws/part remote set-url origin https://git.example.com/x/src.git
|
|
exec git clone -q --filter=blob:none file://$WORK/src $WORK/ws/odd
|
|
exec git -C $WORK/ws/odd remote set-url origin 'ext::sh -c x'
|
|
cd $WORK/ws
|
|
exec devvm --clone --repos all --network none
|
|
stderr '^devvm: clone_partial_blocked_none dir=/\S*/ws/part host=git\.example\.com remote=origin$'
|
|
stderr '^devvm: clone_partial_promisor_kept count=1 dir=/\S*/ws/odd remotes="origin"$'
|
|
exec sh -c 'c="$STUB_DIR/vmfs$(pwd -P)"; git -C "$c/part" config remote.origin.promisor && git -C "$c/part" log --format=%s'
|
|
stdout '^true\ntwo\none$'
|
|
exec devvm rm --force --no-export --no-clone-check
|