mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
devvm --clone in a folder of git repos gives one VM a clone of each repo the user chooses, each at the same path as on the host, so paths between them (file:../pkg, ../Lib/Lib.csproj) work in the VM, and a copy of the folder's own files outside the repos, made once. - Discovery by .git protection's walk (4 folders down, the same skipped folders, 100 repos); each repo checked as --clone checks one; a linked worktree of a repo in the folder isn't a repo of its own; a repo whose folder, or common dir, another VM mounts is refused, naming it, as is one whose name a terminal can't show. A picker in a terminal (every copyable repo ticked, the others shown with why); --repos all|none|LIST answers without one, and the question is refused naming it. A folder that's a repo keeps today's single clone unless --repos is given; one inside another repo's working tree is refused (workspace_inside_repo). The choice is recorded in the VM's state. - A single --clone, or devvm clone on, in a folder another VM mounts is refused too (clone_folder_mounted), at plan time and before the seed's push. - Each repo seeded with its current and default branch (origin/HEAD, else main, else master); a detached HEAD checks out the default. One VM command makes every repo, leaving one an earlier push reached as it is; each repo is checked again just before its push, and its remote chosen once the one before is added. The folder's own repo's clone excludes the other clones (escaped, anchored lines) and the host's info/exclude, at the seed and at devvm clone add. - The folder's own files: walked folder by folder beneath the folder (safefile.Root.OpenDir), no links followed, no hard-linked files, no bare repos, no set-id bits, bounded; refused folders (checkUnsafe) apply. - devvm clone fetch [--json]: every repo's branches into its remote's remote-tracking branches (--refmap=, one refspec), listed by branch name with their repos; nothing new is said only when a repo was fetched from. devvm clone add PATH: one more repo; one whose copy didn't finish is copied again. - rm, devvm clone off and the switch loop over the repos; rm's check reads every repo in one VM command (cloneState), parsed strictly and capped (8 MiB, 10,000 branches in all), counting only worktrees inside the folder, a VM-side folder never made read as every repo gone; a clone missing in the VM is asked about, an unfinished repo checked when it's there; a host repo that changed refuses the check, and one another VM mounts, a single clone's too, gets no host git and is asked about; each repo is checked again before rm's fetch. - The finder opens a workspace clone VM inside one of its repos; --here still makes the repo's own. --repos's dependencies go through needs(), which now takes a first argument too (devvm clone on). - State is additive: clone.workspace, clone.repos, clone.made.files; a 0.1.0 clone reads as one repo at ".". CHANGELOG: an Unreleased section. Messages: flag_needs_flag, repos_value, repos_not_workspace, workspace_repo_unknown, workspace_pick_help, workspace_pick_cannot, workspace_reason_*, workspace_inside_repo, workspace_repos_past, workspace_skipped, workspace_repo_dropped, workspace_detached, copying_repo, uncommitted_not_copied_repos, workspace_ready, workspace_files_failed, workspace_files_skipped, unfetched_commits_in, clone_repo_dirty, clone_repo_gone, clone_repo_changed, clone_repo_mounted, clone_repo_unchecked, clone_folder_mounted, clone_check_repo_changed, fetch_before_delete_repos, no_terminal_fetch_repos, clone_fetch_*, fetching_repo, clone_fetched_*, clone_add_*, clone_added. Tests: TestDefaultBranch, TestBranchPlan, TestIsWorkspace, TestChooseRepos, TestPickRepos, TestFindRepos, TestRepoExcludes, TestWorkspaceFiles, TestCloneChangesAcrossRepos, TestFetchedByBranch, TestCloneRepos, TestV010CloneReadsAsOneRepo, TestCoversRepo, TestParseCloneState, TestCloneStateScript, TestWorktreePathPins, TestOpenDir; the clone_workspace, clone_workspace_repo, subfolder and nested_replaced scripts; fixture_v010_clone (0.1.0's web clone fetched, checked by rm, made a workspace clone by devvm clone add, switched off; its scratch switched on); the e2e clone section's cloneWorkspace. Co-Authored-By: Claude Opus 5.5 <[email protected]>
146 lines
5.2 KiB
Plaintext
146 lines
5.2 KiB
Plaintext
# devvm in a subfolder of a folder with a VM: it opens that VM in the
|
|
# subfolder, saying so; --here and --clone make the subfolder its own;
|
|
# stop acts on the parent's VM, naming it first; rm refuses it without a
|
|
# terminal. adopt doesn't look upward, and nothing does from a repo of
|
|
# its own below the parent's folder unless --parent. Commands that give
|
|
# the parent's VM more access are refused without a terminal.
|
|
mkdir $WORK/app/src/lib
|
|
cd $WORK/app
|
|
exec git init -q
|
|
exec devvm --network open
|
|
|
|
# The parent's VM, its shell in the subfolder.
|
|
cd $WORK/app/src/lib
|
|
stub_reset
|
|
exec devvm
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
! stdout creating
|
|
stub_calls
|
|
! stdout 'limactl (clone|create)'
|
|
stdout '^limactl shell --workdir /\S*/app/src/lib devvm-app-[0-9a-f]{14}\n\z'
|
|
exec sh -c 'ls "$VMS" | wc -l'
|
|
stdout '^ *1$'
|
|
|
|
# adopt is for this path's VM only.
|
|
! exec devvm adopt
|
|
stderr '^devvm: no_vm dir=/\S*/app/src/lib$'
|
|
|
|
# stop: the parent's, named first.
|
|
stub_reset
|
|
exec devvm stop
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}\n==> stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl stop devvm-app-[0-9a-f]{14}$'
|
|
|
|
# --here: a new VM for the subfolder, nothing asked; then it's the
|
|
# subfolder's own.
|
|
cd $WORK/app/src
|
|
exec devvm --here --network open
|
|
stdout '^==> creating_from image=base vm=devvm-src-[0-9a-f]{14}$'
|
|
! stdout using_parent_vm
|
|
stub_reset
|
|
exec devvm
|
|
! stdout using_parent_vm
|
|
stub_calls
|
|
stdout '^limactl shell --workdir /\S*/app/src devvm-src-[0-9a-f]{14}\n\z'
|
|
|
|
# The nearest folder with a VM wins.
|
|
cd $WORK/app/src/lib
|
|
exec devvm stop
|
|
stdout '^==> using_parent_vm dir=/\S*/app/src vm=devvm-src-[0-9a-f]{14}$'
|
|
|
|
# A repo of its own below the parent's folder: other commands find no VM,
|
|
# and devvm makes the subfolder's own. --parent takes the parent's
|
|
# across the repo.
|
|
mkdir $WORK/app/tool/bin
|
|
cd $WORK/app/tool
|
|
exec git init -q
|
|
cd $WORK/app/tool/bin
|
|
! exec devvm stop
|
|
stderr '^devvm: no_vm dir=/\S*/app/tool/bin$'
|
|
! stdout using_parent_vm
|
|
stub_reset
|
|
exec devvm --parent
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl shell --workdir /\S*/app/tool/bin devvm-app-[0-9a-f]{14}\n\z'
|
|
exec devvm stop --parent
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}\n==> stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm --network open
|
|
stdout '^==> creating_from image=base vm=devvm-bin-[0-9a-f]{14}$'
|
|
! stdout using_parent_vm
|
|
|
|
# Once it has its own: --parent passes over it, --here keeps to it, and
|
|
# the two don't go together.
|
|
exec devvm stop --parent
|
|
stdout '^==> already_stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm stop --here
|
|
! stdout using_parent_vm
|
|
stdout '^==> stopped vm=devvm-bin-[0-9a-f]{14}$'
|
|
! exec devvm stop --here --parent
|
|
stderr '^devvm: flags_exclusive flag=--here other=--parent$'
|
|
! exec devvm --clone --parent
|
|
stderr '^devvm: flags_exclusive flag=--clone other=--parent$'
|
|
! exec devvm rm devvm-bin-0123456789abcd --here
|
|
stderr '^devvm: rm_vm_folder_flag flag=--here$'
|
|
exec devvm rm --force --no-export
|
|
|
|
# --parent where no folder above has a VM.
|
|
cd $WORK/app
|
|
! exec devvm stop --parent
|
|
stderr '^devvm: no_parent_vm dir=/\S*/app$'
|
|
|
|
# --clone: the subfolder's own repo's VM, as --here, never the parent's.
|
|
mkdir $WORK/app/repo
|
|
cd $WORK/app/repo
|
|
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
|
|
exec git commit -q --allow-empty -m one
|
|
# The parent's VM mounts the repo, so its seed's host git could be swapped
|
|
# from there: refused before anything is made, naming that VM.
|
|
! exec devvm --clone --network open
|
|
stderr '^devvm: clone_folder_mounted dir=/\S*/app/repo vm=devvm-app-[0-9a-f]{14}$'
|
|
! stdout 'using_parent_vm|creating_from'
|
|
|
|
# rm: never a parent's without asking. Without a terminal it's refused,
|
|
# --force or not, and nothing is deleted; in the parent's folder it goes.
|
|
cd $WORK/app/src
|
|
exec devvm rm --force
|
|
cd $WORK/app/src/lib
|
|
|
|
# Commands that give a parent's VM more access are refused without a
|
|
# terminal, naming the VM and its folder, and change nothing.
|
|
! exec devvm secret use github
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm secret use dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
! exec devvm ssh-agent on
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm ssh-agent on dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm ssh-agent
|
|
stdout '^off$'
|
|
! exec devvm network allow example.com
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm network allow dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm network deny bad.example.com
|
|
stdout 'rule_added'
|
|
! exec devvm network rm '!bad.example.com'
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm network rm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
vm_name APP app
|
|
exec cat $APP_dir/policy
|
|
stdout '!bad.example.com'
|
|
! stdout '^example.com'
|
|
|
|
stub_reset
|
|
! exec devvm rm --force --no-export
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stderr '^devvm: rm_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl delete'
|
|
exec sh -c 'ls "$VMS" | grep -v "\.policy$" | wc -l'
|
|
stdout '^ *1$'
|
|
cd $WORK/app
|
|
exec devvm rm --force
|
|
stdout '^==> deleted vm=devvm-app-[0-9a-f]{14}$'
|
|
exec ls $VMS
|
|
! stdout .
|
|
cd $WORK/app/src/lib
|
|
! exec devvm rm --force
|
|
stderr '^devvm: no_vm dir=/\S*/app/src/lib$'
|