fix: Resolve import test failures and add git to Nix build

- Remove broken import special case that created vc.db instead of using found database
- Add git to nativeBuildInputs in default.nix for tests
- Fix path comparison bug (symlink resolution caused prefix mismatch)
This commit is contained in:
Steve Yegge
2025-11-02 00:09:56 -07:00
parent 2b086951c4
commit 20b21fda42
2 changed files with 13 additions and 40 deletions

View File

@@ -5,7 +5,6 @@ import (
"os"
"path/filepath"
"slices"
"strings"
"sync"
"time"
@@ -154,45 +153,16 @@ var rootCmd = &cobra.Command{
// Initialize database path
if dbPath == "" {
cwd, err := os.Getwd()
localBeadsDir := ""
if err == nil {
localBeadsDir = filepath.Join(cwd, ".beads")
}
// Use public API to find database (same logic as extensions)
if foundDB := beads.FindDatabasePath(); foundDB != "" {
dbPath = foundDB
// Special case for import: if we found a database but there's a local .beads/
// directory without a database, prefer creating a local database
if cmd.Name() == cmdImport && localBeadsDir != "" {
if _, err := os.Stat(localBeadsDir); err == nil {
// Check if found database is NOT in the local .beads/ directory
if !strings.HasPrefix(dbPath, localBeadsDir+string(filepath.Separator)) {
// Use local .beads/vc.db instead for import
dbPath = filepath.Join(localBeadsDir, "vc.db")
}
}
}
} else {
// For import command, allow creating database if .beads/ directory exists
if cmd.Name() == cmdImport && localBeadsDir != "" {
if _, err := os.Stat(localBeadsDir); err == nil {
// .beads/ directory exists - set dbPath for import to create
dbPath = filepath.Join(localBeadsDir, "vc.db")
}
}
// If dbPath still not set, error out
if dbPath == "" {
// No database found - error out instead of falling back to ~/.beads
fmt.Fprintf(os.Stderr, "Error: no beads database found\n")
fmt.Fprintf(os.Stderr, "Hint: run 'bd init' to create a database in the current directory\n")
fmt.Fprintf(os.Stderr, " or set BEADS_DB environment variable to specify a database\n")
os.Exit(1)
}
}
// Use public API to find database (same logic as extensions)
if foundDB := beads.FindDatabasePath(); foundDB != "" {
dbPath = foundDB
} else {
// No database found - error out instead of falling back to ~/.beads
fmt.Fprintf(os.Stderr, "Error: no beads database found\n")
fmt.Fprintf(os.Stderr, "Hint: run 'bd init' to create a database in the current directory\n")
fmt.Fprintf(os.Stderr, " or set BEADS_DB environment variable to specify a database\n")
os.Exit(1)
}
}
// Set actor from flag, viper (env), or default

View File

@@ -11,6 +11,9 @@ pkgs.buildGoModule {
# Go module dependencies hash (computed via nix build)
vendorHash = "sha256-DJqTiLGLZNGhHXag50gHFXTVXCBdj8ytbYbPL3QAq8M=";
# Git is required for tests
nativeBuildInputs = [ pkgs.git ];
meta = with pkgs.lib; {
description = "beads (bd) - An issue tracker designed for AI-supervised coding workflows";
homepage = "https://github.com/steveyegge/beads";