mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
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]>
This commit is contained in:
3 files changed
+13
-2
No files matched your search
@@ -266,6 +266,9 @@ func sandbox(env *testscript.Env, bin, stubs string) error {
|
||||
// testscript starts from an environment of its own, but a script's git
|
||||
// never gets git's variables that pick a repo, whatever ran the tests.
|
||||
env.Vars = stubtest.GitEnv(env.Vars)
|
||||
// Nor the machine's system config, which differs between machines:
|
||||
// Apple's sets init.defaultBranch=main, CI runners' none.
|
||||
env.Setenv("GIT_CONFIG_NOSYSTEM", "1")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -233,11 +233,19 @@ func TestSeedConfig(t *testing.T) {
|
||||
t.Errorf("user.name %q", got)
|
||||
}
|
||||
local := gitIn(t, vm, "config", "--local", "--list")
|
||||
for _, never := range []string{"ghp_", "credential", "extraheader", "sshcommand", "alias", "filter", "insteadof", "remote.devvm", "remote.odd"} {
|
||||
for _, never := range []string{"ghp_", "credential", "extraheader", "sshcommand", "alias", "filter.crypt", "insteadof", "remote.devvm", "remote.odd"} {
|
||||
if strings.Contains(strings.ToLower(local), strings.ToLower(never)) {
|
||||
t.Errorf("%q in the VM's config:\n%s", never, local)
|
||||
}
|
||||
}
|
||||
// The only filter is git-lfs's, which the copy sets in the clone where
|
||||
// the VM has git-lfs (here, wherever the tests' PATH has it), never
|
||||
// one of this machine's.
|
||||
for line := range strings.Lines(strings.ToLower(local)) {
|
||||
if strings.HasPrefix(line, "filter.") && !strings.HasPrefix(line, "filter.lfs.") {
|
||||
t.Errorf("a filter of this machine's in the VM's config: %s", line)
|
||||
}
|
||||
}
|
||||
gitIn(t, vm, "commit", "-q", "--allow-empty", "-m", "hooked")
|
||||
if _, err := os.Stat(filepath.Join(vm, "hook-ran")); err != nil {
|
||||
t.Error("the pre-commit hook didn't run in the VM")
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ 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 'git -C "$STUB_DIR/vmfs$(pwd -P)" commit -q --allow-empty -m vm-own'
|
||||
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$'
|
||||
|
||||
Reference in new issue
Block a user