Fix bd-179: Derive prefix from database filename when config missing

- Add dbPath field to SQLiteStorage to track database file path
- Create derivePrefixFromPath() helper to extract prefix from filename
- Update ID generation in CreateIssue() and generateBatchIDs() to use filename fallback
- Fix tests to explicitly set issue_prefix config for bd- prefixed tests

When config doesn't have issue_prefix set, bd now correctly derives it from
the database filename (e.g., wy-.db -> wy) instead of always defaulting to 'bd'.

Fixes: bd-179
This commit is contained in:
Steve Yegge
2025-10-20 22:18:08 -07:00
parent b6ba8e2e0c
commit db8efd534c
4 changed files with 55 additions and 10 deletions

View File

@@ -188,6 +188,13 @@ func TestMigrateIssueCountersTableEmptyDB(t *testing.T) {
// Create first issue - should work fine
ctx := context.Background()
// Set the issue prefix to "bd" for this test
err = store.SetConfig(ctx, "issue_prefix", "bd")
if err != nil {
t.Fatalf("Failed to set issue_prefix: %v", err)
}
issue := &types.Issue{
Title: "First issue",
Status: types.StatusOpen,
@@ -225,6 +232,13 @@ func TestMigrateIssueCountersTableIdempotent(t *testing.T) {
// Create some issues
ctx := context.Background()
// Set the issue prefix to "bd" for this test
err = store1.SetConfig(ctx, "issue_prefix", "bd")
if err != nil {
t.Fatalf("Failed to set issue_prefix: %v", err)
}
issue := &types.Issue{
Title: "Test issue",
Status: types.StatusOpen,