fix(tests): use --initial-branch=main for modern git compatibility
Modern git (2.28+) uses 'main' as default branch, not 'master'. Tests were failing because they assumed 'master' branch exists. Changes: - Use 'git init --initial-branch=main' instead of bare 'git init' - Change 'git checkout master' to 'git checkout main' - Add git.ResetCaches() after os.Chdir() to clear cached git state - Ensures test isolation when changing directories
This commit is contained in:
@@ -23,8 +23,8 @@ func setupGitRepo(t *testing.T) string {
|
||||
t.Fatalf("failed to create .beads directory: %v", err)
|
||||
}
|
||||
|
||||
// Initialize git repo
|
||||
cmd := exec.Command("git", "init")
|
||||
// Initialize git repo with 'main' as default branch (modern git convention)
|
||||
cmd := exec.Command("git", "init", "--initial-branch=main")
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to init git repo: %v", err)
|
||||
@@ -278,8 +278,8 @@ func setupGitRepoInDir(t *testing.T, dir string) {
|
||||
t.Fatalf("failed to create .beads directory: %v", err)
|
||||
}
|
||||
|
||||
// Initialize git repo
|
||||
cmd := exec.Command("git", "init")
|
||||
// Initialize git repo with 'main' as default branch (modern git convention)
|
||||
cmd := exec.Command("git", "init", "--initial-branch=main")
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("failed to init git repo: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user