fix(import): add warning when issues are skipped due to deletions manifest

When importing JSONL that contains issues in the deletions manifest,
import now:
- Filters out deleted issues before import
- Prints per-issue warning with deletion details (date, actor)
- Shows count of skipped issues in summary
- Suggests --ignore-deletions flag to force import

The new --ignore-deletions flag allows importing issues that are in the
deletions manifest, useful for recovering accidentally deleted issues.

Fixes bd-4zy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-30 21:21:47 -08:00
parent 3df138445a
commit f7dea354d8
4 changed files with 46 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ type Options struct {
OrphanHandling OrphanHandling // How to handle missing parent issues (default: allow)
ClearDuplicateExternalRefs bool // Clear duplicate external_ref values instead of erroring
NoGitHistory bool // Skip git history backfill for deletions (prevents spurious deletion during JSONL migrations)
IgnoreDeletions bool // Import issues even if they're in the deletions manifest
}
// Result contains statistics about the import operation
@@ -60,6 +61,8 @@ type Result struct {
SkippedDependencies []string // Dependencies skipped due to FK constraint violations
Purged int // Issues purged from DB (found in deletions manifest)
PurgedIDs []string // IDs that were purged
SkippedDeleted int // Issues skipped because they're in deletions manifest
SkippedDeletedIDs []string // IDs that were skipped due to deletions manifest
}
// ImportIssues handles the core import logic used by both manual and auto-import.
@@ -114,6 +117,29 @@ func ImportIssues(ctx context.Context, dbPath string, store storage.Storage, iss
opts.OrphanHandling = sqliteStore.GetOrphanHandling(ctx)
}
// Filter out issues that are in the deletions manifest (bd-4zy)
// Unless IgnoreDeletions is set, skip importing deleted issues
if !opts.IgnoreDeletions && dbPath != "" {
beadsDir := filepath.Dir(dbPath)
deletionsPath := deletions.DefaultPath(beadsDir)
loadResult, err := deletions.LoadDeletions(deletionsPath)
if err == nil && len(loadResult.Records) > 0 {
var filteredIssues []*types.Issue
for _, issue := range issues {
if del, found := loadResult.Records[issue.ID]; found {
// Issue is in deletions manifest - skip it
result.SkippedDeleted++
result.SkippedDeletedIDs = append(result.SkippedDeletedIDs, issue.ID)
fmt.Fprintf(os.Stderr, "Skipping %s (in deletions manifest: deleted %s by %s)\n",
issue.ID, del.Timestamp.Format("2006-01-02"), del.Actor)
} else {
filteredIssues = append(filteredIssues, issue)
}
}
issues = filteredIssues
}
}
// Check and handle prefix mismatches
if err := handlePrefixMismatch(ctx, sqliteStore, issues, opts, result); err != nil {
return result, err