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

@@ -96,6 +96,7 @@ NOTE: Import requires direct database access and does not work with daemon mode.
orphanHandling, _ := cmd.Flags().GetString("orphan-handling")
force, _ := cmd.Flags().GetBool("force")
noGitHistory, _ := cmd.Flags().GetBool("no-git-history")
ignoreDeletions, _ := cmd.Flags().GetBool("ignore-deletions")
// Check if stdin is being used interactively (not piped)
if input == "" && term.IsTerminal(int(os.Stdin.Fd())) {
@@ -255,6 +256,7 @@ NOTE: Import requires direct database access and does not work with daemon mode.
ClearDuplicateExternalRefs: clearDuplicateExternalRefs,
OrphanHandling: orphanHandling,
NoGitHistory: noGitHistory,
IgnoreDeletions: ignoreDeletions,
}
result, err := importIssuesCore(ctx, dbPath, store, allIssues, opts)
@@ -402,8 +404,18 @@ NOTE: Import requires direct database access and does not work with daemon mode.
if len(result.IDMapping) > 0 {
fmt.Fprintf(os.Stderr, ", %d issues remapped", len(result.IDMapping))
}
if result.SkippedDeleted > 0 {
fmt.Fprintf(os.Stderr, ", %d skipped (deleted)", result.SkippedDeleted)
}
fmt.Fprintf(os.Stderr, "\n")
// Print skipped deleted issues summary if any (bd-4zy)
if result.SkippedDeleted > 0 {
fmt.Fprintf(os.Stderr, "\n⚠ Skipped %d issue(s) found in deletions manifest\n", result.SkippedDeleted)
fmt.Fprintf(os.Stderr, " These issues were previously deleted and will not be resurrected.\n")
fmt.Fprintf(os.Stderr, " Use --ignore-deletions to force import anyway.\n")
}
// Print skipped dependencies summary if any
if len(result.SkippedDependencies) > 0 {
fmt.Fprintf(os.Stderr, "\n⚠ Warning: Skipped %d dependencies due to missing references:\n", len(result.SkippedDependencies))
@@ -759,6 +771,7 @@ func init() {
importCmd.Flags().String("orphan-handling", "", "How to handle missing parent issues: strict/resurrect/skip/allow (default: use config or 'allow')")
importCmd.Flags().Bool("force", false, "Force metadata update even when database is already in sync with JSONL")
importCmd.Flags().Bool("no-git-history", false, "Skip git history backfill for deletions (use during JSONL filename migrations)")
importCmd.Flags().Bool("ignore-deletions", false, "Import issues even if they're in the deletions manifest")
importCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output import statistics in JSON format")
rootCmd.AddCommand(importCmd)
}

View File

@@ -166,6 +166,7 @@ type ImportOptions struct {
ClearDuplicateExternalRefs bool // Clear duplicate external_ref values instead of erroring
OrphanHandling string // Orphan handling mode: strict/resurrect/skip/allow (empty = use config)
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
}
// ImportResult contains statistics about the import operation
@@ -183,6 +184,8 @@ type ImportResult 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
}
// importIssuesCore handles the core import logic used by both manual and auto-import.
@@ -223,6 +226,7 @@ func importIssuesCore(ctx context.Context, dbPath string, store storage.Storage,
ClearDuplicateExternalRefs: opts.ClearDuplicateExternalRefs,
OrphanHandling: importer.OrphanHandling(orphanHandling),
NoGitHistory: opts.NoGitHistory,
IgnoreDeletions: opts.IgnoreDeletions,
}
// Delegate to the importer package
@@ -246,6 +250,8 @@ func importIssuesCore(ctx context.Context, dbPath string, store storage.Storage,
SkippedDependencies: result.SkippedDependencies,
Purged: result.Purged,
PurgedIDs: result.PurgedIDs,
SkippedDeleted: result.SkippedDeleted,
SkippedDeletedIDs: result.SkippedDeletedIDs,
}, nil
}