/{cmd,docs,internal,website}: make dolt backend explicitly single process
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
@@ -18,6 +19,7 @@ import (
|
||||
"github.com/steveyegge/beads/internal/git"
|
||||
"github.com/steveyegge/beads/internal/storage"
|
||||
"github.com/steveyegge/beads/internal/storage/factory"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
// hookCmd is the main "bd hook" command that git hooks call into.
|
||||
@@ -663,7 +665,7 @@ func hookPostMergeDolt(beadsDir string) int {
|
||||
|
||||
// Import JSONL to the import branch
|
||||
jsonlPath := filepath.Join(beadsDir, "issues.jsonl")
|
||||
if err := importFromJSONLToStore(store, jsonlPath); err != nil {
|
||||
if err := importFromJSONLToStore(ctx, store, jsonlPath); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: could not import JSONL: %v\n", err)
|
||||
// Checkout back to original branch
|
||||
_ = doltStore.Checkout(ctx, currentBranch)
|
||||
@@ -831,13 +833,41 @@ func hookPostCheckout(args []string) int {
|
||||
|
||||
// importFromJSONLToStore imports issues from JSONL to a store.
|
||||
// This is a placeholder - the actual implementation should use the store's methods.
|
||||
func importFromJSONLToStore(store interface{}, jsonlPath string) error {
|
||||
_ = store
|
||||
_ = jsonlPath
|
||||
// Use bd sync --import-only for now
|
||||
// TODO: Implement direct store import
|
||||
cmd := exec.Command("bd", "sync", "--import-only", "--no-git-history", "--no-daemon")
|
||||
return cmd.Run()
|
||||
func importFromJSONLToStore(ctx context.Context, store storage.Storage, jsonlPath string) error {
|
||||
// Parse JSONL into issues
|
||||
// #nosec G304 - jsonlPath is derived from beadsDir (trusted workspace path)
|
||||
f, err := os.Open(jsonlPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = f.Close() }()
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
// 2MB buffer for large issues
|
||||
scanner.Buffer(make([]byte, 0, 1024), 2*1024*1024)
|
||||
|
||||
var allIssues []*types.Issue
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
var issue types.Issue
|
||||
if err := json.Unmarshal([]byte(line), &issue); err != nil {
|
||||
return err
|
||||
}
|
||||
issue.SetDefaults()
|
||||
allIssues = append(allIssues, &issue)
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Import using shared logic (no subprocess).
|
||||
// Use store.Path() as the database path (works for both sqlite and dolt).
|
||||
opts := ImportOptions{}
|
||||
_, err = importIssuesCore(ctx, store.Path(), store, allIssues, opts)
|
||||
return err
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
Reference in New Issue
Block a user