mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
A global --no-input (persistent on the root, with --help and -v): no question is asked or read. The ui's prompts (Ask, Confirm, Answer, Secret, Pick/PickOne in a terminal) show the question, then fail with no_input naming what answers it (msg.AnswerFor, by the question's ID), or no_input_terminal for a question only a terminal answers. ui.Flags and SetFlags carry -v and --no-input. Answers: --network-policy/--no-network-policy, --here, devvm size -g, devvm setup --features/--backend, devvm network -g, devvm ssh-agent add, devvm restart, --ssh-config (new, on devvm, host and code: the Include line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude), --stdin, and --force. --force (-f) only skips a confirmation, and destructive commands need it without a terminal (force_needed, a failure, not a usage error): rm (new rm_confirm), gc (it went ahead without a terminal), gc --caches (now allowed without a terminal with --force), images rm (images_rm_confirm), secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images are built on the one rebuilt (build.Env.Force). rm --no-export skips the export; rm's parent-folder, earlier-folder and --clone confirmations are terminal-only and --force never answers them (vm.RmOptions). gc --tools --force splits: --recent (only with --tools, gc_recent_needs_tools) drops the hour's hold and keeps the refusal while a VM is being made (gc_recent_making); gc_tools_recent names devvm gc --tools --recent. gc_caches_need_terminal goes. Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt (--force), TestRebuild (force_needed, then Force); secret, rebuild, images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images rm/secret rm/rebuild with --force (and --no-export where rm -f skipped the export), and the clone section's rm with its checks. Docs: commands.md (Questions devvm asks, rm, flags), first-vm, clone, images (cleaning up, --recent), space, coding-agents, internals overview and images; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
108 lines
3.8 KiB
Plaintext
108 lines
3.8 KiB
Plaintext
# devvm git-protect: shows a folder's VM's .git protection, and turns it on,
|
|
# strict or off while the VM is stopped. Strict also keeps host git status
|
|
# and diff out of submodules (diff.ignoreSubmodules=all in .git/config).
|
|
# Locks need macOS: elsewhere on and strict are refused. The chflags stub
|
|
# changes no flags.
|
|
env DEVVM_MESSAGES=names
|
|
env VMS=$XDG_DATA_HOME/devvm/vms
|
|
|
|
# No VM yet.
|
|
mkdir $WORK/web
|
|
cd $WORK/web
|
|
! exec devvm git-protect
|
|
stderr '^devvm: no_vm_git_protect dir=\S*/web$'
|
|
! exec devvm git-protect maybe
|
|
stderr '^devvm: arg_not_choice choices=on, strict, off command=devvm git-protect given=maybe$'
|
|
|
|
# A new VM, running: shown, but not changed on macOS (it could race the
|
|
# locks); elsewhere off, and on is refused.
|
|
exec git init -q
|
|
exec devvm --no-network-policy base
|
|
exec devvm git-protect
|
|
[darwin] stdout '\Aon\n\z'
|
|
[linux] stdout '\Aoff\n\z'
|
|
[darwin] ! exec devvm git-protect off
|
|
[darwin] stderr '^devvm: git_protect_running vm=devvm-web-[0-9a-f]{14}$'
|
|
[linux] exec devvm git-protect off
|
|
[linux] stdout '^==> git_unlocked vm=devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm git-protect strict
|
|
[darwin] stderr '^devvm: git_protect_running vm=devvm-web-[0-9a-f]{14}$'
|
|
[linux] stderr '^devvm: git_protect_on_needs_macos$'
|
|
[linux] stop 'no locks off macOS'
|
|
|
|
# Stopped: strict sets diff.ignoreSubmodules with .git/config unlocked,
|
|
# then locks .git again.
|
|
exec sh -c 'limactl stop "$(basename "$VMS"/devvm-web-*)"'
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm git-protect strict
|
|
stdout '^==> git_locked_strict vm=devvm-web-[0-9a-f]{14}$'
|
|
exec git config --file .git/config diff.ignoreSubmodules
|
|
stdout '\Aall\n\z'
|
|
stub_calls
|
|
stdout '^chflags -R -P nouchg /\S*/web/\.git/config\n(.*\n)*chflags -R -P uchg /\S*/web/\.git/config$'
|
|
stdout '^chflags -R -P uchg /\S*/web/\.git/hooks$'
|
|
! stdout 'limactl (start|edit)'
|
|
exec devvm git-protect
|
|
stdout '\Astrict\n\z'
|
|
exec devvm git-protect --json
|
|
stdout '\A{\n "version": 1,\n "mode": "strict"\n}\n\z'
|
|
! exec devvm git-protect --json off
|
|
stderr '^devvm: json_shows_only command=devvm git-protect$'
|
|
exec sh -c 'cat "$VMS"/devvm-web-*'
|
|
stdout '^git_protect=strict$'
|
|
stdout '^git_inode=[0-9]+$'
|
|
|
|
# On takes diff.ignoreSubmodules back out.
|
|
exec devvm git-protect on
|
|
stdout '^==> git_locked vm=devvm-web-[0-9a-f]{14}$'
|
|
! exec git config --file .git/config diff.ignoreSubmodules
|
|
|
|
# Off unlocks, and takes it out too; a launch then locks nothing.
|
|
exec devvm git-protect strict
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm git-protect off
|
|
stdout '^==> git_unlocked vm=devvm-web-[0-9a-f]{14}$'
|
|
! exec git config --file .git/config diff.ignoreSubmodules
|
|
stub_calls
|
|
stdout '^chflags -R -P nouchg /\S*/web/\.git/hooks$'
|
|
stdout '^chflags -R -P nouchg /\S*/web/\.git/config$'
|
|
! stdout ' uchg '
|
|
exec devvm git-protect
|
|
stdout '\Aoff\n\z'
|
|
exec sh -c 'limactl stop "$(basename "$VMS"/devvm-web-*)"'
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
! stdout chflags
|
|
|
|
# --no-git-protect on an existing VM names devvm git-protect off.
|
|
exec devvm --no-git-protect
|
|
stderr '^devvm: git_protect_flag_ignored$'
|
|
|
|
# Strict is kept on launches, and rm unlocks it.
|
|
exec sh -c 'limactl stop "$(basename "$VMS"/devvm-web-*)"'
|
|
exec devvm git-protect strict
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
stdout '^chflags -R -P uchg /\S*/web/\.git/config$'
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm rm --force --no-export
|
|
stub_calls
|
|
stdout '^chflags -R -P nouchg /\S*/web/\.git/config$'
|
|
|
|
# Without a .git yet: locked when one appears.
|
|
mkdir $WORK/nogit
|
|
cd $WORK/nogit
|
|
exec devvm --no-network-policy base
|
|
exec sh -c 'limactl stop "$(basename "$VMS"/devvm-nogit-*)"'
|
|
exec devvm git-protect on
|
|
stdout '^==> git_lock_later vm=devvm-nogit-[0-9a-f]{14}$'
|
|
|
|
# A --clone VM mounts no .git: shown as clone, never changed.
|
|
exec sh -c 'echo mode=clone >> "$(ls "$VMS"/devvm-nogit-*)"'
|
|
exec devvm git-protect
|
|
stdout '\Aclone\n\z'
|
|
! exec devvm git-protect on
|
|
stderr '^devvm: git_protect_clone vm=devvm-nogit-[0-9a-f]{14}$'
|