* Fix #274: Add automatic .beads/.gitignore upgrade Implements three mechanisms to ensure users get updated gitignore: 1. bd doctor --fix: Manually upgrade gitignore 2. Daemon auto-upgrade: Upgrades on startup if outdated 3. bd init idempotent: Safe to re-run, always updates gitignore The gitignore template now lives in cmd/bd/doctor/gitignore.go for consistent updates across all three mechanisms. Fixes: #274 * Remove test binary Amp-Thread-ID: https://ampcode.com/threads/T-7042cfcc-ac97-43d7-a40f-3fa1bb4e1c2b Co-authored-by: Amp <amp@ampcode.com> * Fix critical issues: remove merge artifact and apply gitignore template - Remove .beads/beads.left.jsonl (merge artifact that shouldn't be committed) - Apply new gitignore template to .beads/.gitignore (was missing patterns) Amp-Thread-ID: https://ampcode.com/threads/T-7042cfcc-ac97-43d7-a40f-3fa1bb4e1c2b Co-authored-by: Amp <amp@ampcode.com> * bd sync: 2025-11-12 11:09:30 * Retrigger CI Amp-Thread-ID: https://ampcode.com/threads/T-8d532264-6d5e-4b68-88e9-e4511851b64a Co-authored-by: Amp <amp@ampcode.com> * Fix duplicate DoctorCheck type definition * Trigger CI after fixing type conflict Amp-Thread-ID: https://ampcode.com/threads/T-8d532264-6d5e-4b68-88e9-e4511851b64a Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/beads/cmd/bd/doctor"
|
||||
"github.com/steveyegge/beads/internal/beads"
|
||||
"github.com/steveyegge/beads/internal/config"
|
||||
"github.com/steveyegge/beads/internal/configfile"
|
||||
@@ -175,43 +176,13 @@ With --no-db: creates .beads/ directory and issues.jsonl file instead of SQLite
|
||||
return
|
||||
}
|
||||
|
||||
// Create .gitignore in .beads directory
|
||||
// Create/update .gitignore in .beads directory (idempotent - always update to latest)
|
||||
gitignorePath := filepath.Join(localBeadsDir, ".gitignore")
|
||||
gitignoreContent := `# SQLite databases
|
||||
*.db
|
||||
*.db?*
|
||||
*.db-journal
|
||||
*.db-wal
|
||||
*.db-shm
|
||||
|
||||
# Daemon runtime files
|
||||
daemon.lock
|
||||
daemon.log
|
||||
daemon.pid
|
||||
bd.sock
|
||||
|
||||
# Legacy database files
|
||||
db.sqlite
|
||||
bd.db
|
||||
|
||||
# Merge artifacts (temporary files from 3-way merge)
|
||||
beads.base.jsonl
|
||||
beads.base.meta.json
|
||||
beads.left.jsonl
|
||||
beads.left.meta.json
|
||||
beads.right.jsonl
|
||||
beads.right.meta.json
|
||||
|
||||
# Keep JSONL exports and config (source of truth for git)
|
||||
!issues.jsonl
|
||||
!metadata.json
|
||||
!config.json
|
||||
`
|
||||
if err := os.WriteFile(gitignorePath, []byte(gitignoreContent), 0600); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to create .gitignore: %v\n", err)
|
||||
// Non-fatal - continue anyway
|
||||
}
|
||||
if err := os.WriteFile(gitignorePath, []byte(doctor.GitignoreTemplate), 0600); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to create/update .gitignore: %v\n", err)
|
||||
// Non-fatal - continue anyway
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure parent directory exists for the database
|
||||
if err := os.MkdirAll(initDBDir, 0750); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user