Merge branch 'main' of https://github.com/steveyegge/beads
This commit is contained in:
1330
.beads/beads.jsonl
1330
.beads/beads.jsonl
File diff suppressed because one or more lines are too long
@@ -353,6 +353,7 @@ With --no-db: creates .beads/ directory and issues.jsonl file instead of SQLite
|
||||
|
||||
green := color.New(color.FgGreen).SprintFunc()
|
||||
cyan := color.New(color.FgCyan).SprintFunc()
|
||||
yellow := color.New(color.FgYellow).SprintFunc()
|
||||
|
||||
fmt.Printf("\n%s bd initialized successfully!\n\n", green("✓"))
|
||||
fmt.Printf(" Database: %s\n", cyan(initDBPath))
|
||||
@@ -751,7 +752,7 @@ exit 0
|
||||
return nil
|
||||
}
|
||||
|
||||
// mergeDriverInstalled checks if bd merge driver is configured
|
||||
// mergeDriverInstalled checks if bd merge driver is configured correctly
|
||||
func mergeDriverInstalled() bool {
|
||||
// Check git config for merge driver
|
||||
cmd := exec.Command("git", "config", "merge.beads.driver")
|
||||
@@ -760,6 +761,14 @@ func mergeDriverInstalled() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if using old invalid placeholders (%L/%R from versions <0.24.0)
|
||||
// Git only supports %O (base), %A (current), %B (other)
|
||||
driverConfig := strings.TrimSpace(string(output))
|
||||
if strings.Contains(driverConfig, "%L") || strings.Contains(driverConfig, "%R") {
|
||||
// Stale config with invalid placeholders - needs repair
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if .gitattributes has the merge driver configured
|
||||
gitattributesPath := ".gitattributes"
|
||||
content, err := os.ReadFile(gitattributesPath)
|
||||
|
||||
@@ -791,6 +791,63 @@ func TestInitMergeDriverAutoConfiguration(t *testing.T) {
|
||||
t.Errorf("Expected merge.beads.name to contain 'bd', got %q", name)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("auto-repair stale merge driver with invalid placeholders", func(t *testing.T) {
|
||||
// Reset global state
|
||||
origDBPath := dbPath
|
||||
defer func() { dbPath = origDBPath }()
|
||||
dbPath = ""
|
||||
|
||||
tmpDir := t.TempDir()
|
||||
originalWd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get working directory: %v", err)
|
||||
}
|
||||
defer os.Chdir(originalWd)
|
||||
|
||||
if err := os.Chdir(tmpDir); err != nil {
|
||||
t.Fatalf("Failed to change to temp directory: %v", err)
|
||||
}
|
||||
|
||||
// Initialize git repo
|
||||
if err := runCommandInDir(tmpDir, "git", "init"); err != nil {
|
||||
t.Fatalf("Failed to init git: %v", err)
|
||||
}
|
||||
|
||||
// Configure stale merge driver with old invalid placeholders (%L/%R)
|
||||
// This simulates a user who initialized with bd version <0.24.0
|
||||
if err := runCommandInDir(tmpDir, "git", "config", "merge.beads.driver", "bd merge %L %R"); err != nil {
|
||||
t.Fatalf("Failed to set stale git config: %v", err)
|
||||
}
|
||||
|
||||
// Create .gitattributes with merge driver
|
||||
gitattrsPath := filepath.Join(tmpDir, ".gitattributes")
|
||||
if err := os.WriteFile(gitattrsPath, []byte(".beads/beads.jsonl merge=beads\n"), 0644); err != nil {
|
||||
t.Fatalf("Failed to create .gitattributes: %v", err)
|
||||
}
|
||||
|
||||
// Run bd init - should detect stale config and repair it
|
||||
rootCmd.SetArgs([]string{"init", "--prefix", "test", "--quiet"})
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
t.Fatalf("Init failed: %v", err)
|
||||
}
|
||||
|
||||
// Verify merge driver was updated to correct placeholders
|
||||
driver, err := runCommandInDirWithOutput(tmpDir, "git", "config", "merge.beads.driver")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get merge.beads.driver: %v", err)
|
||||
}
|
||||
driver = strings.TrimSpace(driver)
|
||||
expected := "bd merge %A %O %A %B"
|
||||
if driver != expected {
|
||||
t.Errorf("Expected merge driver to be repaired to %q, got %q", expected, driver)
|
||||
}
|
||||
|
||||
// Verify it no longer contains invalid placeholders
|
||||
if strings.Contains(driver, "%L") || strings.Contains(driver, "%R") {
|
||||
t.Errorf("Merge driver should not contain invalid %%L or %%R placeholders, got %q", driver)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// TestReadFirstIssueFromJSONL_ValidFile verifies reading first issue from valid JSONL
|
||||
|
||||
Reference in New Issue
Block a user