chore: bump version to 0.30.2
- Update version in version.go, default.nix, hook templates - Add CHANGELOG.md entry for v0.30.2 - Add v0.30.1 and v0.30.2 to versionChanges in info.go - Remove stale internal/deletions import from integration test (fixes CI failure from bd-fom refactor) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/steveyegge/beads/internal/deletions"
|
||||
"github.com/steveyegge/beads/internal/storage/sqlite"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
@@ -95,125 +94,6 @@ func TestConcurrentExternalRefUpdates(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestCrossCloneDeletionPropagation tests that deletions propagate across clones
|
||||
// via the deletions manifest. Simulates:
|
||||
// 1. Clone A and Clone B both have issue bd-test-123
|
||||
// 2. Clone A deletes bd-test-123 (recorded in deletions.jsonl)
|
||||
// 3. Clone B pulls and imports - issue should be purged from Clone B's DB
|
||||
func TestCrossCloneDeletionPropagation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
// Create temp directory structure for "Clone B" (the clone that receives the deletion)
|
||||
tmpDir := t.TempDir()
|
||||
beadsDir := filepath.Join(tmpDir, ".beads")
|
||||
if err := os.MkdirAll(beadsDir, 0755); err != nil {
|
||||
t.Fatalf("Failed to create .beads dir: %v", err)
|
||||
}
|
||||
|
||||
// Create database in .beads/ (required for purgeDeletedIssues to find deletions.jsonl)
|
||||
dbPath := filepath.Join(beadsDir, "beads.db")
|
||||
store, err := sqlite.New(ctx, dbPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create store: %v", err)
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil {
|
||||
t.Fatalf("Failed to set prefix: %v", err)
|
||||
}
|
||||
|
||||
// Create an issue in Clone B's database (simulating it was synced before)
|
||||
issueToDelete := &types.Issue{
|
||||
ID: "bd-test-123",
|
||||
Title: "Issue that will be deleted in Clone A",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeTask,
|
||||
}
|
||||
if err := store.CreateIssue(ctx, issueToDelete, "test"); err != nil {
|
||||
t.Fatalf("Failed to create issue: %v", err)
|
||||
}
|
||||
|
||||
// Also create another issue that should NOT be deleted
|
||||
issueToKeep := &types.Issue{
|
||||
ID: "bd-test-456",
|
||||
Title: "Issue that stays",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeTask,
|
||||
}
|
||||
if err := store.CreateIssue(ctx, issueToKeep, "test"); err != nil {
|
||||
t.Fatalf("Failed to create kept issue: %v", err)
|
||||
}
|
||||
|
||||
// Verify both issues exist
|
||||
issues, err := store.SearchIssues(ctx, "", types.IssueFilter{})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to search issues: %v", err)
|
||||
}
|
||||
if len(issues) != 2 {
|
||||
t.Fatalf("Expected 2 issues before import, got %d", len(issues))
|
||||
}
|
||||
|
||||
// Simulate Clone A deleting bd-test-123 by writing to deletions manifest
|
||||
deletionsPath := filepath.Join(beadsDir, "deletions.jsonl")
|
||||
record := deletions.DeletionRecord{
|
||||
ID: "bd-test-123",
|
||||
Timestamp: time.Now().UTC(),
|
||||
Actor: "clone-a-user",
|
||||
Reason: "test deletion",
|
||||
}
|
||||
if err := deletions.AppendDeletion(deletionsPath, record); err != nil {
|
||||
t.Fatalf("Failed to write deletion record: %v", err)
|
||||
}
|
||||
|
||||
// Create JSONL with only the kept issue (simulating git pull from remote)
|
||||
// The deleted issue is NOT in the JSONL (it was removed in Clone A)
|
||||
jsonlIssues := []*types.Issue{issueToKeep}
|
||||
|
||||
// Import with Options that uses the database path (triggers purgeDeletedIssues)
|
||||
result, err := ImportIssues(ctx, dbPath, store, jsonlIssues, Options{})
|
||||
if err != nil {
|
||||
t.Fatalf("Import failed: %v", err)
|
||||
}
|
||||
|
||||
// Verify the purge happened
|
||||
if result.Purged != 1 {
|
||||
t.Errorf("Expected 1 purged issue, got %d", result.Purged)
|
||||
}
|
||||
if len(result.PurgedIDs) != 1 || result.PurgedIDs[0] != "bd-test-123" {
|
||||
t.Errorf("Expected purged ID bd-test-123, got %v", result.PurgedIDs)
|
||||
}
|
||||
|
||||
// Verify database state
|
||||
finalIssues, err := store.SearchIssues(ctx, "", types.IssueFilter{})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to search final issues: %v", err)
|
||||
}
|
||||
|
||||
if len(finalIssues) != 1 {
|
||||
t.Errorf("Expected 1 issue after import, got %d", len(finalIssues))
|
||||
}
|
||||
|
||||
// The kept issue should still exist
|
||||
keptIssue, err := store.GetIssue(ctx, "bd-test-456")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get kept issue: %v", err)
|
||||
}
|
||||
if keptIssue == nil {
|
||||
t.Error("Expected bd-test-456 to still exist")
|
||||
}
|
||||
|
||||
// The deleted issue should be gone
|
||||
deletedIssue, err := store.GetIssue(ctx, "bd-test-123")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to query deleted issue: %v", err)
|
||||
}
|
||||
if deletedIssue != nil {
|
||||
t.Error("Expected bd-test-123 to be purged")
|
||||
}
|
||||
}
|
||||
|
||||
// TestLocalUnpushedIssueNotDeleted verifies that local issues that were never
|
||||
// in git are NOT deleted during import (they are local work, not deletions)
|
||||
func TestLocalUnpushedIssueNotDeleted(t *testing.T) {
|
||||
@@ -261,9 +141,6 @@ func TestLocalUnpushedIssueNotDeleted(t *testing.T) {
|
||||
t.Fatalf("Failed to create remote issue: %v", err)
|
||||
}
|
||||
|
||||
// Empty deletions manifest (no deletions)
|
||||
// Don't create the file - LoadDeletions handles missing file gracefully
|
||||
|
||||
// JSONL only contains the remote issue (local issue was never exported)
|
||||
jsonlIssues := []*types.Issue{remoteIssue}
|
||||
|
||||
@@ -273,7 +150,7 @@ func TestLocalUnpushedIssueNotDeleted(t *testing.T) {
|
||||
t.Fatalf("Import failed: %v", err)
|
||||
}
|
||||
|
||||
// No purges should happen (not in deletions manifest, not in git history)
|
||||
// No purges should happen (local issues not in JSONL are preserved)
|
||||
if result.Purged != 0 {
|
||||
t.Errorf("Expected 0 purged issues, got %d (purged: %v)", result.Purged, result.PurgedIDs)
|
||||
}
|
||||
@@ -295,75 +172,3 @@ func TestLocalUnpushedIssueNotDeleted(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestDeletionWithReason verifies that deletion reason is properly recorded
|
||||
func TestDeletionWithReason(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
tmpDir := t.TempDir()
|
||||
beadsDir := filepath.Join(tmpDir, ".beads")
|
||||
if err := os.MkdirAll(beadsDir, 0755); err != nil {
|
||||
t.Fatalf("Failed to create .beads dir: %v", err)
|
||||
}
|
||||
|
||||
dbPath := filepath.Join(beadsDir, "beads.db")
|
||||
store, err := sqlite.New(ctx, dbPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create store: %v", err)
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil {
|
||||
t.Fatalf("Failed to set prefix: %v", err)
|
||||
}
|
||||
|
||||
// Create issue
|
||||
issue := &types.Issue{
|
||||
ID: "bd-dup-001",
|
||||
Title: "Duplicate issue",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeTask,
|
||||
}
|
||||
if err := store.CreateIssue(ctx, issue, "test"); err != nil {
|
||||
t.Fatalf("Failed to create issue: %v", err)
|
||||
}
|
||||
|
||||
// Record deletion with reason "duplicate of bd-orig-001"
|
||||
deletionsPath := filepath.Join(beadsDir, "deletions.jsonl")
|
||||
record := deletions.DeletionRecord{
|
||||
ID: "bd-dup-001",
|
||||
Timestamp: time.Now().UTC(),
|
||||
Actor: "dedup-bot",
|
||||
Reason: "duplicate of bd-orig-001",
|
||||
}
|
||||
if err := deletions.AppendDeletion(deletionsPath, record); err != nil {
|
||||
t.Fatalf("Failed to write deletion: %v", err)
|
||||
}
|
||||
|
||||
// Verify record was written with reason
|
||||
loadResult, err := deletions.LoadDeletions(deletionsPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to load deletions: %v", err)
|
||||
}
|
||||
|
||||
if loaded, ok := loadResult.Records["bd-dup-001"]; !ok {
|
||||
t.Error("Deletion record not found")
|
||||
} else {
|
||||
if loaded.Reason != "duplicate of bd-orig-001" {
|
||||
t.Errorf("Expected reason 'duplicate of bd-orig-001', got '%s'", loaded.Reason)
|
||||
}
|
||||
if loaded.Actor != "dedup-bot" {
|
||||
t.Errorf("Expected actor 'dedup-bot', got '%s'", loaded.Actor)
|
||||
}
|
||||
}
|
||||
|
||||
// Import empty JSONL (issue was deleted)
|
||||
result, err := ImportIssues(ctx, dbPath, store, []*types.Issue{}, Options{})
|
||||
if err != nil {
|
||||
t.Fatalf("Import failed: %v", err)
|
||||
}
|
||||
|
||||
if result.Purged != 1 {
|
||||
t.Errorf("Expected 1 purged, got %d", result.Purged)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user