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:
@@ -5,7 +5,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -154,45 +153,16 @@ var rootCmd = &cobra.Command{
|
|||||||
|
|
||||||
// Initialize database path
|
// Initialize database path
|
||||||
if dbPath == "" {
|
if dbPath == "" {
|
||||||
cwd, err := os.Getwd()
|
// Use public API to find database (same logic as extensions)
|
||||||
localBeadsDir := ""
|
if foundDB := beads.FindDatabasePath(); foundDB != "" {
|
||||||
if err == nil {
|
dbPath = foundDB
|
||||||
localBeadsDir = filepath.Join(cwd, ".beads")
|
} else {
|
||||||
}
|
// No database found - error out instead of falling back to ~/.beads
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: no beads database found\n")
|
||||||
// Use public API to find database (same logic as extensions)
|
fmt.Fprintf(os.Stderr, "Hint: run 'bd init' to create a database in the current directory\n")
|
||||||
if foundDB := beads.FindDatabasePath(); foundDB != "" {
|
fmt.Fprintf(os.Stderr, " or set BEADS_DB environment variable to specify a database\n")
|
||||||
dbPath = foundDB
|
os.Exit(1)
|
||||||
|
}
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set actor from flag, viper (env), or default
|
// Set actor from flag, viper (env), or default
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ pkgs.buildGoModule {
|
|||||||
# Go module dependencies hash (computed via nix build)
|
# Go module dependencies hash (computed via nix build)
|
||||||
vendorHash = "sha256-DJqTiLGLZNGhHXag50gHFXTVXCBdj8ytbYbPL3QAq8M=";
|
vendorHash = "sha256-DJqTiLGLZNGhHXag50gHFXTVXCBdj8ytbYbPL3QAq8M=";
|
||||||
|
|
||||||
|
# Git is required for tests
|
||||||
|
nativeBuildInputs = [ pkgs.git ];
|
||||||
|
|
||||||
meta = with pkgs.lib; {
|
meta = with pkgs.lib; {
|
||||||
description = "beads (bd) - An issue tracker designed for AI-supervised coding workflows";
|
description = "beads (bd) - An issue tracker designed for AI-supervised coding workflows";
|
||||||
homepage = "https://github.com/steveyegge/beads";
|
homepage = "https://github.com/steveyegge/beads";
|
||||||
|
|||||||
Reference in New Issue
Block a user