Files
devvm/testdata/script/clone_uncommitted_retry.txtar
w3cjandClaude Opus 5.5 4f99e40731 test(clone): don't depend on the machine's git-lfs or system git config
CI (run 43285988512, at 9535110f) failed two tests that pass on a Mac
with Apple's git and no git-lfs:

- TestSeedConfig found "filter" in the VM's config. With git-lfs on
  PATH, as on GitHub's runners, the seed's own per-clone
  git lfs install --local --skip-repo writes filter.lfs.*, which is
  what the copy is meant to do. The check now looks for this machine's
  filter (filter.crypt) and allows only filter.lfs.* besides. Reproduced
  with git-lfs 3.8.1 on PATH; passes with and without it.
- clone_uncommitted_retry wanted clone_kept_branches. That has nothing
  to do with LFS: after the failed first copy, the VM's repo is empty,
  and the script's git commit landed on the VM git's default branch.
  Apple's system gitconfig sets init.defaultBranch=main, so locally it
  was main, which the retry keeps (clone_kept_branches); on the runners
  it's master, so main was set as copied and only HEAD stayed
  (clone_kept_head). Reproduced with GIT_CONFIG_NOSYSTEM=1, which now
  fails the old script locally exactly as CI did. The script now puts
  the VM's HEAD on main before it commits, and every testscript runs
  with GIT_CONFIG_NOSYSTEM=1, so a machine's system config can't change
  what a script's git does.

The gate passes twice, with git-lfs 3.8.1 first on PATH and without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 12:30:46 -07:00

56 lines
2.1 KiB
Plaintext

# A copy of uncommitted changes that runs again after a failed one. The
# VM's own file at a path changed here stays, and devvm names it, though
# the path differs here too. A VM that committed on its branch keeps its
# HEAD, so the changes here, which would apply to something else, aren't
# copied, and devvm says so instead of naming the ones it would have
# left out. (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
# The VM writes b, which is changed here, between the tries.
cd $WORK/web
exec git init -q -b main
exec git add .
exec git commit -q -m one
exec sh -c 'echo host > b && rm a && mkdir a && echo x > a/f'
exec sh -c 'echo index-pack > "$STUB_DIR/shell-fails-on"'
! exec devvm --clone --network open
stderr '^devvm: clone_seed_failed vm=devvm-web-[0-9a-f]{14}$'
rm $STUB_DIR/shell-fails-on
exec sh -c 'echo the-vms > "$STUB_DIR/vmfs$(pwd -P)/b"'
exec devvm
stderr '^devvm: clone_kept_files count=1 dir=/\S*/web files="b"$'
stderr '^devvm: clone_typechange_kept count=1 dir=/\S*/web files="a"$'
! stderr 'clone_uncommitted_kept'
exec sh -c 'cat "$STUB_DIR/vmfs$(pwd -P)/b"'
stdout '^the-vms$'
exec devvm rm --force --no-export --no-clone-check
# The VM commits on main between the tries: its HEAD and branch stay, and
# the changes here aren't copied.
cd $WORK/app
exec git init -q -b main
exec git add .
exec git commit -q -m one
exec sh -c 'echo host > b && rm a && mkdir a && echo x > a/f'
exec sh -c 'echo index-pack > "$STUB_DIR/shell-fails-on"'
! exec devvm --clone --network open
rm $STUB_DIR/shell-fails-on
exec sh -c 'c="$STUB_DIR/vmfs$(pwd -P)"; git -C "$c" symbolic-ref HEAD refs/heads/main && git -C "$c" commit -q --allow-empty -m vm-own'
exec devvm
stderr '^devvm: clone_kept_branches '
stderr '^devvm: clone_uncommitted_kept dir=/\S*/app$'
! stderr 'clone_typechange_kept|clone_filtered_kept'
exec sh -c 'c="$STUB_DIR/vmfs$(pwd -P)"; git -C "$c" log --format=%s -1; test -e "$c/b" || echo no-b'
stdout '^vm-own$'
stdout '^no-b$'
exec devvm rm --force --no-export --no-clone-check
-- web/a --
a
-- web/b --
b
-- app/a --
a
-- app/b --
b