bd sync: 2025-12-27 15:56:42

This commit is contained in:
Steve Yegge
2025-12-27 15:56:42 -08:00
parent 87f535a65e
commit c8b912cbe6
179 changed files with 3051 additions and 10283 deletions

View File

@@ -7,7 +7,6 @@ import (
"testing"
"github.com/steveyegge/beads/internal/config"
"github.com/steveyegge/beads/internal/git"
// Import SQLite driver for test database creation
_ "github.com/ncruces/go-sqlite3/driver"
@@ -71,20 +70,14 @@ func TestShouldDisableDaemonForWorktree(t *testing.T) {
// Change to the worktree directory
origDir, _ := os.Getwd()
defer func() {
defer func() {
_ = os.Chdir(origDir)
// Reset git caches after changing directory
git.ResetCaches()
// Reinitialize config to restore original state
_ = config.Initialize()
}()
if err := os.Chdir(worktreeDir); err != nil {
t.Fatalf("Failed to change to worktree dir: %v", err)
}
git.ResetCaches()
// Reset git caches after changing directory (required for IsWorktree to re-detect)
git.ResetCaches()
// No sync-branch configured
os.Unsetenv("BEADS_SYNC_BRANCH")
@@ -113,18 +106,13 @@ func TestShouldDisableDaemonForWorktree(t *testing.T) {
// Change to the worktree directory
origDir, _ := os.Getwd()
defer func() {
defer func() {
_ = os.Chdir(origDir)
git.ResetCaches()
_ = config.Initialize()
}()
if err := os.Chdir(worktreeDir); err != nil {
t.Fatalf("Failed to change to worktree dir: %v", err)
}
git.ResetCaches()
// Reset git caches after changing directory
git.ResetCaches()
// Reinitialize config to pick up the new directory's config.yaml
if err := config.Initialize(); err != nil {
@@ -149,18 +137,13 @@ func TestShouldDisableDaemonForWorktree(t *testing.T) {
// Change to the worktree directory
origDir, _ := os.Getwd()
defer func() {
defer func() {
_ = os.Chdir(origDir)
git.ResetCaches()
_ = config.Initialize()
}()
if err := os.Chdir(worktreeDir); err != nil {
t.Fatalf("Failed to change to worktree dir: %v", err)
}
git.ResetCaches()
// Reset git caches after changing directory
git.ResetCaches()
// Reinitialize config to pick up the new directory's config.yaml
if err := config.Initialize(); err != nil {
@@ -204,18 +187,13 @@ func TestShouldAutoStartDaemonWorktreeIntegration(t *testing.T) {
// Change to the worktree directory
origDir, _ := os.Getwd()
defer func() {
defer func() {
_ = os.Chdir(origDir)
git.ResetCaches()
_ = config.Initialize()
}()
if err := os.Chdir(worktreeDir); err != nil {
t.Fatalf("Failed to change to worktree dir: %v", err)
}
git.ResetCaches()
// Reset git caches after changing directory
git.ResetCaches()
// Clear all daemon-related env vars
os.Unsetenv("BEADS_NO_DAEMON")
@@ -242,18 +220,13 @@ func TestShouldAutoStartDaemonWorktreeIntegration(t *testing.T) {
// Change to the worktree directory
origDir, _ := os.Getwd()
defer func() {
defer func() {
_ = os.Chdir(origDir)
git.ResetCaches()
_ = config.Initialize()
}()
if err := os.Chdir(worktreeDir); err != nil {
t.Fatalf("Failed to change to worktree dir: %v", err)
}
git.ResetCaches()
// Reset git caches after changing directory
git.ResetCaches()
// Reinitialize config to pick up the new directory's config.yaml
if err := config.Initialize(); err != nil {
@@ -280,18 +253,13 @@ func TestShouldAutoStartDaemonWorktreeIntegration(t *testing.T) {
// Change to the worktree directory
origDir, _ := os.Getwd()
defer func() {
defer func() {
_ = os.Chdir(origDir)
git.ResetCaches()
_ = config.Initialize()
}()
if err := os.Chdir(worktreeDir); err != nil {
t.Fatalf("Failed to change to worktree dir: %v", err)
}
git.ResetCaches()
// Reset git caches after changing directory
git.ResetCaches()
// Reinitialize config to pick up the new directory's config.yaml
if err := config.Initialize(); err != nil {
@@ -334,8 +302,8 @@ func setupWorktreeTestRepo(t *testing.T) (mainDir, worktreeDir string) {
// Create main repo directory
mainDir = t.TempDir()
// Initialize git repo with 'main' as default branch (modern git convention)
cmd := exec.Command("git", "init", "--initial-branch=main")
// Initialize git repo
cmd := exec.Command("git", "init")
cmd.Dir = mainDir
if output, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("Failed to init git repo: %v\n%s", err, output)