test: fixtures commit with maintenance.auto=false before every git worktree add (wy-7ocweu) (#7358)
Fixes #7349. The same race #7314 closed in internal/beads and
internal/config, in the fixtures it did not cover: a fixture's plain
`git commit` spawns the detached `git maintenance run --auto` child, whose
worktree-prune races the fixture's next `git worktree add` and deletes
.git/worktrees/<name>/locked under it (seen on PR #7312 run 37585997441,
cmd/bd Dolt-server tier shard 4/16, TestBootstrap_WorktreeFallbackDir).
One noAutoMaintenance + gitCommand(args...) helper per test package, each
in an existing untagged shared test file (cmd/bd/helpers_test.go,
doctor/git_test_helpers_test.go, doctor/fix/common_test.go,
formula/parser_test.go, git/gitdir_test.go, storage/domain/git/git_test.go;
cmd/bd/test_helpers_test.go is //go:build cgo so unusable for the pure
lane), and every inline exec.Command("git", ...) in those six packages
swapped for it. The flags ride the command line, never env config: the
routing-key scrub drops env config. No new files, so no BUILD.bazel rows.
Proof: GIT_TRACE on `go test ./cmd/bd -run TestBootstrap_WorktreeFallbackDir`
counts 3 `maintenance run --auto` spawns at d8d8bf587b and 0 with this
change.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
2e6289f9fb
commit
3571331b50
73 changed files with 367 additions and 342 deletions
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -40,7 +39,7 @@ func TestGetActorWithGit(t *testing.T) {
|
|||
|
||||
// Helper to get current git user.name (may be empty if not configured)
|
||||
getGitUserName := func() string {
|
||||
out, err := exec.Command("git", "config", "user.name").Output()
|
||||
out, err := gitCommand("config", "user.name").Output()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package main
|
|||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -102,7 +101,7 @@ func TestBackupDir_UsesWorktreeFallback(t *testing.T) {
|
|||
|
||||
run := func(dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -119,13 +118,13 @@ func TestBackupDir_UsesWorktreeFallback(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -110,13 +110,13 @@ func TestEmbeddedBootstrap(t *testing.T) {
|
|||
|
||||
t.Run("bootstrap_dry_run_fresh", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
cmd := exec.Command("git", "init", "-q")
|
||||
cmd := gitCommand("init", "-q")
|
||||
cmd.Dir = dir
|
||||
cmd.CombinedOutput()
|
||||
cmd = exec.Command("git", "config", "user.name", "Test")
|
||||
cmd = gitCommand("config", "user.name", "Test")
|
||||
cmd.Dir = dir
|
||||
cmd.CombinedOutput()
|
||||
cmd = exec.Command("git", "config", "user.email", "test@test.com")
|
||||
cmd = gitCommand("config", "user.email", "test@test.com")
|
||||
cmd.Dir = dir
|
||||
cmd.CombinedOutput()
|
||||
// Create .beads with metadata.json so FindBeadsDir detects it
|
||||
|
|
@ -134,13 +134,13 @@ func TestEmbeddedBootstrap(t *testing.T) {
|
|||
|
||||
t.Run("bootstrap_init", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
cmd := exec.Command("git", "init", "-q")
|
||||
cmd := gitCommand("init", "-q")
|
||||
cmd.Dir = dir
|
||||
cmd.CombinedOutput()
|
||||
cmd = exec.Command("git", "config", "user.name", "Test")
|
||||
cmd = gitCommand("config", "user.name", "Test")
|
||||
cmd.Dir = dir
|
||||
cmd.CombinedOutput()
|
||||
cmd = exec.Command("git", "config", "user.email", "test@test.com")
|
||||
cmd = gitCommand("config", "user.email", "test@test.com")
|
||||
cmd.Dir = dir
|
||||
cmd.CombinedOutput()
|
||||
beadsDir := filepath.Join(dir, ".beads")
|
||||
|
|
@ -176,13 +176,13 @@ func TestEmbeddedBootstrap(t *testing.T) {
|
|||
|
||||
// Create new dir with .beads + issues.jsonl but no database
|
||||
dir := t.TempDir()
|
||||
gitCmd := exec.Command("git", "init", "-q")
|
||||
gitCmd := gitCommand("init", "-q")
|
||||
gitCmd.Dir = dir
|
||||
gitCmd.CombinedOutput()
|
||||
gitCmd = exec.Command("git", "config", "user.name", "Test")
|
||||
gitCmd = gitCommand("config", "user.name", "Test")
|
||||
gitCmd.Dir = dir
|
||||
gitCmd.CombinedOutput()
|
||||
gitCmd = exec.Command("git", "config", "user.email", "test@test.com")
|
||||
gitCmd = gitCommand("config", "user.email", "test@test.com")
|
||||
gitCmd.Dir = dir
|
||||
gitCmd.CombinedOutput()
|
||||
destBeads := filepath.Join(dir, ".beads")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -24,7 +23,7 @@ func TestBootstrap_WorktreeFallbackDir(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -42,13 +41,13 @@ func TestBootstrap_WorktreeFallbackDir(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
@ -111,7 +110,7 @@ func TestBootstrap_WorktreeLocalBeadsPreferLocal(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -127,13 +126,13 @@ func TestBootstrap_WorktreeLocalBeadsPreferLocal(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
@ -181,7 +180,7 @@ func TestBootstrap_WorktreeNoBeadsAnywhereStillPointsToMainRepo(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -197,13 +196,13 @@ func TestBootstrap_WorktreeNoBeadsAnywhereStillPointsToMainRepo(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -245,7 +244,7 @@ func TestIssueIDCompletion_UsesWorktreeFallbackWhenStoreNil(t *testing.T) {
|
|||
|
||||
run := func(dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -262,13 +261,13 @@ func TestIssueIDCompletion_UsesWorktreeFallbackWhenStoreNil(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -266,7 +265,7 @@ func TestProxiedServerConfig(t *testing.T) {
|
|||
t.Errorf("beads.role set should not advance HEAD: before=%s after=%s", before, after)
|
||||
}
|
||||
|
||||
gitCmd := exec.Command("git", "config", "--get", "beads.role")
|
||||
gitCmd := gitCommand("config", "--get", "beads.role")
|
||||
gitCmd.Dir = p.dir
|
||||
out, err := gitCmd.Output()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
|
@ -454,7 +453,7 @@ func TestCollectGitConfigEntriesIgnoresInheritedRouting(t *testing.T) {
|
|||
pinJSONOutput(t, false)
|
||||
runGit := func(t *testing.T, repo string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repo
|
||||
cmd.Env = gitenv.ScrubRouting(os.Environ())
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
|
@ -221,14 +220,14 @@ func TestBeadsRoleGitConfig(t *testing.T) {
|
|||
tmpDir := newGitRepo(t)
|
||||
|
||||
t.Run("set contributor role writes to git config", func(t *testing.T) {
|
||||
cmd := exec.Command("git", "config", "beads.role", "contributor")
|
||||
cmd := gitCommand("config", "beads.role", "contributor")
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config set failed: %v", err)
|
||||
}
|
||||
|
||||
// Verify it's readable from git config
|
||||
cmd = exec.Command("git", "config", "--get", "beads.role")
|
||||
cmd = gitCommand("config", "--get", "beads.role")
|
||||
cmd.Dir = tmpDir
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
|
@ -240,13 +239,13 @@ func TestBeadsRoleGitConfig(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("set maintainer role writes to git config", func(t *testing.T) {
|
||||
cmd := exec.Command("git", "config", "beads.role", "maintainer")
|
||||
cmd := gitCommand("config", "beads.role", "maintainer")
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config set failed: %v", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "config", "--get", "beads.role")
|
||||
cmd = gitCommand("config", "--get", "beads.role")
|
||||
cmd.Dir = tmpDir
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
|
@ -275,7 +274,7 @@ func TestBeadsRoleCommandsIgnoreInheritedGitRouting(t *testing.T) {
|
|||
pinJSONOutput(t, false)
|
||||
runGit := func(t *testing.T, repo string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repo
|
||||
cmd.Env = gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
|
|
@ -406,7 +405,7 @@ func TestBeadsRoleWritesUseFreshCommonConfig(t *testing.T) {
|
|||
t.Setenv(key, home)
|
||||
}
|
||||
run := func(dir string, args ...string) string {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
@ -1155,7 +1154,7 @@ func TestBeadsRoleWriteErrorsRetainGitDiagnostics(t *testing.T) {
|
|||
repo := newGitRepo(t)
|
||||
t.Chdir(repo)
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "%s", out)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -23,7 +22,7 @@ func TestFindBeadsRepoRoot_WorktreeFallback(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Skipf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -41,13 +40,13 @@ func TestFindBeadsRepoRoot_WorktreeFallback(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
@ -97,7 +96,7 @@ func TestBeadsPollutionCheck_WorktreeSkips(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -115,13 +114,13 @@ func TestBeadsPollutionCheck_WorktreeSkips(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -32,12 +31,12 @@ func initGitRepoForContextTest(t *testing.T, dir string) {
|
|||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
t.Fatalf("mkdir repo: %v", err)
|
||||
}
|
||||
cmd := exec.Command("git", "init", "--quiet")
|
||||
cmd := gitCommand("init", "--quiet")
|
||||
cmd.Dir = dir
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git init: %v\n%s", err, output)
|
||||
}
|
||||
cmd = exec.Command("git", "config", "core.hooksPath", ".git/hooks")
|
||||
cmd = gitCommand("config", "core.hooksPath", ".git/hooks")
|
||||
cmd.Dir = dir
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git config hooks: %v\n%s", err, output)
|
||||
|
|
@ -201,7 +200,7 @@ func TestDetectUserRoleForActiveRepoUsesSelectedBeadsDir(t *testing.T) {
|
|||
targetBeadsDir := filepath.Join(targetDir, ".beads")
|
||||
writeTestConfigYAML(t, targetBeadsDir, "")
|
||||
|
||||
cmd := exec.Command("git", "config", "beads.role", "maintainer")
|
||||
cmd := gitCommand("config", "beads.role", "maintainer")
|
||||
cmd.Dir = targetDir
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git config beads.role: %v\n%s", err, output)
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ func initContributor(t *testing.T, bd, prefix string) (projectDir, planningDir s
|
|||
requireFile(t, planningBeadsDir)
|
||||
|
||||
// Sanity: beads.role should be "contributor".
|
||||
roleCmd := exec.Command("git", "config", "beads.role")
|
||||
roleCmd := gitCommand("config", "beads.role")
|
||||
roleCmd.Dir = projectDir
|
||||
roleOut, err := roleCmd.Output()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1245,7 +1245,7 @@ func TestEmbeddedCreateWithGitRemote(t *testing.T) {
|
|||
dir, _, _ := bdInit(t, bd, "--prefix", "gr")
|
||||
|
||||
// Add a fake git remote so isBackupAutoEnabled returns true
|
||||
cmd := exec.Command("git", "remote", "add", "origin", "https://example.com/fake.git")
|
||||
cmd := gitCommand("remote", "add", "origin", "https://example.com/fake.git")
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git remote add failed: %v\n%s", err, out)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -176,7 +175,7 @@ func testGitInit(t *testing.T, dir string) {
|
|||
|
||||
func testGitCmd(t *testing.T, dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\nOutput: %s", args, err, output)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
|
@ -148,7 +147,7 @@ func setupBareParentWorktreeForDoctorTest(t *testing.T) (string, string) {
|
|||
func runGitInDirForDoctorTest(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -29,7 +28,7 @@ func setupDoctorSharedWorktree(t *testing.T) (mainRepoDir, worktreeDir string) {
|
|||
|
||||
run := func(dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -48,13 +47,13 @@ func setupDoctorSharedWorktree(t *testing.T) (mainRepoDir, worktreeDir string) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir = filepath.Join(tmpDir, "worktree")
|
||||
addWorktree := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
addWorktree := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
addWorktree.Dir = mainRepoDir
|
||||
if out, err := addWorktree.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
removeWorktree := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
removeWorktree := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
removeWorktree.Dir = mainRepoDir
|
||||
_ = removeWorktree.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -179,7 +178,7 @@ func TestCheckSchemaCompatibility(t *testing.T) {
|
|||
func runDoctorGitInDir(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -22,7 +21,7 @@ func setupWorktreeRepo(t *testing.T) (mainRepoDir, worktreeDir string) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -39,13 +38,13 @@ func setupWorktreeRepo(t *testing.T) (mainRepoDir, worktreeDir string) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir = filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ func setupMinimalGitRepo(t *testing.T) string {
|
|||
{"config", "user.name", "test"},
|
||||
{"config", "user.email", "test@test.com"},
|
||||
} {
|
||||
cmd := exec.Command("git", append([]string{"-C", tmpDir}, args...)...)
|
||||
cmd := gitCommand(append([]string{"-C", tmpDir}, args...)...)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package fix
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -162,3 +163,14 @@ func TestLocalWorkspaceBeadsDir(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
// noAutoMaintenance keeps a fixture's git commit from spawning the detached
|
||||
// "git maintenance run --auto" child whose worktree-prune races the fixture's
|
||||
// next "git worktree add" (gastownhall/beads#7314, #7349). Flags ride the
|
||||
// command line, never env config: the routing-key scrub drops env config.
|
||||
var noAutoMaintenance = []string{"-c", "maintenance.auto=false", "-c", "gc.auto=0"}
|
||||
|
||||
// gitCommand builds a git command for a fixture with noAutoMaintenance applied.
|
||||
func gitCommand(args ...string) *exec.Cmd {
|
||||
return exec.Command("git", append(append([]string{}, noAutoMaintenance...), args...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package fix
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -46,7 +45,7 @@ func setupSharedWorktreeWorkspace(t *testing.T) (mainRepoDir, worktreeDir string
|
|||
|
||||
run := func(dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -65,13 +64,13 @@ func setupSharedWorktreeWorkspace(t *testing.T) (mainRepoDir, worktreeDir string
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir = filepath.Join(tmpDir, "worktree")
|
||||
addWorktree := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
addWorktree := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
addWorktree.Dir = mainRepoDir
|
||||
if out, err := addWorktree.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
removeWorktree := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
removeWorktree := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
removeWorktree.Dir = mainRepoDir
|
||||
_ = removeWorktree.Run()
|
||||
})
|
||||
|
|
@ -82,7 +81,7 @@ func setupSharedWorktreeWorkspace(t *testing.T) (mainRepoDir, worktreeDir string
|
|||
// runGit runs a git command and returns output
|
||||
func runGit(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package fix
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -31,7 +30,7 @@ func initGitTemplate() {
|
|||
}
|
||||
gitTemplateDir = dir
|
||||
|
||||
cmd := exec.Command("git", "init", "--initial-branch=main")
|
||||
cmd := gitCommand("init", "--initial-branch=main")
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
gitTemplateErr = fmt.Errorf("git init failed: %w", err)
|
||||
|
|
@ -42,7 +41,7 @@ func initGitTemplate() {
|
|||
{"config", "user.email", "test@test.com"},
|
||||
{"config", "user.name", "Test User"},
|
||||
} {
|
||||
cmd = exec.Command("git", args...)
|
||||
cmd = gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
gitTemplateErr = fmt.Errorf("git %v failed: %w", args, err)
|
||||
|
|
@ -113,13 +112,13 @@ func TestNewGitRepo_UsesRepoLocalHooksPathDespiteGlobalConfig(t *testing.T) {
|
|||
t.Fatalf("failed to create fake global hooks dir: %v", err)
|
||||
}
|
||||
|
||||
setGlobal := exec.Command("git", "config", "--global", "core.hooksPath", globalHooks)
|
||||
setGlobal := gitCommand("config", "--global", "core.hooksPath", globalHooks)
|
||||
if out, err := setGlobal.CombinedOutput(); err != nil {
|
||||
t.Fatalf("failed to set global core.hooksPath: %v (%s)", err, strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
repoDir := newGitRepo(t)
|
||||
getLocal := exec.Command("git", "config", "--get", "core.hooksPath")
|
||||
getLocal := gitCommand("config", "--get", "core.hooksPath")
|
||||
getLocal.Dir = repoDir
|
||||
out, err := getLocal.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package fix
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -844,7 +843,7 @@ func TestDetectActiveHookManager(t *testing.T) {
|
|||
}
|
||||
// Test isolation: force repo-local hooks path so global git config
|
||||
// does not redirect detection to an unrelated directory.
|
||||
setHooksPathCmd := exec.Command("git", "config", "core.hooksPath", ".git/hooks")
|
||||
setHooksPathCmd := gitCommand("config", "core.hooksPath", ".git/hooks")
|
||||
setHooksPathCmd.Dir = dir
|
||||
if err := setHooksPathCmd.Run(); err != nil {
|
||||
t.Fatalf("failed to set core.hooksPath: %v", err)
|
||||
|
|
@ -879,7 +878,7 @@ func TestDetectActiveHookManager_CustomHooksPath(t *testing.T) {
|
|||
t.Fatalf("failed to copy git template: %v", err)
|
||||
}
|
||||
// Start from repo-local hooks for test isolation; override below.
|
||||
setHooksPathCmd := exec.Command("git", "config", "core.hooksPath", ".git/hooks")
|
||||
setHooksPathCmd := gitCommand("config", "core.hooksPath", ".git/hooks")
|
||||
setHooksPathCmd.Dir = dir
|
||||
if err := setHooksPathCmd.Run(); err != nil {
|
||||
t.Fatalf("failed to set core.hooksPath: %v", err)
|
||||
|
|
@ -898,7 +897,7 @@ func TestDetectActiveHookManager_CustomHooksPath(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set core.hooksPath via git config
|
||||
configCmd := exec.Command("git", "config", "core.hooksPath", "my-hooks")
|
||||
configCmd := gitCommand("config", "core.hooksPath", "my-hooks")
|
||||
configCmd.Dir = dir
|
||||
if err := configCmd.Run(); err != nil {
|
||||
t.Fatalf("failed to set core.hooksPath: %v", err)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package fix
|
|||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ func setupDoltWorkspace(t *testing.T) string {
|
|||
if err := copyGitDir(gitTemplateDir, dir); err != nil {
|
||||
t.Fatalf("failed to copy git template: %v", err)
|
||||
}
|
||||
cmd := exec.Command("git", "config", "remote.origin.url", "https://github.com/test/dolt-metadata-fix.git")
|
||||
cmd := gitCommand("config", "remote.origin.url", "https://github.com/test/dolt-metadata-fix.git")
|
||||
cmd.Dir = dir
|
||||
_ = cmd.Run()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -29,7 +28,7 @@ func mkTmpDirInTmp(t *testing.T, prefix string) string {
|
|||
|
||||
func runGit(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package doctor
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -31,7 +30,7 @@ func initGitTemplate() {
|
|||
}
|
||||
gitTemplateDir = dir
|
||||
|
||||
cmd := exec.Command("git", "init", "--initial-branch=main")
|
||||
cmd := gitCommand("init", "--initial-branch=main")
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
gitTemplateErr = fmt.Errorf("git init failed: %w", err)
|
||||
|
|
@ -42,7 +41,7 @@ func initGitTemplate() {
|
|||
{"config", "user.email", "test@test.com"},
|
||||
{"config", "user.name", "Test User"},
|
||||
} {
|
||||
cmd = exec.Command("git", args...)
|
||||
cmd = gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
gitTemplateErr = fmt.Errorf("git %v failed: %w", args, err)
|
||||
|
|
@ -113,13 +112,13 @@ func TestNewGitRepo_UsesRepoLocalHooksPathDespiteGlobalConfig(t *testing.T) {
|
|||
t.Fatalf("failed to create fake global hooks dir: %v", err)
|
||||
}
|
||||
|
||||
setGlobal := exec.Command("git", "config", "--global", "core.hooksPath", globalHooks)
|
||||
setGlobal := gitCommand("config", "--global", "core.hooksPath", globalHooks)
|
||||
if out, err := setGlobal.CombinedOutput(); err != nil {
|
||||
t.Fatalf("failed to set global core.hooksPath: %v (%s)", err, strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
repoDir := newGitRepo(t)
|
||||
getLocal := exec.Command("git", "config", "--get", "core.hooksPath")
|
||||
getLocal := gitCommand("config", "--get", "core.hooksPath")
|
||||
getLocal.Dir = repoDir
|
||||
out, err := getLocal.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -70,7 +69,7 @@ func setupGitRepoInDir(t *testing.T, dir string) {
|
|||
|
||||
// Force repo-local hooks path for test isolation. This prevents global
|
||||
// core.hooksPath from affecting hook detection behavior in tests.
|
||||
cmd := exec.Command("git", "config", "core.hooksPath", ".git/hooks")
|
||||
cmd := gitCommand("config", "core.hooksPath", ".git/hooks")
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to set core.hooksPath for test repo: %v", err)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/git"
|
||||
|
|
@ -27,3 +28,14 @@ func runInDir(t *testing.T, dir string, fn func()) {
|
|||
}()
|
||||
fn()
|
||||
}
|
||||
|
||||
// noAutoMaintenance keeps a fixture's git commit from spawning the detached
|
||||
// "git maintenance run --auto" child whose worktree-prune races the fixture's
|
||||
// next "git worktree add" (gastownhall/beads#7314, #7349). Flags ride the
|
||||
// command line, never env config: the routing-key scrub drops env config.
|
||||
var noAutoMaintenance = []string{"-c", "maintenance.auto=false", "-c", "gc.auto=0"}
|
||||
|
||||
// gitCommand builds a git command for a fixture with noAutoMaintenance applied.
|
||||
func gitCommand(args ...string) *exec.Cmd {
|
||||
return exec.Command("git", append(append([]string{}, noAutoMaintenance...), args...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package doctor
|
|||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
|
@ -1439,7 +1438,7 @@ func TestCheckRedirectNotTracked_FileTracked(t *testing.T) {
|
|||
}
|
||||
|
||||
// Stage (track) the redirect file
|
||||
gitAdd := exec.Command("git", "add", redirectPath)
|
||||
gitAdd := gitCommand("add", redirectPath)
|
||||
if err := gitAdd.Run(); err != nil {
|
||||
t.Skipf("git add failed: %v", err)
|
||||
}
|
||||
|
|
@ -1498,13 +1497,13 @@ func TestFixRedirectTracking(t *testing.T) {
|
|||
}
|
||||
|
||||
// Stage (track) the redirect file
|
||||
gitAdd := exec.Command("git", "add", redirectPath)
|
||||
gitAdd := gitCommand("add", redirectPath)
|
||||
if err := gitAdd.Run(); err != nil {
|
||||
t.Skipf("git add failed: %v", err)
|
||||
}
|
||||
|
||||
// Verify it's tracked
|
||||
lsFiles := exec.Command("git", "ls-files", redirectPath)
|
||||
lsFiles := gitCommand("ls-files", redirectPath)
|
||||
output, _ := lsFiles.Output()
|
||||
if strings.TrimSpace(string(output)) == "" {
|
||||
t.Fatal("redirect file should be tracked before fix")
|
||||
|
|
@ -1516,7 +1515,7 @@ func TestFixRedirectTracking(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify it's no longer tracked
|
||||
lsFiles = exec.Command("git", "ls-files", redirectPath)
|
||||
lsFiles = gitCommand("ls-files", redirectPath)
|
||||
output, _ = lsFiles.Output()
|
||||
if strings.TrimSpace(string(output)) != "" {
|
||||
t.Error("redirect file should be untracked after fix")
|
||||
|
|
@ -1789,7 +1788,7 @@ func TestCheckLastTouchedNotTracked_FileTracked(t *testing.T) {
|
|||
}
|
||||
|
||||
// Stage (track) the last-touched file
|
||||
gitAdd := exec.Command("git", "add", lastTouchedPath)
|
||||
gitAdd := gitCommand("add", lastTouchedPath)
|
||||
if err := gitAdd.Run(); err != nil {
|
||||
t.Skipf("git add failed: %v", err)
|
||||
}
|
||||
|
|
@ -1848,7 +1847,7 @@ func TestFixLastTouchedTracking(t *testing.T) {
|
|||
}
|
||||
|
||||
// Stage (track) the last-touched file
|
||||
gitAdd := exec.Command("git", "add", lastTouchedPath)
|
||||
gitAdd := gitCommand("add", lastTouchedPath)
|
||||
if err := gitAdd.Run(); err != nil {
|
||||
t.Skipf("git add failed: %v", err)
|
||||
}
|
||||
|
|
@ -2485,7 +2484,7 @@ func setupBareParentWorktreeForGitignoreTest(t *testing.T) (string, string) {
|
|||
func runGitInDirForGitignoreTest(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -2946,7 +2945,7 @@ func TestCheckNoVestigialSyncWorktrees_WithRedirectNoWorktree(t *testing.T) {
|
|||
tmpDir := t.TempDir()
|
||||
|
||||
// Create a git repo so the git root detection works
|
||||
cmd := exec.Command("git", "init", tmpDir)
|
||||
cmd := gitCommand("init", tmpDir)
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Skipf("git init failed: %v", err)
|
||||
}
|
||||
|
|
@ -2985,7 +2984,7 @@ func TestCheckNoVestigialSyncWorktrees_VestigialDetected(t *testing.T) {
|
|||
tmpDir := t.TempDir()
|
||||
|
||||
// Create a git repo
|
||||
cmd := exec.Command("git", "init", tmpDir)
|
||||
cmd := gitCommand("init", tmpDir)
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Skipf("git init failed: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -214,7 +213,7 @@ func findHookPlan(plan HookMigrationPlan, name string) (HookMigrationHookPlan, b
|
|||
|
||||
func forceRepoHooksPath(t *testing.T, repoPath string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "config", "core.hooksPath", ".git/hooks")
|
||||
cmd := gitCommand("config", "core.hooksPath", ".git/hooks")
|
||||
cmd.Dir = repoPath
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to set core.hooksPath for test repo: %v", err)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
|
@ -12,7 +11,7 @@ import (
|
|||
// setGitConfig sets a git config value in dir, failing the test on error.
|
||||
func setGitConfig(t *testing.T, dir, key, value string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "config", key, value)
|
||||
cmd := gitCommand("config", key, value)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git config %s %s failed: %v (%s)", key, value, err, strings.TrimSpace(string(out)))
|
||||
|
|
@ -23,7 +22,7 @@ func setGitConfig(t *testing.T, dir, key, value string) {
|
|||
// since the goal is just to make sure the key is absent.
|
||||
func unsetGitConfig(t *testing.T, dir, key string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "config", "--unset", key)
|
||||
cmd := gitCommand("config", "--unset", key)
|
||||
cmd.Dir = dir
|
||||
_ = cmd.Run()
|
||||
}
|
||||
|
|
@ -31,7 +30,7 @@ func unsetGitConfig(t *testing.T, dir, key string) {
|
|||
// getGitConfig reads a git config value in dir. Returns "" if unset.
|
||||
func getGitConfig(t *testing.T, dir, key string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "config", "--get", key)
|
||||
cmd := gitCommand("config", "--get", key)
|
||||
cmd.Dir = dir
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
|
@ -57,7 +56,7 @@ func TestCheckBeadsRole_Maintainer(t *testing.T) {
|
|||
tmpDir := newGitRepo(t)
|
||||
|
||||
// Set beads.role to maintainer
|
||||
cmd := exec.Command("git", "config", "beads.role", "maintainer")
|
||||
cmd := gitCommand("config", "beads.role", "maintainer")
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config failed: %v", err)
|
||||
|
|
@ -77,7 +76,7 @@ func TestCheckBeadsRole_Contributor(t *testing.T) {
|
|||
tmpDir := newGitRepo(t)
|
||||
|
||||
// Set beads.role to contributor
|
||||
cmd := exec.Command("git", "config", "beads.role", "contributor")
|
||||
cmd := gitCommand("config", "beads.role", "contributor")
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config failed: %v", err)
|
||||
|
|
@ -97,7 +96,7 @@ func TestCheckBeadsRole_InvalidValue(t *testing.T) {
|
|||
tmpDir := newGitRepo(t)
|
||||
|
||||
// Set beads.role to an invalid value
|
||||
cmd := exec.Command("git", "config", "beads.role", "admin")
|
||||
cmd := gitCommand("config", "beads.role", "admin")
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config failed: %v", err)
|
||||
|
|
@ -182,7 +181,7 @@ func TestCheckBeadsRoleIgnoresInheritedRouting(t *testing.T) {
|
|||
target, decoy := newGitRepo(t), newGitRepo(t)
|
||||
runGit := func(repo string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = repo, gitenv.ScrubRouting(os.Environ())
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("fixture git %v: %v: %s", args, err, out)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package doctor
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -10,7 +9,7 @@ import (
|
|||
func disableGlobalGitIgnore(t *testing.T, repoDir string) {
|
||||
t.Helper()
|
||||
|
||||
cmd := exec.Command("git", "config", "core.excludesFile", "")
|
||||
cmd := gitCommand("config", "core.excludesFile", "")
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git config core.excludesFile failed: %v\n%s", err, out)
|
||||
|
|
@ -58,12 +57,12 @@ func TestCheckTrackedRuntimeFiles_WorktreeFallbackUsesSharedBeads(t *testing.T)
|
|||
t.Fatalf("failed to write last-touched: %v", err)
|
||||
}
|
||||
|
||||
add := exec.Command("git", "add", "-f", ".beads/last-touched")
|
||||
add := gitCommand("add", "-f", ".beads/last-touched")
|
||||
add.Dir = mainRepoDir
|
||||
if out, err := add.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git add failed: %v\n%s", err, out)
|
||||
}
|
||||
commit := exec.Command("git", "commit", "-m", "Track runtime artifact for test")
|
||||
commit := gitCommand("commit", "-m", "Track runtime artifact for test")
|
||||
commit.Dir = mainRepoDir
|
||||
if out, err := commit.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git commit failed: %v\n%s", err, out)
|
||||
|
|
@ -93,12 +92,12 @@ func TestFixTrackedRuntimeFiles_WorktreeFallbackUsesSharedBeads(t *testing.T) {
|
|||
t.Fatalf("failed to write last-touched: %v", err)
|
||||
}
|
||||
|
||||
add := exec.Command("git", "add", "-f", ".beads/last-touched")
|
||||
add := gitCommand("add", "-f", ".beads/last-touched")
|
||||
add.Dir = mainRepoDir
|
||||
if out, err := add.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git add failed: %v\n%s", err, out)
|
||||
}
|
||||
commit := exec.Command("git", "commit", "-m", "Track runtime artifact for fix test")
|
||||
commit := gitCommand("commit", "-m", "Track runtime artifact for fix test")
|
||||
commit.Dir = mainRepoDir
|
||||
if out, err := commit.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git commit failed: %v\n%s", err, out)
|
||||
|
|
@ -110,7 +109,7 @@ func TestFixTrackedRuntimeFiles_WorktreeFallbackUsesSharedBeads(t *testing.T) {
|
|||
t.Fatalf("FixTrackedRuntimeFiles() error = %v", err)
|
||||
}
|
||||
|
||||
status := exec.Command("git", "status", "--short", "--", ".beads/last-touched")
|
||||
status := gitCommand("status", "--short", "--", ".beads/last-touched")
|
||||
status.Dir = mainRepoDir
|
||||
out, err := status.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
func setupGitRepoForIntegration(t *testing.T, dir string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "init", dir)
|
||||
cmd := gitCommand("init", dir)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git init failed: %v\n%s", err, out)
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ func setupGitRepoForIntegration(t *testing.T, dir string) {
|
|||
{"-C", dir, "config", "user.email", "test@example.com"},
|
||||
{"-C", dir, "config", "user.name", "Test User"},
|
||||
} {
|
||||
cmd = exec.Command("git", args...)
|
||||
cmd = gitCommand(args...)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func remoteAdd(t *testing.T, bd, dir string, args ...string) (string, string, er
|
|||
// setGitOrigin adds a git remote named "origin" to the directory.
|
||||
func setGitOrigin(t *testing.T, dir, url string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "remote", "add", "origin", url)
|
||||
cmd := gitCommand("remote", "add", "origin", url)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git remote add origin %s: %v\n%s", url, err, out)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -259,7 +258,7 @@ func initBareGitRepoForTest(t *testing.T, dir string) {
|
|||
// runGitCommand runs a git command in dir and fatals on error.
|
||||
func runGitCommand(t *testing.T, dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %s: %v\n%s", strings.Join(args, " "), err, out)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -17,7 +16,7 @@ import (
|
|||
// resetDataRunGit runs a git command in dir, fatal on failure.
|
||||
func resetDataRunGit(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -78,16 +78,16 @@ func initGitRepo(t *testing.T, dir string) {
|
|||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
t.Fatalf("mkdir repo: %v", err)
|
||||
}
|
||||
cmd := exec.Command("git", "init", "-q")
|
||||
cmd := gitCommand("init", "-q")
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git init %s: %v\n%s", dir, err, out)
|
||||
}
|
||||
writeFile(t, filepath.Join(dir, ".gitignore"), []byte(".beads/.env\n"))
|
||||
commitCmd := exec.Command("git", "add", ".")
|
||||
commitCmd := gitCommand("add", ".")
|
||||
commitCmd.Dir = dir
|
||||
_, _ = commitCmd.CombinedOutput()
|
||||
commitCmd = exec.Command("git", "commit", "-q", "-m", "init")
|
||||
commitCmd = gitCommand("commit", "-q", "-m", "init")
|
||||
commitCmd.Dir = dir
|
||||
commitCmd.Env = append(os.Environ(),
|
||||
"GIT_AUTHOR_NAME=Test",
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func TestGitAddFile_InWorktreeHook_StagesCorrectPath(t *testing.T) {
|
|||
}
|
||||
runGit := func(dir string, args ...string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", args...)
|
||||
c := gitCommand(args...)
|
||||
c.Dir = dir
|
||||
if out, err := c.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v in %s failed: %v\n%s", args, dir, err, out)
|
||||
|
|
@ -71,7 +71,7 @@ func TestGitAddFile_InWorktreeHook_StagesCorrectPath(t *testing.T) {
|
|||
worktree := filepath.Join(tmpDir, "wt")
|
||||
runGit(mainRepo, "worktree", "add", worktree, "-b", "feat")
|
||||
t.Cleanup(func() {
|
||||
c := exec.Command("git", "worktree", "remove", "--force", worktree)
|
||||
c := gitCommand("worktree", "remove", "--force", worktree)
|
||||
c.Dir = mainRepo
|
||||
_ = c.Run()
|
||||
})
|
||||
|
|
@ -87,7 +87,7 @@ func TestGitAddFile_InWorktreeHook_StagesCorrectPath(t *testing.T) {
|
|||
|
||||
// Simulate the environment inside a git pre-commit hook: GIT_DIR points
|
||||
// at the worktree's per-worktree gitdir.
|
||||
out, err := exec.Command("git", "-C", worktree, "rev-parse", "--git-dir").Output()
|
||||
out, err := gitCommand("-C", worktree, "rev-parse", "--git-dir").Output()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ func TestGitAddFile_InWorktreeHook_StagesCorrectPath(t *testing.T) {
|
|||
|
||||
// Inspect the worktree's index: the staged path must be ".beads/issues.jsonl",
|
||||
// NOT bare "issues.jsonl" at repo root.
|
||||
lsFiles := exec.Command("git", "ls-files", "--stage")
|
||||
lsFiles := gitCommand("ls-files", "--stage")
|
||||
lsFiles.Dir = worktree
|
||||
data, err := lsFiles.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -692,7 +692,7 @@ func TestGitAddFile_NonHookContext_GuardDoesNotFire(t *testing.T) {
|
|||
}
|
||||
runGit := func(args ...string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", args...)
|
||||
c := gitCommand(args...)
|
||||
c.Dir = repo
|
||||
if out, err := c.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||
|
|
@ -718,7 +718,7 @@ func TestGitAddFile_NonHookContext_GuardDoesNotFire(t *testing.T) {
|
|||
t.Fatalf("gitAddFile: %v", err)
|
||||
}
|
||||
|
||||
c := exec.Command("git", "ls-files", "--stage")
|
||||
c := gitCommand("ls-files", "--stage")
|
||||
c.Dir = repo
|
||||
data, err := c.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -756,7 +756,7 @@ func TestGitAddFile_RelativePathDoesNotDoubleRoot(t *testing.T) {
|
|||
}
|
||||
runGit := func(args ...string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", args...)
|
||||
c := gitCommand(args...)
|
||||
c.Dir = repo
|
||||
if out, err := c.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||
|
|
@ -788,7 +788,7 @@ func TestGitAddFile_RelativePathDoesNotDoubleRoot(t *testing.T) {
|
|||
t.Fatalf("gitAddFile(%q): %v", relPath, err)
|
||||
}
|
||||
|
||||
c := exec.Command("git", "diff", "--cached", "--name-only")
|
||||
c := gitCommand("diff", "--cached", "--name-only")
|
||||
c.Dir = repo
|
||||
data, err := c.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -825,7 +825,7 @@ func TestGitAddFile_CapturesStderrOnFailure(t *testing.T) {
|
|||
}
|
||||
runGit := func(args ...string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", args...)
|
||||
c := gitCommand(args...)
|
||||
c.Dir = repo
|
||||
if out, err := c.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||
|
|
@ -890,7 +890,7 @@ func TestGitAddFile_CapturesLockedIndexFailure(t *testing.T) {
|
|||
}
|
||||
runGit := func(args ...string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", args...)
|
||||
c := gitCommand(args...)
|
||||
c.Dir = repo
|
||||
if out, err := c.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||
|
|
@ -926,7 +926,7 @@ func TestGitAddFile_CapturesLockedIndexFailure(t *testing.T) {
|
|||
t.Fatalf("expected index.lock error, got: %q", msg)
|
||||
}
|
||||
|
||||
c := exec.Command("git", "ls-files", "--stage")
|
||||
c := gitCommand("ls-files", "--stage")
|
||||
c.Dir = repo
|
||||
data, err := c.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -948,7 +948,7 @@ func TestAutoExportGitAddFailureExitsNonZero(t *testing.T) {
|
|||
|
||||
runGit := func(args ...string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", args...)
|
||||
c := gitCommand(args...)
|
||||
c.Dir = dir
|
||||
if out, err := c.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||
|
|
@ -1026,7 +1026,7 @@ func TestGitAddFile_RedirectCase_DoesNotStageInMainRepo(t *testing.T) {
|
|||
}
|
||||
runGit := func(dir string, args ...string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", args...)
|
||||
c := gitCommand(args...)
|
||||
c.Dir = dir
|
||||
if out, err := c.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v in %s failed: %v\n%s", args, dir, err, out)
|
||||
|
|
@ -1056,12 +1056,12 @@ func TestGitAddFile_RedirectCase_DoesNotStageInMainRepo(t *testing.T) {
|
|||
worktree := filepath.Join(tmpDir, "wt")
|
||||
runGit(mainRepo, "worktree", "add", worktree, "-b", "feat")
|
||||
t.Cleanup(func() {
|
||||
c := exec.Command("git", "worktree", "remove", "--force", worktree)
|
||||
c := gitCommand("worktree", "remove", "--force", worktree)
|
||||
c.Dir = mainRepo
|
||||
_ = c.Run()
|
||||
})
|
||||
|
||||
out, err := exec.Command("git", "-C", worktree, "rev-parse", "--git-dir").Output()
|
||||
out, err := gitCommand("-C", worktree, "rev-parse", "--git-dir").Output()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1084,7 +1084,7 @@ func TestGitAddFile_RedirectCase_DoesNotStageInMainRepo(t *testing.T) {
|
|||
// staging entry from the worktree's hook firing.
|
||||
checkNoStage := func(label, repoDir string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", "ls-files", "--stage")
|
||||
c := gitCommand("ls-files", "--stage")
|
||||
c.Dir = repoDir
|
||||
data, err := c.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -1134,7 +1134,7 @@ func TestPreCommitHasStagedBeadsFiles(t *testing.T) {
|
|||
}
|
||||
runGit := func(args ...string) {
|
||||
t.Helper()
|
||||
c := exec.Command("git", args...)
|
||||
c := gitCommand(args...)
|
||||
c.Dir = repo
|
||||
if out, err := c.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -34,7 +33,7 @@ func initGitTemplate() {
|
|||
}
|
||||
gitTemplateDir = dir
|
||||
|
||||
cmd := exec.Command("git", "init", "--initial-branch=main")
|
||||
cmd := gitCommand("init", "--initial-branch=main")
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
gitTemplateErr = fmt.Errorf("git init failed: %w", err)
|
||||
|
|
@ -45,7 +44,7 @@ func initGitTemplate() {
|
|||
{"config", "user.email", "test@test.com"},
|
||||
{"config", "user.name", "Test User"},
|
||||
} {
|
||||
cmd = exec.Command("git", args...)
|
||||
cmd = gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
gitTemplateErr = fmt.Errorf("git %v failed: %w", args, err)
|
||||
|
|
@ -119,13 +118,13 @@ func TestNewGitRepo_UsesRepoLocalHooksPathDespiteGlobalConfig(t *testing.T) {
|
|||
t.Fatalf("failed to create fake global hooks dir: %v", err)
|
||||
}
|
||||
|
||||
setGlobal := exec.Command("git", "config", "--global", "core.hooksPath", globalHooks)
|
||||
setGlobal := gitCommand("config", "--global", "core.hooksPath", globalHooks)
|
||||
if out, err := setGlobal.CombinedOutput(); err != nil {
|
||||
t.Fatalf("failed to set global core.hooksPath: %v (%s)", err, strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
repoDir := newGitRepo(t)
|
||||
getLocal := exec.Command("git", "config", "--get", "core.hooksPath")
|
||||
getLocal := gitCommand("config", "--get", "core.hooksPath")
|
||||
getLocal.Dir = repoDir
|
||||
out, err := getLocal.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/utils"
|
||||
|
|
@ -62,3 +63,14 @@ func TestExtractPrefix(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// noAutoMaintenance keeps a fixture's git commit from spawning the detached
|
||||
// "git maintenance run --auto" child whose worktree-prune races the fixture's
|
||||
// next "git worktree add" (gastownhall/beads#7314, #7349). Flags ride the
|
||||
// command line, never env config: the routing-key scrub drops env config.
|
||||
var noAutoMaintenance = []string{"-c", "maintenance.auto=false", "-c", "gc.auto=0"}
|
||||
|
||||
// gitCommand builds a git command for a fixture with noAutoMaintenance applied.
|
||||
func gitCommand(args ...string) *exec.Cmd {
|
||||
return exec.Command("git", append(append([]string{}, noAutoMaintenance...), args...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -22,7 +21,7 @@ func setupExportStagedDeletionRepo(t *testing.T) (repoDir, filePath string) {
|
|||
|
||||
run := func(args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Skipf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -47,7 +46,7 @@ func TestIsExportFileStagedForDeletion_StagedDeletion(t *testing.T) {
|
|||
|
||||
run := func(args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -77,7 +76,7 @@ func TestIsExportFileStagedForDeletion_StagedModificationNotDeletion(t *testing.
|
|||
|
||||
run := func(args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func mkdirs(t *testing.T, dirs ...string) {
|
|||
// scrubbed because the test process may itself be running under a git hook.
|
||||
func runGitForWorktreeTest(t *testing.T, dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = scrubGitHookEnv(os.Environ())
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
|
|
@ -396,7 +396,7 @@ func readFileForWorktreeTest(t *testing.T, path string) string {
|
|||
// can tell "the hook staged this" from "the fixture did".
|
||||
func stagedPathsForWorktreeTest(t *testing.T, dir string) []string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "diff", "--cached", "--name-only")
|
||||
cmd := gitCommand("diff", "--cached", "--name-only")
|
||||
cmd.Dir = dir
|
||||
cmd.Env = scrubGitHookEnv(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
func TestGuardHookWritePathIgnoresInheritedGitRouting(t *testing.T) {
|
||||
runGit := func(repo string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repo
|
||||
cmd.Env = gitenv.ScrubRouting(os.Environ())
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
|
|
@ -64,7 +64,7 @@ func TestGuardHookWritePathIgnoresInheritedGitRouting(t *testing.T) {
|
|||
t.Setenv(key, value)
|
||||
}
|
||||
if tc.name == "both" {
|
||||
probe := exec.Command("git", "-C", hooksDir, "ls-files", "--error-unmatch", "--", "pre-commit")
|
||||
probe := gitCommand("-C", hooksDir, "ls-files", "--error-unmatch", "--", "pre-commit")
|
||||
out, err := probe.CombinedOutput()
|
||||
require.NoError(t, err, "inherited index must also prove tracking: %s", out)
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ func setupGuardTestRepo(t *testing.T) string {
|
|||
repoDir := t.TempDir()
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Skipf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -197,7 +197,7 @@ func TestInstallHooksRefusesTrackedHook(t *testing.T) {
|
|||
{"commit", "-m", "add tracked hook"},
|
||||
{"config", "core.hooksPath", "hooks"},
|
||||
} {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Skipf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -233,7 +233,7 @@ func TestInstallHooksAllowsTrackedBdOwnedHook(t *testing.T) {
|
|||
{"commit", "-m", "commit bd-managed hook"},
|
||||
{"config", "core.hooksPath", "hooks"},
|
||||
} {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Skipf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -362,7 +362,7 @@ func TestInstallHooksRefusesTrackedExternalIntegrationHook(t *testing.T) {
|
|||
{"commit", "-m", "add tracked external integration hook"},
|
||||
{"config", "core.hooksPath", "hooks"},
|
||||
} {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Skipf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -540,7 +540,7 @@ func TestGuardHookWritePathHonorsInheritedRepository(t *testing.T) {
|
|||
}
|
||||
runGit := func(args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repo
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||
|
|
@ -592,7 +592,7 @@ func TestGuardHookWritePathHonorsInheritedRepository(t *testing.T) {
|
|||
}
|
||||
inherited := os.Environ()
|
||||
args := []string{"-C", hooksDir, "ls-files", "--error-unmatch", "--", "pre-commit"}
|
||||
clean := exec.Command("git", args...)
|
||||
clean := gitCommand(args...)
|
||||
clean.Env = gitenv.ScrubRouting(inherited)
|
||||
out, cleanErr := clean.CombinedOutput()
|
||||
if cleanErr == nil {
|
||||
|
|
@ -605,7 +605,7 @@ func TestGuardHookWritePathHonorsInheritedRepository(t *testing.T) {
|
|||
if exit, ok := cleanErr.(*exec.ExitError); ok && exit.ExitCode() == 1 {
|
||||
t.Fatalf("fixture must fail the scrubbed probe for a configuration reason, got exit 1: %s", out)
|
||||
}
|
||||
fallback := exec.Command("git", args...)
|
||||
fallback := gitCommand(args...)
|
||||
fallback.Env = inherited
|
||||
if out, err := fallback.CombinedOutput(); err != nil {
|
||||
t.Fatalf("inherited tracking precondition: %v\n%s", err, out)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func TestConfigureBeadsHooksPath_WorktreeUsesMainRepo(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Skipf("git %v failed: %v", args, err)
|
||||
|
|
@ -45,13 +45,13 @@ func TestConfigureBeadsHooksPath_WorktreeUsesMainRepo(t *testing.T) {
|
|||
run("commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepoDir
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
@ -71,7 +71,7 @@ func TestConfigureBeadsHooksPath_WorktreeUsesMainRepo(t *testing.T) {
|
|||
t.Fatalf("configureBeadsHooksPath failed: %v", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "config", "--get", "core.hooksPath")
|
||||
cmd = gitCommand("config", "--get", "core.hooksPath")
|
||||
cmd.Dir = mainRepoDir
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
|
@ -99,7 +99,7 @@ func TestConfigureSharedHooksPath_WorktreeUsesMainRepo(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Skipf("git %v failed: %v", args, err)
|
||||
|
|
@ -115,13 +115,13 @@ func TestConfigureSharedHooksPath_WorktreeUsesMainRepo(t *testing.T) {
|
|||
run("commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepoDir
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
@ -141,7 +141,7 @@ func TestConfigureSharedHooksPath_WorktreeUsesMainRepo(t *testing.T) {
|
|||
t.Fatalf("configureSharedHooksPath failed: %v", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "config", "--get", "core.hooksPath")
|
||||
cmd = gitCommand("config", "--get", "core.hooksPath")
|
||||
cmd.Dir = mainRepoDir
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
|
@ -169,7 +169,7 @@ func TestResetHooksPathIfBeadsManaged_Worktree(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Skipf("git %v failed: %v", args, err)
|
||||
|
|
@ -185,13 +185,13 @@ func TestResetHooksPathIfBeadsManaged_Worktree(t *testing.T) {
|
|||
run("commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepoDir
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
@ -205,7 +205,7 @@ func TestResetHooksPathIfBeadsManaged_Worktree(t *testing.T) {
|
|||
if evaluated != "" {
|
||||
hooksPathToSet = evaluated
|
||||
}
|
||||
cmd = exec.Command("git", "config", "core.hooksPath", hooksPathToSet)
|
||||
cmd = gitCommand("config", "core.hooksPath", hooksPathToSet)
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config core.hooksPath failed: %v", err)
|
||||
|
|
@ -213,12 +213,12 @@ func TestResetHooksPathIfBeadsManaged_Worktree(t *testing.T) {
|
|||
|
||||
run("config", "beads.role", "primary")
|
||||
run("config", "extensions.worktreeConfig", "true")
|
||||
cmd = exec.Command("git", "config", "--worktree", "beads.role", "worktree-only")
|
||||
cmd = gitCommand("config", "--worktree", "beads.role", "worktree-only")
|
||||
cmd.Dir = worktreeDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("configure worktree role: %v\n%s", err, out)
|
||||
}
|
||||
cmd = exec.Command("git", "config", "--worktree", "core.hooksPath", ".beads/hooks")
|
||||
cmd = gitCommand("config", "--worktree", "core.hooksPath", ".beads/hooks")
|
||||
cmd.Dir = worktreeDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("configure worktree hooksPath: %v\n%s", err, out)
|
||||
|
|
@ -235,25 +235,25 @@ func TestResetHooksPathIfBeadsManaged_Worktree(t *testing.T) {
|
|||
t.Fatalf("resetHooksPathIfBeadsManaged failed: %v", err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("git", "config", "--local", "--get", "core.hooksPath")
|
||||
cmd = gitCommand("config", "--local", "--get", "core.hooksPath")
|
||||
cmd.Dir = mainRepoDir
|
||||
out, _ := cmd.Output()
|
||||
if strings.TrimSpace(string(out)) != "" {
|
||||
t.Errorf("core.hooksPath = %q after reset, want empty", strings.TrimSpace(string(out)))
|
||||
}
|
||||
cmd = exec.Command("git", "config", "--local", "--get", "beads.role")
|
||||
cmd = gitCommand("config", "--local", "--get", "beads.role")
|
||||
cmd.Dir = mainRepoDir
|
||||
out, err = cmd.Output()
|
||||
if exit, ok := err.(*exec.ExitError); !ok || exit.ExitCode() != 1 {
|
||||
t.Errorf("main role remains after reset: %q, %v", out, err)
|
||||
}
|
||||
cmd = exec.Command("git", "config", "--worktree", "--get", "beads.role")
|
||||
cmd = gitCommand("config", "--worktree", "--get", "beads.role")
|
||||
cmd.Dir = worktreeDir
|
||||
out, err = cmd.Output()
|
||||
if err != nil || strings.TrimSpace(string(out)) != "worktree-only" {
|
||||
t.Errorf("worktree-specific role changed: %q, %v", out, err)
|
||||
}
|
||||
cmd = exec.Command("git", "config", "--worktree", "--get", "core.hooksPath")
|
||||
cmd = gitCommand("config", "--worktree", "--get", "core.hooksPath")
|
||||
cmd.Dir = worktreeDir
|
||||
out, err = cmd.Output()
|
||||
if err != nil || strings.TrimSpace(string(out)) != ".beads/hooks" {
|
||||
|
|
@ -279,7 +279,7 @@ func TestResetHooksPathIfBeadsManaged_Worktree(t *testing.T) {
|
|||
if after, err := os.ReadFile(privateConfig); err != nil || string(after) != string(before) {
|
||||
t.Fatalf("private worktree config changed: %v", err)
|
||||
}
|
||||
get := exec.Command("git", "config", "--local", "--get", "beads.role")
|
||||
get := gitCommand("config", "--local", "--get", "beads.role")
|
||||
get.Dir = mainRepoDir
|
||||
out, err := get.Output()
|
||||
if exit, ok := err.(*exec.ExitError); !ok || exit.ExitCode() != 1 {
|
||||
|
|
@ -301,7 +301,7 @@ func TestConfigureBeadsHooksPath_NormalRepoUnchanged(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Skipf("git %v failed: %v", args, err)
|
||||
|
|
@ -331,7 +331,7 @@ func TestConfigureBeadsHooksPath_NormalRepoUnchanged(t *testing.T) {
|
|||
t.Fatalf("configureBeadsHooksPath failed: %v", err)
|
||||
}
|
||||
|
||||
cmd := exec.Command("git", "config", "--get", "core.hooksPath")
|
||||
cmd := gitCommand("config", "--get", "core.hooksPath")
|
||||
cmd.Dir = repoDir
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
|
@ -569,7 +569,7 @@ func TestStandaloneHookCommandsUseSelectedContext(t *testing.T) {
|
|||
require.NoError(t, hooksUninstallCmd.RunE(hooksUninstallCmd, nil))
|
||||
_, err := os.Stat(filepath.Join(destination, "pre-commit"))
|
||||
require.ErrorIs(t, err, os.ErrNotExist)
|
||||
query := exec.Command("git", "--git-dir", common, "config", "--local", "--get", "beads.role")
|
||||
query := gitCommand("--git-dir", common, "config", "--local", "--get", "beads.role")
|
||||
query.Dir, query.Env = cwd, gitenv.ScrubRouting(os.Environ())
|
||||
var exit *exec.ExitError
|
||||
require.ErrorAs(t, query.Run(), &exit)
|
||||
|
|
@ -580,7 +580,7 @@ func TestStandaloneHookCommandsUseSelectedContext(t *testing.T) {
|
|||
// configured keeps .git/hooks shadowed by an emptied directory,
|
||||
// i.e. every hook silently disabled while beads-managed config is
|
||||
// still installed — the GH#4440 contract this command enforces.
|
||||
pathQuery := exec.Command("git", "--git-dir", common, "config", "--local", "--get", "core.hooksPath")
|
||||
pathQuery := gitCommand("--git-dir", common, "config", "--local", "--get", "core.hooksPath")
|
||||
pathQuery.Dir, pathQuery.Env = cwd, gitenv.ScrubRouting(os.Environ())
|
||||
var pathExit *exec.ExitError
|
||||
require.ErrorAs(t, pathQuery.Run(), &pathExit)
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ func TestInitCancel_E2E(t *testing.T) {
|
|||
|
||||
func runGitCmd(t *testing.T, dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -480,14 +480,14 @@ func TestEmbeddedInitA(t *testing.T) {
|
|||
if err := os.MkdirAll(bareRepo, 0755); err != nil {
|
||||
t.Fatalf("mkdir %s: %v", bareRepo, err)
|
||||
}
|
||||
cmd := exec.Command("git", "init", "--bare")
|
||||
cmd := gitCommand("init", "--bare")
|
||||
cmd.Dir = bareRepo
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git init --bare %s failed: %v\n%s", bareRepo, err, out)
|
||||
}
|
||||
}
|
||||
for name, url := range map[string]string{"origin": origin, "upstream": upstream} {
|
||||
cmd := exec.Command("git", "remote", "add", name, url)
|
||||
cmd := gitCommand("remote", "add", name, url)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git remote add %s failed: %v\n%s", name, err, out)
|
||||
|
|
@ -522,7 +522,7 @@ func TestEmbeddedInitA(t *testing.T) {
|
|||
t.Errorf("planning embeddeddolt dir missing (planning store not pre-initialized): %v", err)
|
||||
}
|
||||
|
||||
roleCmd := exec.Command("git", "config", "--get", "beads.role")
|
||||
roleCmd := gitCommand("config", "--get", "beads.role")
|
||||
roleCmd.Dir = dir
|
||||
roleOut, err := roleCmd.Output()
|
||||
if err != nil {
|
||||
|
|
@ -565,7 +565,7 @@ func TestEmbeddedInitA(t *testing.T) {
|
|||
}
|
||||
|
||||
bdDolt(t, bd, dir, "push")
|
||||
ls := exec.Command("git", "ls-remote", remoteURL, "refs/dolt/data")
|
||||
ls := gitCommand("ls-remote", remoteURL, "refs/dolt/data")
|
||||
lsOut, err := ls.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("git ls-remote refs/dolt/data failed: %v\n%s", err, lsOut)
|
||||
|
|
@ -607,7 +607,7 @@ func TestEmbeddedInitA(t *testing.T) {
|
|||
if readErr == nil && strings.Contains(string(configYAML), remoteURL) {
|
||||
t.Errorf("refused push still persisted sync.remote; config.yaml:\n%s", configYAML)
|
||||
}
|
||||
if lsOut, lsErr := exec.Command("git", "ls-remote", remoteURL, "refs/dolt/data").Output(); lsErr == nil && len(strings.TrimSpace(string(lsOut))) != 0 {
|
||||
if lsOut, lsErr := gitCommand("ls-remote", remoteURL, "refs/dolt/data").Output(); lsErr == nil && len(strings.TrimSpace(string(lsOut))) != 0 {
|
||||
t.Errorf("refused push still uploaded issue history: %s", lsOut)
|
||||
}
|
||||
}
|
||||
|
|
@ -646,7 +646,7 @@ func TestEmbeddedInitA(t *testing.T) {
|
|||
t.Fatalf("bd dolt push should persist sync.remote; config.yaml:\n%s", configYAML)
|
||||
}
|
||||
|
||||
ls := exec.Command("git", "ls-remote", remoteURL, "refs/dolt/data")
|
||||
ls := gitCommand("ls-remote", remoteURL, "refs/dolt/data")
|
||||
lsOut, err := ls.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("git ls-remote refs/dolt/data failed: %v\n%s", err, lsOut)
|
||||
|
|
@ -940,7 +940,7 @@ func TestEmbeddedInitB(t *testing.T) {
|
|||
{"add", "-A"},
|
||||
{"commit", "-m", "baseline"},
|
||||
} {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %s failed: %v\n%s", args[0], err, out)
|
||||
|
|
@ -970,7 +970,7 @@ func TestEmbeddedInitB(t *testing.T) {
|
|||
}
|
||||
|
||||
// git status --porcelain must be empty: stealth touched no visible files.
|
||||
cmd := exec.Command("git", "-c", "core.hooksPath=", "status", "--porcelain")
|
||||
cmd := gitCommand("-c", "core.hooksPath=", "status", "--porcelain")
|
||||
cmd.Dir = dir
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -1017,7 +1017,7 @@ func TestEmbeddedInitB(t *testing.T) {
|
|||
t.Logf("bd doctor --fix exited non-zero (tolerated): %v\n%s", err, out)
|
||||
}
|
||||
|
||||
statusCmd := exec.Command("git", "-c", "core.hooksPath=", "status", "--porcelain")
|
||||
statusCmd := gitCommand("-c", "core.hooksPath=", "status", "--porcelain")
|
||||
statusCmd.Dir = dir
|
||||
out, err := statusCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -1094,7 +1094,7 @@ func TestEmbeddedInitB(t *testing.T) {
|
|||
if err := os.WriteFile(hookPath, []byte(hook), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
unsetHooksPath := exec.Command("git", "config", "--unset", "core.hooksPath")
|
||||
unsetHooksPath := gitCommand("config", "--unset", "core.hooksPath")
|
||||
unsetHooksPath.Dir = dir
|
||||
if out, err := unsetHooksPath.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git config --unset core.hooksPath failed: %v\n%s", err, out)
|
||||
|
|
@ -1124,7 +1124,7 @@ func TestEmbeddedInitB(t *testing.T) {
|
|||
if _, err := os.Stat(filepath.Join(dir, ".hook-ran")); err == nil {
|
||||
t.Fatal("expected init auto-commit to bypass git hooks")
|
||||
}
|
||||
logCmd := exec.Command("git", "log", "--oneline", "-n", "1")
|
||||
logCmd := gitCommand("log", "--oneline", "-n", "1")
|
||||
logCmd.Dir = dir
|
||||
stdout, stderr, err := runCommandBuffers(t, logCmd)
|
||||
if err != nil {
|
||||
|
|
@ -1717,7 +1717,7 @@ func TestEmbeddedInitArtifactRouting(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
show := exec.Command("git", "show", "HEAD:.beads/metadata.json")
|
||||
show := gitCommand("show", "HEAD:.beads/metadata.json")
|
||||
show.Dir, show.Env = target, gitenv.ScrubRouting(os.Environ())
|
||||
if got, err := show.CombinedOutput(); err != nil || !bytes.Equal(got, want) {
|
||||
t.Errorf("embedded init did not commit target metadata: %v: %s", err, got)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -26,7 +25,7 @@ import (
|
|||
// silently.
|
||||
func TestInitGitBootstrapProbeWidensPastLegitimateCeiling(t *testing.T) {
|
||||
ancestor := t.TempDir()
|
||||
initRepo := exec.Command("git", "init", "--quiet")
|
||||
initRepo := gitCommand("init", "--quiet")
|
||||
initRepo.Dir = ancestor
|
||||
initRepo.Env = gitenv.ScrubRouting(os.Environ())
|
||||
if out, err := initRepo.CombinedOutput(); err != nil {
|
||||
|
|
@ -50,7 +49,7 @@ func TestInitGitBootstrapProbeWidensPastLegitimateCeiling(t *testing.T) {
|
|||
// Control: identical environment except the ceiling is left in place, which is what the
|
||||
// probe did before this change. It must fail — otherwise the ceiling never bit and the
|
||||
// assertion below would pass for the wrong reason.
|
||||
fenced := exec.Command("git", "-C", project, "rev-parse", "--git-dir")
|
||||
fenced := gitCommand("-C", project, "rev-parse", "--git-dir")
|
||||
fenced.Env = append(gitenv.ScrubRouting(os.Environ()), "GIT_CEILING_DIRECTORIES="+ceiling)
|
||||
if out, ferr := fenced.Output(); ferr == nil {
|
||||
t.Fatalf("ceiling %q did not fence off %q (git found %q); this case cannot prove the widening",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -795,7 +794,7 @@ func TestConfigureBeadsHooksPath_AbsolutePath(t *testing.T) {
|
|||
}
|
||||
|
||||
// Read back core.hooksPath
|
||||
out, err := exec.Command("git", "config", "--get", "core.hooksPath").Output()
|
||||
out, err := gitCommand("config", "--get", "core.hooksPath").Output()
|
||||
if err != nil {
|
||||
t.Fatalf("git config --get core.hooksPath failed: %v", err)
|
||||
}
|
||||
|
|
@ -827,7 +826,7 @@ func TestInstallHooksBeads_WorktreeAccess(t *testing.T) {
|
|||
t.Fatalf("Failed to create metadata.json: %v", err)
|
||||
}
|
||||
|
||||
cmd := exec.Command("git", "commit", "--allow-empty", "--no-verify", "-m", "init")
|
||||
cmd := gitCommand("commit", "--allow-empty", "--no-verify", "-m", "init")
|
||||
cmd.Dir = tmpDir
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git commit failed: %v\n%s", err, string(output))
|
||||
|
|
@ -847,7 +846,7 @@ func TestInstallHooksBeads_WorktreeAccess(t *testing.T) {
|
|||
}
|
||||
|
||||
// Read core.hooksPath and verify it's absolute
|
||||
out, err := exec.Command("git", "config", "--get", "core.hooksPath").Output()
|
||||
out, err := gitCommand("config", "--get", "core.hooksPath").Output()
|
||||
if err != nil {
|
||||
t.Fatalf("core.hooksPath not set after --beads install: %v", err)
|
||||
}
|
||||
|
|
@ -858,17 +857,17 @@ func TestInstallHooksBeads_WorktreeAccess(t *testing.T) {
|
|||
|
||||
// Create a worktree and verify hooks are accessible from it
|
||||
worktreeDir := filepath.Join(t.TempDir(), "worktree")
|
||||
cmd = exec.Command("git", "worktree", "add", worktreeDir, "-b", "test-worktree")
|
||||
cmd = gitCommand("worktree", "add", worktreeDir, "-b", "test-worktree")
|
||||
cmd.Dir = tmpDir
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, string(output))
|
||||
}
|
||||
defer func() {
|
||||
exec.Command("git", "worktree", "remove", worktreeDir).Run()
|
||||
gitCommand("worktree", "remove", worktreeDir).Run()
|
||||
}()
|
||||
|
||||
// From the worktree, core.hooksPath should resolve to the same hooks
|
||||
cmd = exec.Command("git", "config", "--get", "core.hooksPath")
|
||||
cmd = gitCommand("config", "--get", "core.hooksPath")
|
||||
cmd.Dir = worktreeDir
|
||||
wtOut, err := cmd.Output()
|
||||
if err != nil {
|
||||
|
|
@ -924,14 +923,14 @@ func TestInstallHooksBeads_PreservesGlobalHooks(t *testing.T) {
|
|||
t.Fatalf("failed to write global pre-commit hook: %v", err)
|
||||
}
|
||||
|
||||
setGlobal := exec.Command("git", "config", "--global", "core.hooksPath", globalHooksDir)
|
||||
setGlobal := gitCommand("config", "--global", "core.hooksPath", globalHooksDir)
|
||||
if out, err := setGlobal.CombinedOutput(); err != nil {
|
||||
t.Fatalf("failed to set global core.hooksPath: %v (%s)", err, strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
// Manual repo init (can't use newGitRepo which sets a local core.hooksPath).
|
||||
repoDir := t.TempDir()
|
||||
initCmd := exec.Command("git", "init", "--initial-branch=main")
|
||||
initCmd := gitCommand("init", "--initial-branch=main")
|
||||
initCmd.Dir = repoDir
|
||||
if err := initCmd.Run(); err != nil {
|
||||
t.Fatalf("git init failed: %v", err)
|
||||
|
|
@ -940,7 +939,7 @@ func TestInstallHooksBeads_PreservesGlobalHooks(t *testing.T) {
|
|||
{"config", "user.email", "test@test.com"},
|
||||
{"config", "user.name", "Test User"},
|
||||
} {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config %v failed: %v", args, err)
|
||||
|
|
@ -987,7 +986,7 @@ func TestInstallHooksBeads_PreservesDefaultGitHooks(t *testing.T) {
|
|||
}
|
||||
|
||||
// Unset the local core.hooksPath that newGitRepo sets so git falls back to .git/hooks/.
|
||||
exec.Command("git", "config", "--unset", "core.hooksPath").Run()
|
||||
gitCommand("config", "--unset", "core.hooksPath").Run()
|
||||
|
||||
beadsDir := setupBeadsDir(t, repoDir)
|
||||
|
||||
|
|
@ -1202,13 +1201,13 @@ func TestInstallHooksBeads_HuskyV8Helper(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set as global hooks path (simulating husky v8)
|
||||
setGlobal := exec.Command("git", "config", "--global", "core.hooksPath", huskyDir)
|
||||
setGlobal := gitCommand("config", "--global", "core.hooksPath", huskyDir)
|
||||
if out, err := setGlobal.CombinedOutput(); err != nil {
|
||||
t.Fatalf("set global core.hooksPath: %v (%s)", err, strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
repoDir := t.TempDir()
|
||||
initCmd := exec.Command("git", "init", "--initial-branch=main")
|
||||
initCmd := gitCommand("init", "--initial-branch=main")
|
||||
initCmd.Dir = repoDir
|
||||
if err := initCmd.Run(); err != nil {
|
||||
t.Fatalf("git init: %v", err)
|
||||
|
|
@ -1217,7 +1216,7 @@ func TestInstallHooksBeads_HuskyV8Helper(t *testing.T) {
|
|||
{"config", "user.email", "test@test.com"},
|
||||
{"config", "user.name", "Test"},
|
||||
} {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config %v: %v", args, err)
|
||||
|
|
@ -1308,13 +1307,13 @@ s=$(dirname "$(dirname "$0")")/$n
|
|||
}
|
||||
|
||||
// Set core.hooksPath to .husky/_/ (husky v9 style)
|
||||
setGlobal := exec.Command("git", "config", "--global", "core.hooksPath", huskyInner)
|
||||
setGlobal := gitCommand("config", "--global", "core.hooksPath", huskyInner)
|
||||
if out, err := setGlobal.CombinedOutput(); err != nil {
|
||||
t.Fatalf("set global core.hooksPath: %v (%s)", err, strings.TrimSpace(string(out)))
|
||||
}
|
||||
|
||||
repoDir := t.TempDir()
|
||||
initCmd := exec.Command("git", "init", "--initial-branch=main")
|
||||
initCmd := gitCommand("init", "--initial-branch=main")
|
||||
initCmd.Dir = repoDir
|
||||
if err := initCmd.Run(); err != nil {
|
||||
t.Fatalf("git init: %v", err)
|
||||
|
|
@ -1323,7 +1322,7 @@ s=$(dirname "$(dirname "$0")")/$n
|
|||
{"config", "user.email", "test@test.com"},
|
||||
{"config", "user.name", "Test"},
|
||||
} {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git config %v: %v", args, err)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
|
|
@ -34,7 +33,7 @@ func TestProxiedInitRemoteURLUsesSelectedProject(t *testing.T) {
|
|||
}
|
||||
runGit := func(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
@ -105,7 +104,7 @@ func TestProxiedInitRemoteURLUsesSelectedProject(t *testing.T) {
|
|||
t.Setenv("GIT_CONFIG_COUNT", "1")
|
||||
t.Setenv("GIT_CONFIG_KEY_0", "url.file:///inline-origin.insteadOf")
|
||||
t.Setenv("GIT_CONFIG_VALUE_0", selectedURL)
|
||||
probe := exec.Command("git", "remote", "get-url", "origin")
|
||||
probe := gitCommand("remote", "get-url", "origin")
|
||||
probe.Dir = target // Prove this row distinguishes inherited inline config.
|
||||
out, err := probe.CombinedOutput()
|
||||
require.NoError(t, err, "%s", out)
|
||||
|
|
@ -379,7 +378,7 @@ func TestProxiedInitTailRoleIgnoresInheritedGitRouting(t *testing.T) {
|
|||
require.NoError(t, os.WriteFile(globalPath, nil, 0600))
|
||||
runGit := func(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
@ -455,7 +454,7 @@ func TestProxiedInitTailRoleProbeUsesSelectedDirectory(t *testing.T) {
|
|||
t.Setenv("GIT_CONFIG_NOSYSTEM", "1")
|
||||
runGit := func(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
@ -496,7 +495,7 @@ func TestProxiedInitTailRoleProbeUsesSelectedDirectory(t *testing.T) {
|
|||
if tc.initial != "" {
|
||||
runGit(t, target, "config", "--local", "beads.role", tc.initial)
|
||||
}
|
||||
probe := exec.Command("git", "rev-parse", "--git-dir")
|
||||
probe := gitCommand("rev-parse", "--git-dir")
|
||||
probe.Dir, probe.Env = target, gitenv.ScrubRouting(os.Environ())
|
||||
require.Equal(t, tc.kind != "nonrepo", probe.Run() == nil, "owned target repository precondition")
|
||||
if tc.kind == "nonrepo" {
|
||||
|
|
@ -567,7 +566,7 @@ func TestProxiedInitTailGitUsesSelectedDirectory(t *testing.T) {
|
|||
}
|
||||
runGit := func(dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
|
|
@ -18,7 +17,7 @@ import (
|
|||
|
||||
func initRoleFixtureGit(t *testing.T, repo string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = repo
|
||||
cmd.Env = gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
|
|
@ -483,7 +482,7 @@ func TestContributorPlanningGitIgnoresInheritedRouting(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("git", "show", "HEAD:README.md")
|
||||
cmd := gitCommand("show", "HEAD:README.md")
|
||||
cmd.Dir, cmd.Env = planning, gitenv.ScrubRouting(os.Environ())
|
||||
if committed, err := cmd.Output(); err != nil || string(committed) != string(readme) {
|
||||
t.Errorf("planning README commit differs from created bytes: %v", err)
|
||||
|
|
@ -597,7 +596,7 @@ func TestInitArtifactGitRouting(t *testing.T) {
|
|||
if err := os.WriteFile(foreignIndex, index, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
stage := exec.Command("git", "add", ".beads/fixture")
|
||||
stage := gitCommand("add", ".beads/fixture")
|
||||
stage.Dir, stage.Env = decoy, append(gitenv.ScrubRouting(os.Environ()), "GIT_INDEX_FILE="+foreignIndex)
|
||||
if out, err := stage.CombinedOutput(); err != nil {
|
||||
t.Fatalf("prepare actual foreign index: %v: %s", err, out)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func TestBeadsRoleWriterIgnoresInheritedGitRouting(t *testing.T) {
|
|||
// value physically landed rather than what discovery would resolve to.
|
||||
localRole := func(t *testing.T, repo string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "config", "--local", "--get", "beads.role")
|
||||
cmd := gitCommand("config", "--local", "--get", "beads.role")
|
||||
cmd.Dir = repo
|
||||
cmd.Env = gitenv.ScrubRoutingAndSuppression(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
|
|
@ -50,7 +50,7 @@ func TestBeadsRoleWriterIgnoresInheritedGitRouting(t *testing.T) {
|
|||
}
|
||||
setLocalRole := func(t *testing.T, repo, role string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "config", "--local", "beads.role", role)
|
||||
cmd := gitCommand("config", "--local", "beads.role", role)
|
||||
cmd.Dir = repo
|
||||
cmd.Env = gitenv.ScrubRoutingAndSuppression(os.Environ())
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
|
@ -26,10 +25,10 @@ func TestSetupGitExclude_Worktree(t *testing.T) {
|
|||
if err := os.WriteFile(dummyFile, []byte("# Test\n"), 0644); err != nil {
|
||||
t.Fatalf("failed to create dummy file: %v", err)
|
||||
}
|
||||
cmd := exec.Command("git", "add", ".")
|
||||
cmd := gitCommand("add", ".")
|
||||
cmd.Dir = mainDir
|
||||
_ = cmd.Run()
|
||||
cmd = exec.Command("git", "commit", "-m", "initial")
|
||||
cmd = gitCommand("commit", "-m", "initial")
|
||||
cmd.Dir = mainDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to create initial commit: %v", err)
|
||||
|
|
@ -37,7 +36,7 @@ func TestSetupGitExclude_Worktree(t *testing.T) {
|
|||
|
||||
// Create worktree
|
||||
worktreeDir := filepath.Join(t.TempDir(), "worktree")
|
||||
cmd = exec.Command("git", "worktree", "add", worktreeDir, "-b", "feature")
|
||||
cmd = gitCommand("worktree", "add", worktreeDir, "-b", "feature")
|
||||
cmd.Dir = mainDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to create worktree: %v", err)
|
||||
|
|
@ -70,7 +69,7 @@ func TestSetupGitExclude_Worktree(t *testing.T) {
|
|||
|
||||
// Verify: worktree's .git/worktrees/<name>/info/exclude should NOT exist
|
||||
// (or should not have the patterns if it exists)
|
||||
worktreeGitDir, err := exec.Command("git", "-C", worktreeDir, "rev-parse", "--git-dir").Output()
|
||||
worktreeGitDir, err := gitCommand("-C", worktreeDir, "rev-parse", "--git-dir").Output()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get worktree git dir: %v", err)
|
||||
}
|
||||
|
|
@ -95,10 +94,10 @@ func TestSetupForkExclude_Worktree(t *testing.T) {
|
|||
if err := os.WriteFile(dummyFile, []byte("# Test\n"), 0644); err != nil {
|
||||
t.Fatalf("failed to create dummy file: %v", err)
|
||||
}
|
||||
cmd := exec.Command("git", "add", ".")
|
||||
cmd := gitCommand("add", ".")
|
||||
cmd.Dir = mainDir
|
||||
_ = cmd.Run()
|
||||
cmd = exec.Command("git", "commit", "-m", "initial")
|
||||
cmd = gitCommand("commit", "-m", "initial")
|
||||
cmd.Dir = mainDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to create initial commit: %v", err)
|
||||
|
|
@ -106,7 +105,7 @@ func TestSetupForkExclude_Worktree(t *testing.T) {
|
|||
|
||||
// Create worktree
|
||||
worktreeDir := filepath.Join(t.TempDir(), "worktree")
|
||||
cmd = exec.Command("git", "worktree", "add", worktreeDir, "-b", "feature")
|
||||
cmd = gitCommand("worktree", "add", worktreeDir, "-b", "feature")
|
||||
cmd.Dir = mainDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to create worktree: %v", err)
|
||||
|
|
@ -136,7 +135,7 @@ func TestSetupForkExclude_Worktree(t *testing.T) {
|
|||
|
||||
// Verify: worktree's .git/worktrees/<name>/info/exclude should NOT exist
|
||||
// (or should not have the patterns if it exists)
|
||||
worktreeGitDir, err := exec.Command("git", "-C", worktreeDir, "rev-parse", "--git-dir").Output()
|
||||
worktreeGitDir, err := gitCommand("-C", worktreeDir, "rev-parse", "--git-dir").Output()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get worktree git dir: %v", err)
|
||||
}
|
||||
|
|
@ -518,7 +517,7 @@ func TestAddExcludePatternsPreservesAppendLineEndings(t *testing.T) {
|
|||
if err := os.WriteFile(gitignorePath, []byte(tracked), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if out, err := exec.Command("git", "-C", dir, "add", "--", ".gitignore").CombinedOutput(); err != nil {
|
||||
if out, err := gitCommand("-C", dir, "add", "--", ".gitignore").CombinedOutput(); err != nil {
|
||||
t.Fatalf("track .gitignore: %v: %s", err, out)
|
||||
}
|
||||
path, err := resolveGitExcludePath(dir)
|
||||
|
|
@ -624,7 +623,7 @@ func TestAddExcludePatternsCreatesMissingFile(t *testing.T) {
|
|||
|
||||
func initExcludeGit(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
|
|||
|
|
@ -1088,12 +1088,12 @@ func TestInitContributorSetsBeadsRoleContributor(t *testing.T) {
|
|||
t.Chdir(tmpDir)
|
||||
|
||||
// Owned local remotes prevent network lookups during initialization.
|
||||
cmd := exec.Command("git", "remote", "add", "origin", newGitRepo(t))
|
||||
cmd := gitCommand("remote", "add", "origin", newGitRepo(t))
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to add origin remote: %v", err)
|
||||
}
|
||||
cmd = exec.Command("git", "remote", "add", "upstream", newGitRepo(t))
|
||||
cmd = gitCommand("remote", "add", "upstream", newGitRepo(t))
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to add upstream remote: %v", err)
|
||||
|
|
@ -1153,7 +1153,7 @@ func TestInitNonInteractiveAlwaysSetsRole(t *testing.T) {
|
|||
t.Chdir(tmpDir)
|
||||
|
||||
// Ensure no role is set before init
|
||||
exec.Command("git", "config", "--unset", "beads.role").Run() //nolint:errcheck
|
||||
gitCommand("config", "--unset", "beads.role").Run() //nolint:errcheck
|
||||
|
||||
rootCmd.SetArgs([]string{"init", "--prefix", "test", "--quiet", "--non-interactive"})
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
|
|
@ -1527,7 +1527,7 @@ func TestInitBEADS_DIR(t *testing.T) {
|
|||
}
|
||||
runGit := func(dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -2000,7 +2000,7 @@ func setupBareParentInitWorktree(t *testing.T) (string, string) {
|
|||
|
||||
runGit := func(dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -2012,14 +2012,14 @@ func setupBareParentInitWorktree(t *testing.T) (string, string) {
|
|||
runGit(tmpDir, "--git-dir", bareDir, "symbolic-ref", "HEAD", "refs/heads/main")
|
||||
runGit(tmpDir, "--git-dir", bareDir, "config", "user.email", "test@example.com")
|
||||
runGit(tmpDir, "--git-dir", bareDir, "config", "user.name", "Test User")
|
||||
emptyTreeCmd := exec.Command("git", "--git-dir", bareDir, "hash-object", "-t", "tree", "/dev/null")
|
||||
emptyTreeCmd := gitCommand("--git-dir", bareDir, "hash-object", "-t", "tree", "/dev/null")
|
||||
emptyTreeCmd.Dir = tmpDir
|
||||
emptyTreeOut, err := emptyTreeCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("git hash-object failed: %v\n%s", err, emptyTreeOut)
|
||||
}
|
||||
emptyTree := strings.TrimSpace(string(emptyTreeOut))
|
||||
commitCmd := exec.Command("git", "--git-dir", bareDir, "commit-tree", "-m", "Initial commit", emptyTree)
|
||||
commitCmd := gitCommand("--git-dir", bareDir, "commit-tree", "-m", "Initial commit", emptyTree)
|
||||
commitCmd.Dir = tmpDir
|
||||
commitOut, err := commitCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -2567,11 +2567,11 @@ func TestInitDatabaseAdoptsExistingProjectID(t *testing.T) {
|
|||
t.Chdir(secondDir)
|
||||
|
||||
// Set up minimal git repo (init expects it for repo_id)
|
||||
if err := exec.Command("git", "-C", secondDir, "init").Run(); err != nil {
|
||||
if err := gitCommand("-C", secondDir, "init").Run(); err != nil {
|
||||
t.Fatalf("git init: %v", err)
|
||||
}
|
||||
_ = exec.Command("git", "-C", secondDir, "config", "user.email", "test@test.com").Run()
|
||||
_ = exec.Command("git", "-C", secondDir, "config", "user.name", "Test").Run()
|
||||
_ = gitCommand("-C", secondDir, "config", "user.email", "test@test.com").Run()
|
||||
_ = gitCommand("-C", secondDir, "config", "user.name", "Test").Run()
|
||||
|
||||
rootCmd.SetArgs([]string{
|
||||
"init",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -24,7 +23,7 @@ func TestCountExistingIssues_WorktreeFallback(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -42,13 +41,13 @@ func TestCountExistingIssues_WorktreeFallback(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepoDir
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
@ -108,7 +107,7 @@ func TestCountExistingIssues_WorktreeLocalBeadsPreferred(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -124,13 +123,13 @@ func TestCountExistingIssues_WorktreeLocalBeadsPreferred(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
@ -181,7 +180,7 @@ func TestCountExistingIssues_WorktreeNoBeadsAnywhere(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(dir string, args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -197,13 +196,13 @@ func TestCountExistingIssues_WorktreeNoBeadsAnywhere(t *testing.T) {
|
|||
run(mainRepoDir, "commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cleanupCmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cleanupCmd.Dir = mainRepoDir
|
||||
_ = cleanupCmd.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -333,7 +332,7 @@ func setupHookMigrationRepo(t *testing.T) (repoDir string, hooksDir string) {
|
|||
repoDir = newGitRepo(t)
|
||||
|
||||
runInDir(t, repoDir, func() {
|
||||
cmd := exec.Command("git", "config", "core.hooksPath", ".git/hooks")
|
||||
cmd := gitCommand("config", "core.hooksPath", ".git/hooks")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to set core.hooksPath: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ func setupContributorRouting(t *testing.T, bd, dir string) string {
|
|||
t.Helper()
|
||||
planningDir := t.TempDir()
|
||||
// Init a minimal git repo in the planning dir.
|
||||
exec.Command("git", "init", planningDir).Run() //nolint:errcheck
|
||||
gitCommand("init", planningDir).Run() //nolint:errcheck
|
||||
// Initialize beads in planning dir.
|
||||
initCmd := exec.Command(bd, "init", "--prefix", "pl", "--quiet")
|
||||
initCmd.Dir = planningDir
|
||||
|
|
@ -84,7 +84,7 @@ func TestMigratePersonal_movesIssues(t *testing.T) {
|
|||
planningDir := setupContributorRouting(t, bd, dir)
|
||||
|
||||
// Create issues with the git identity (getActorWithGit will use git user.name).
|
||||
gitName, _ := exec.Command("git", "config", "--global", "user.name").Output()
|
||||
gitName, _ := gitCommand("config", "--global", "user.name").Output()
|
||||
actor := strings.TrimSpace(string(gitName))
|
||||
if actor == "" {
|
||||
actor = "Test"
|
||||
|
|
@ -132,7 +132,7 @@ func TestMigratePersonal_abortOnNoConfirm(t *testing.T) {
|
|||
setupContributorRouting(t, bd, dir)
|
||||
|
||||
// Create an issue owned by current git user.
|
||||
gitName, _ := exec.Command("git", "config", "--global", "user.name").Output()
|
||||
gitName, _ := gitCommand("config", "--global", "user.name").Output()
|
||||
actor := strings.TrimSpace(string(gitName))
|
||||
if actor == "" {
|
||||
actor = "Test"
|
||||
|
|
@ -178,7 +178,7 @@ func TestMigratePersonal_preservesComments(t *testing.T) {
|
|||
dir, _, _ := bdInit(t, bd, "--prefix", "mpc")
|
||||
planningDir := setupContributorRouting(t, bd, dir)
|
||||
|
||||
gitName, _ := exec.Command("git", "config", "--global", "user.name").Output()
|
||||
gitName, _ := gitCommand("config", "--global", "user.name").Output()
|
||||
actor := strings.TrimSpace(string(gitName))
|
||||
if actor == "" {
|
||||
actor = "Test"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -17,7 +16,7 @@ func TestProxiedServerOrphans(t *testing.T) {
|
|||
|
||||
gitCommit := func(t *testing.T, message string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", "commit", "--allow-empty", "-m", message)
|
||||
cmd := gitCommand("commit", "--allow-empty", "-m", message)
|
||||
cmd.Dir = p.dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git commit: %v\n%s", err, out)
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ func primeChangeDirRedirectClone(t *testing.T, storeBeadsDir string) string {
|
|||
|
||||
func primeChangeDirGit(t *testing.T, dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(),
|
||||
"GIT_AUTHOR_NAME=bd-test", "GIT_AUTHOR_EMAIL=bd-test@example.com",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -25,7 +24,7 @@ func setupWorktree(t *testing.T) (mainRepoDir, worktreeDir string) {
|
|||
}
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Skipf("git %v failed: %v", args, err)
|
||||
|
|
@ -43,13 +42,13 @@ func setupWorktree(t *testing.T) (mainRepoDir, worktreeDir string) {
|
|||
run("commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir = filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepoDir
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -24,7 +23,7 @@ func TestReset_WorktreeFindsBeadsDir(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -42,13 +41,13 @@ func TestReset_WorktreeFindsBeadsDir(t *testing.T) {
|
|||
run("commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepoDir
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
@ -113,7 +112,7 @@ func TestReset_WorktreeNoBeadsReturnsEmpty(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -129,13 +128,13 @@ func TestReset_WorktreeNoBeadsReturnsEmpty(t *testing.T) {
|
|||
run("commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepoDir
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
@ -162,7 +161,7 @@ func TestReset_WorktreeSubdirFindsBeadsDir(t *testing.T) {
|
|||
}
|
||||
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v failed: %v\n%s", args, err, out)
|
||||
|
|
@ -178,13 +177,13 @@ func TestReset_WorktreeSubdirFindsBeadsDir(t *testing.T) {
|
|||
run("commit", "-m", "Initial commit")
|
||||
|
||||
worktreeDir := filepath.Join(tmpDir, "worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreeDir, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreeDir, "HEAD")
|
||||
cmd.Dir = mainRepoDir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git worktree add failed: %v\n%s", err, out)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepoDir
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -187,7 +186,7 @@ func TestGitURLToDoltRemote(t *testing.T) {
|
|||
func runGitForSyncTest(t *testing.T, dir string, args ...string) {
|
||||
t.Helper()
|
||||
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
if dir != "" {
|
||||
cmd.Dir = dir
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -119,7 +118,7 @@ func TestCommitBeadsConfigSkipsGitHooks(t *testing.T) {
|
|||
|
||||
func runGitForCommitConfigTest(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ func buildBDForInitTests(t *testing.T) string {
|
|||
// fails the test on error. Used by bootstrap and init-safety subprocess tests.
|
||||
func runGitForBootstrapTest(t *testing.T, dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
if dir != "" {
|
||||
cmd.Dir = dir
|
||||
}
|
||||
|
|
@ -469,7 +469,7 @@ func initGitRepoAt(t *testing.T, dir string) {
|
|||
// Force repo-local hooks so tests ignore any global hooksPath override.
|
||||
{"config", "core.hooksPath", ".git/hooks"},
|
||||
} {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %s failed: %v\n%s", args[0], err, out)
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ func worktreeFallbackBeadsDirDirect(repoRoot string) string {
|
|||
if repoRoot == "" {
|
||||
return ""
|
||||
}
|
||||
cmd := exec.Command("git", "-C", repoRoot, "rev-parse", "--git-dir", "--git-common-dir")
|
||||
cmd := gitCommand("-C", repoRoot, "rev-parse", "--git-dir", "--git-common-dir")
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -74,8 +73,8 @@ func setupGitRepo(t *testing.T) (repoPath string, cleanup func()) {
|
|||
_ = os.Chdir(originalWd)
|
||||
t.Fatalf("failed to write test file: %v", err)
|
||||
}
|
||||
_ = exec.Command("git", "add", ".").Run()
|
||||
if err := exec.Command("git", "commit", "-m", "initial").Run(); err != nil {
|
||||
_ = gitCommand("add", ".").Run()
|
||||
if err := gitCommand("commit", "-m", "initial").Run(); err != nil {
|
||||
_ = os.Chdir(originalWd)
|
||||
t.Fatalf("failed to create initial commit: %v", err)
|
||||
}
|
||||
|
|
@ -120,7 +119,7 @@ func setupGitRepoWithBranch(t *testing.T, branch string) (repoPath string, clean
|
|||
}
|
||||
// Switch to requested branch if different from template default
|
||||
if branch != "main" {
|
||||
if err := exec.Command("git", "checkout", "-b", branch).Run(); err != nil {
|
||||
if err := gitCommand("checkout", "-b", branch).Run(); err != nil {
|
||||
_ = os.Chdir(originalWd)
|
||||
t.Fatalf("failed to switch to branch %s: %v", branch, err)
|
||||
}
|
||||
|
|
@ -144,8 +143,8 @@ func setupGitRepoWithBranch(t *testing.T, branch string) (repoPath string, clean
|
|||
_ = os.Chdir(originalWd)
|
||||
t.Fatalf("failed to write test file: %v", err)
|
||||
}
|
||||
_ = exec.Command("git", "add", ".").Run()
|
||||
if err := exec.Command("git", "commit", "-m", "initial").Run(); err != nil {
|
||||
_ = gitCommand("add", ".").Run()
|
||||
if err := gitCommand("commit", "-m", "initial").Run(); err != nil {
|
||||
_ = os.Chdir(originalWd)
|
||||
t.Fatalf("failed to create initial commit: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func TestStandaloneHooksAbsoluteFallbackHasNoConfigAuthority(t *testing.T) {
|
|||
func TestUninstallHooksUnsetsBeadsRole(t *testing.T) {
|
||||
tmpDir := newGitRepo(t)
|
||||
runInDir(t, tmpDir, func() {
|
||||
cmd := exec.Command("git", "config", "beads.role", "primary")
|
||||
cmd := gitCommand("config", "beads.role", "primary")
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to set beads.role: %v", err)
|
||||
|
|
@ -67,7 +67,7 @@ func TestUninstallHooksUnsetsBeadsRole(t *testing.T) {
|
|||
t.Fatalf("uninstallHooks() failed: %v", err)
|
||||
}
|
||||
|
||||
getCmd := exec.Command("git", "config", "--local", "--get", "beads.role")
|
||||
getCmd := gitCommand("config", "--local", "--get", "beads.role")
|
||||
getCmd.Dir = tmpDir
|
||||
out, err := getCmd.Output()
|
||||
if err == nil {
|
||||
|
|
@ -96,7 +96,7 @@ func TestUninstallHooksReportsAmbiguousBeadsRole(t *testing.T) {
|
|||
tmpDir := newGitRepo(t)
|
||||
runInDir(t, tmpDir, func() {
|
||||
for _, value := range []string{"primary", "secondary"} {
|
||||
cmd := exec.Command("git", "config", "--add", "beads.role", value)
|
||||
cmd := gitCommand("config", "--add", "beads.role", value)
|
||||
cmd.Dir = tmpDir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to add beads.role=%s: %v", value, err)
|
||||
|
|
@ -112,7 +112,7 @@ func TestUninstallHooksReportsAmbiguousBeadsRole(t *testing.T) {
|
|||
}
|
||||
|
||||
// And the key really is still set — the error was not spurious.
|
||||
getCmd := exec.Command("git", "config", "--local", "--get-all", "beads.role")
|
||||
getCmd := gitCommand("config", "--local", "--get-all", "beads.role")
|
||||
getCmd.Dir = tmpDir
|
||||
out, getErr := getCmd.Output()
|
||||
if getErr != nil {
|
||||
|
|
@ -141,7 +141,7 @@ func TestResetHooksPathIfBeadsManagedReportsFailureLoudly(t *testing.T) {
|
|||
// There has to be something to unset, or there is no git invocation to
|
||||
// fail: the reset reads beads.role first and only unsets it when it is
|
||||
// actually present.
|
||||
setCmd := exec.Command("git", "config", "beads.role", "primary")
|
||||
setCmd := gitCommand("config", "beads.role", "primary")
|
||||
setCmd.Dir = tmpDir
|
||||
if err := setCmd.Run(); err != nil {
|
||||
t.Fatalf("failed to set beads.role: %v", err)
|
||||
|
|
@ -223,7 +223,7 @@ func TestResetRolePreservesSelectedGitContext(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
query := func(dir string, args ...string) ([]byte, error) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
return cmd.CombinedOutput()
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ func TestResetRolePreservesSelectedGitContext(t *testing.T) {
|
|||
t.Setenv("GIT_CONFIG_VALUE_0", "forged")
|
||||
case "selected_config":
|
||||
t.Setenv("GIT_CONFIG", filepath.Join(decoy, ".git", "config"))
|
||||
probe := exec.Command("git", "--git-dir", selected, "config", "beads.routing-test", "selected-file")
|
||||
probe := gitCommand("--git-dir", selected, "config", "beads.routing-test", "selected-file")
|
||||
probe.Dir = cwd // This fixture precondition deliberately inherits GIT_CONFIG.
|
||||
if out, err := probe.CombinedOutput(); err != nil {
|
||||
t.Fatalf("selected-file probe: %v\n%s", err, out)
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@ func TestMetricsOffRejectsUnsafeUserRootsInNativeProcess(t *testing.T) {
|
|||
"BEADS_TEST_MODE=1",
|
||||
)
|
||||
|
||||
gitInit := exec.Command("git", "init", "--quiet")
|
||||
gitInit := gitCommand("init", "--quiet")
|
||||
gitInit.Dir = sentinel
|
||||
gitInit.Env = initEnv
|
||||
if out, err := gitInit.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git init: %v\n%s", err, out)
|
||||
}
|
||||
gitHooks := exec.Command("git", "config", "core.hooksPath", ".git/hooks")
|
||||
gitHooks := gitCommand("config", "core.hooksPath", ".git/hooks")
|
||||
gitHooks.Dir = sentinel
|
||||
gitHooks.Env = initEnv
|
||||
if out, err := gitHooks.CombinedOutput(); err != nil {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -284,13 +283,13 @@ func TestEnsureCreatedWorktreeCleanRejectsDirtyWorktree(t *testing.T) {
|
|||
commitTestFile(t, repoRoot, "README.md", "# Test\n", "initial commit")
|
||||
|
||||
worktreePath := filepath.Join(t.TempDir(), "dirty-worktree")
|
||||
cmd := exec.Command("git", "worktree", "add", worktreePath, "HEAD")
|
||||
cmd := gitCommand("worktree", "add", worktreePath, "HEAD")
|
||||
cmd.Dir = repoRoot
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("failed to create worktree: %v\n%s", err, output)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreePath)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreePath)
|
||||
cmd.Dir = repoRoot
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
@ -366,7 +365,7 @@ func initGitRepoForGitignoreTest(t *testing.T) string {
|
|||
t.Helper()
|
||||
repoRoot := t.TempDir()
|
||||
|
||||
cmd := exec.Command("git", "init")
|
||||
cmd := gitCommand("init")
|
||||
cmd.Dir = repoRoot
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("failed to init git repo: %v\n%s", err, string(output))
|
||||
|
|
@ -384,12 +383,12 @@ func commitTestFile(t *testing.T, repoRoot, relPath, content, message string) {
|
|||
if err := os.WriteFile(path, []byte(content), 0644); err != nil {
|
||||
t.Fatalf("failed to write %s: %v", relPath, err)
|
||||
}
|
||||
cmd := exec.Command("git", "add", relPath)
|
||||
cmd := gitCommand("add", relPath)
|
||||
cmd.Dir = repoRoot
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git add %s failed: %v\n%s", relPath, err, output)
|
||||
}
|
||||
cmd = exec.Command("git", "commit", "-m", message)
|
||||
cmd = gitCommand("commit", "-m", message)
|
||||
cmd.Dir = repoRoot
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git commit failed: %v\n%s", err, output)
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func TestWorktreeRemoveProcessHelper(t *testing.T) {
|
|||
}
|
||||
|
||||
func runWorktreeRemoveHookGit(dir string, args ...string) error {
|
||||
command := exec.Command("git", args...)
|
||||
command := gitCommand(args...)
|
||||
command.Dir = dir
|
||||
command.Env = append(scrubWorktreeGitRoutingEnv(os.Environ()), "GIT_CONFIG_GLOBAL="+os.DevNull, "GIT_CONFIG_SYSTEM="+os.DevNull, "GIT_CONFIG_NOSYSTEM=1", "GIT_NO_REPLACE_OBJECTS=1")
|
||||
output, err := command.CombinedOutput()
|
||||
|
|
@ -444,7 +444,7 @@ func (fixture *worktreeRemovalFixture) assertRemovedAndCleaned(t *testing.T) {
|
|||
}
|
||||
func (fixture *worktreeRemovalFixture) git(t *testing.T, directory string, args ...string) string {
|
||||
t.Helper()
|
||||
command := exec.Command("git", args...)
|
||||
command := gitCommand(args...)
|
||||
command.Dir = directory
|
||||
command.Env = append(scrubWorktreeGitRoutingEnv(os.Environ()), "GIT_CONFIG_GLOBAL="+os.DevNull, "GIT_CONFIG_SYSTEM="+os.DevNull, "GIT_CONFIG_NOSYSTEM=1", "GIT_NO_REPLACE_OBJECTS=1")
|
||||
output, err := command.CombinedOutput()
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ func TestWorktreeCommandsIgnoreInheritedGitRoutingState(t *testing.T) {
|
|||
commitTestFile(t, decoyMain, "README.md", "linked decoy\n", "decoy commit")
|
||||
writeTestConfigYAML(t, filepath.Join(decoyMain, ".beads"), "json: [\n")
|
||||
decoyLane := filepath.Join(t.TempDir(), "linked-decoy")
|
||||
command := exec.Command("git", "worktree", "add", "-b", "linked-decoy", decoyLane)
|
||||
command := gitCommand("worktree", "add", "-b", "linked-decoy", decoyLane)
|
||||
command.Dir = decoyMain
|
||||
if output, err := command.CombinedOutput(); err != nil {
|
||||
t.Fatalf("create decoy linked worktree: %v\n%s", err, output)
|
||||
|
|
@ -378,7 +378,7 @@ func decodeWorktreeCommandJSON(t *testing.T, output string, target any) {
|
|||
|
||||
func gitWorktreeRegistry(t *testing.T, repoDir string) string {
|
||||
t.Helper()
|
||||
command := exec.Command("git", "worktree", "list", "--porcelain")
|
||||
command := gitCommand("worktree", "list", "--porcelain")
|
||||
command.Dir = repoDir
|
||||
output, err := command.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -416,7 +416,7 @@ func assertGitWorktreePaths(t *testing.T, repoDir string, want ...string) {
|
|||
|
||||
func gitRevParsePath(t *testing.T, repoDir, selector string) string {
|
||||
t.Helper()
|
||||
command := exec.Command("git", "rev-parse", selector)
|
||||
command := gitCommand("rev-parse", selector)
|
||||
command.Dir = repoDir
|
||||
output, err := command.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -439,10 +439,10 @@ func TestResolveWorktreePathByName(t *testing.T) {
|
|||
if err := os.WriteFile(filepath.Join(mainDir, "README.md"), []byte("# Test\n"), 0644); err != nil {
|
||||
t.Fatalf("Failed to create test file: %v", err)
|
||||
}
|
||||
cmd := exec.Command("git", "add", ".")
|
||||
cmd := gitCommand("add", ".")
|
||||
cmd.Dir = mainDir
|
||||
_ = cmd.Run()
|
||||
cmd = exec.Command("git", "commit", "-m", "Initial commit")
|
||||
cmd = gitCommand("commit", "-m", "Initial commit")
|
||||
cmd.Dir = mainDir
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("Failed to create initial commit: %v\n%s", err, output)
|
||||
|
|
@ -456,14 +456,14 @@ func TestResolveWorktreePathByName(t *testing.T) {
|
|||
|
||||
// Create a worktree inside .worktrees/
|
||||
worktreePath := filepath.Join(worktreesDir, "test-wt")
|
||||
cmd = exec.Command("git", "worktree", "add", "-b", "test-wt", worktreePath)
|
||||
cmd = gitCommand("worktree", "add", "-b", "test-wt", worktreePath)
|
||||
cmd.Dir = mainDir
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("Failed to create worktree: %v\n%s", err, output)
|
||||
}
|
||||
defer func() {
|
||||
// Cleanup worktree
|
||||
cmd := exec.Command("git", "worktree", "remove", worktreePath, "--force")
|
||||
cmd := gitCommand("worktree", "remove", worktreePath, "--force")
|
||||
cmd.Dir = mainDir
|
||||
_ = cmd.Run()
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func resetFormulaSearchTestContext(t *testing.T) {
|
|||
|
||||
func runGitForFormulaTest(t *testing.T, dir string, args ...string) {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir = dir
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -160,7 +160,7 @@ func TestDefaultSearchPaths_UsesResolvedBeadsDirForWorktree(t *testing.T) {
|
|||
worktreeDir := filepath.Join(root, "worktree")
|
||||
runGitForFormulaTest(t, mainRepo, "worktree", "add", worktreeDir, "HEAD")
|
||||
t.Cleanup(func() {
|
||||
cmd := exec.Command("git", "worktree", "remove", "--force", worktreeDir)
|
||||
cmd := gitCommand("worktree", "remove", "--force", worktreeDir)
|
||||
cmd.Dir = mainRepo
|
||||
_ = cmd.Run()
|
||||
})
|
||||
|
|
@ -2287,3 +2287,14 @@ func TestParseJSON_StepMetadata(t *testing.T) {
|
|||
t.Errorf("Steps[0].Metadata[priority_level] = %v, want \"high\"", got)
|
||||
}
|
||||
}
|
||||
|
||||
// noAutoMaintenance keeps a fixture's git commit from spawning the detached
|
||||
// "git maintenance run --auto" child whose worktree-prune races the fixture's
|
||||
// next "git worktree add" (gastownhall/beads#7314, #7349). Flags ride the
|
||||
// command line, never env config: the routing-key scrub drops env config.
|
||||
var noAutoMaintenance = []string{"-c", "maintenance.auto=false", "-c", "gc.auto=0"}
|
||||
|
||||
// gitCommand builds a git command for a fixture with noAutoMaintenance applied.
|
||||
func gitCommand(args ...string) *exec.Cmd {
|
||||
return exec.Command("git", append(append([]string{}, noAutoMaintenance...), args...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,25 +17,25 @@ func setupTestRepo(t *testing.T) (repoPath string, cleanup func()) {
|
|||
if err := os.MkdirAll(repoPath, 0750); err != nil {
|
||||
t.Fatalf("Failed to create test repo directory: %v", err)
|
||||
}
|
||||
cmd := exec.Command("git", "init")
|
||||
cmd := gitCommand("init")
|
||||
cmd.Dir = repoPath
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("Failed to init git repo: %v\nOutput: %s", err, string(output))
|
||||
}
|
||||
cmd = exec.Command("git", "config", "user.email", "test@example.com")
|
||||
cmd = gitCommand("config", "user.email", "test@example.com")
|
||||
cmd.Dir = repoPath
|
||||
_ = cmd.Run()
|
||||
cmd = exec.Command("git", "config", "user.name", "Test User")
|
||||
cmd = gitCommand("config", "user.name", "Test User")
|
||||
cmd.Dir = repoPath
|
||||
_ = cmd.Run()
|
||||
beadsDir := filepath.Join(repoPath, ".beads")
|
||||
_ = os.MkdirAll(beadsDir, 0750)
|
||||
_ = os.WriteFile(filepath.Join(beadsDir, "test.jsonl"), []byte("test data\n"), 0644)
|
||||
_ = os.WriteFile(filepath.Join(repoPath, "other.txt"), []byte("other data\n"), 0644)
|
||||
cmd = exec.Command("git", "add", ".")
|
||||
cmd = gitCommand("add", ".")
|
||||
cmd.Dir = repoPath
|
||||
_ = cmd.Run()
|
||||
cmd = exec.Command("git", "commit", "-m", "Initial commit")
|
||||
cmd = gitCommand("commit", "-m", "Initial commit")
|
||||
cmd.Dir = repoPath
|
||||
_, _ = cmd.CombinedOutput()
|
||||
cleanup = func() {}
|
||||
|
|
@ -220,7 +220,7 @@ func TestGetGitHooksDirTildeExpansion(t *testing.T) {
|
|||
|
||||
ResetCaches()
|
||||
|
||||
cmd := exec.Command("git", "config", "core.hooksPath", tt.hooksPath)
|
||||
cmd := gitCommand("config", "core.hooksPath", tt.hooksPath)
|
||||
cmd.Dir = subRepoPath
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Skipf("git config rejected core.hooksPath %q: %v", tt.hooksPath, err)
|
||||
|
|
@ -279,7 +279,7 @@ func TestResolveHooksContext(t *testing.T) {
|
|||
cleanEnv := os.Environ()
|
||||
git := func(dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, cleanEnv
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
@ -500,3 +500,14 @@ func TestResolveHooksContext(t *testing.T) {
|
|||
check(t, link, cleanEnv, selected, filepath.Join(canonical(selected), ".git", "hooks"))
|
||||
})
|
||||
}
|
||||
|
||||
// noAutoMaintenance keeps a fixture's git commit from spawning the detached
|
||||
// "git maintenance run --auto" child whose worktree-prune races the fixture's
|
||||
// next "git worktree add" (gastownhall/beads#7314, #7349). Flags ride the
|
||||
// command line, never env config: the routing-key scrub drops env config.
|
||||
var noAutoMaintenance = []string{"-c", "maintenance.auto=false", "-c", "gc.auto=0"}
|
||||
|
||||
// gitCommand builds a git command for a fixture with noAutoMaintenance applied.
|
||||
func gitCommand(args ...string) *exec.Cmd {
|
||||
return exec.Command("git", append(append([]string{}, noAutoMaintenance...), args...)...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ func TestRoleConfigIgnoresInheritedGitRouting(t *testing.T) {
|
|||
}
|
||||
runGit := func(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
@ -441,7 +441,7 @@ func TestRoleConfigKeySpellingTakesScrubbedPath(t *testing.T) {
|
|||
}
|
||||
runGit := func(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
@ -487,7 +487,7 @@ func TestInitGitRepositoryUsesSelectedDirectory(t *testing.T) {
|
|||
}
|
||||
runGit := func(dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd := gitCommand(args...)
|
||||
cmd.Dir, cmd.Env = dir, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git %v: %s", args, out)
|
||||
|
|
@ -600,7 +600,7 @@ func TestInitGitRepositoryRoleIgnoresInheritedConfigSuppression(t *testing.T) {
|
|||
require.NoError(t, os.WriteFile(filepath.Join(home, ".gitconfig"), []byte("[beads]\n\trole = contributor\n"), 0600))
|
||||
// No local role in the target: the global file is the only place the answer
|
||||
// can come from, so blinding it is visible as a miss.
|
||||
initCmd := exec.Command("git", "init", "--quiet")
|
||||
initCmd := gitCommand("init", "--quiet")
|
||||
initCmd.Dir, initCmd.Env = target, gitenv.ScrubRouting(os.Environ())
|
||||
out, err := initCmd.CombinedOutput()
|
||||
require.NoError(t, err, "fixture git init: %s", out)
|
||||
|
|
@ -625,3 +625,14 @@ func TestInitGitRepositoryRoleIgnoresInheritedConfigSuppression(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
// noAutoMaintenance keeps a fixture's git commit from spawning the detached
|
||||
// "git maintenance run --auto" child whose worktree-prune races the fixture's
|
||||
// next "git worktree add" (gastownhall/beads#7314, #7349). Flags ride the
|
||||
// command line, never env config: the routing-key scrub drops env config.
|
||||
var noAutoMaintenance = []string{"-c", "maintenance.auto=false", "-c", "gc.auto=0"}
|
||||
|
||||
// gitCommand builds a git command for a fixture with noAutoMaintenance applied.
|
||||
func gitCommand(args ...string) *exec.Cmd {
|
||||
return exec.Command("git", append(append([]string{}, noAutoMaintenance...), args...)...)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue