Merge branch 'main' of github.com:steveyegge/beads

This commit is contained in:
Steve Yegge
2025-11-04 10:24:19 -08:00
3 changed files with 28 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"runtime"
"testing"
"time"
@@ -132,7 +133,13 @@ func TestDaemonAutoImportAfterGitPull(t *testing.T) {
runGitCmd(t, clone2Dir, "pull")
// Wait for filesystem to settle after git operations
time.Sleep(50 * time.Millisecond)
// Windows has lower filesystem timestamp precision (typically 100ms)
// and file I/O may be slower, so we need a longer delay
if runtime.GOOS == "windows" {
time.Sleep(500 * time.Millisecond)
} else {
time.Sleep(100 * time.Millisecond)
}
// Start daemon server in clone2
socketPath := filepath.Join(clone2BeadsDir, "bd.sock")

View File

@@ -563,6 +563,12 @@ func TestSyncBranchPull_Success(t *testing.T) {
t.Error("JSONL not copied to main repo after pull")
}
// On Windows, file I/O may need more time to settle
// Increase delay significantly for reliable CI tests
if runtime.GOOS == "windows" {
time.Sleep(300 * time.Millisecond)
}
// Verify JSONL content matches
clone1Data, err := os.ReadFile(clone1JSONLPath)
if err != nil {

View File

@@ -512,13 +512,19 @@ func detectDatabases(beadsDir string) ([]*dbInfo, error) {
}
func getDBVersion(dbPath string) string {
// Open database read-only
db, err := sql.Open("sqlite", dbPath+"?mode=ro")
// Open database read-only using file URI (same as production code)
connStr := "file:" + dbPath + "?mode=ro&_time_format=sqlite"
db, err := sql.Open("sqlite3", connStr)
if err != nil {
return "unknown"
}
defer db.Close()
// Ping to ensure connection is actually established
if err := db.Ping(); err != nil {
return "unknown"
}
// Try to read version from metadata table
var version string
err = db.QueryRow("SELECT value FROM metadata WHERE key = 'bd_version'").Scan(&version)
@@ -526,6 +532,7 @@ func getDBVersion(dbPath string) string {
return version
}
// If the row doesn't exist but table does, this is still a database with metadata
// Check if metadata table exists
var tableName string
err = db.QueryRow(`
@@ -537,6 +544,11 @@ func getDBVersion(dbPath string) string {
return "pre-0.17.5"
}
// Table exists but version query failed (probably no bd_version key)
if err == nil {
return "unknown"
}
return "unknown"
}