feat(import): add import.orphan_handling config with 4 modes

- Add GetOrphanHandling() helper to SQLiteStorage (reads from config table)
- Add --orphan-handling flag to 'bd import' command
- Wire OrphanHandling through ImportOptions -> importer.Options
- Auto-read config if flag not provided (default: 'allow')
- Document in CONFIG.md with detailed mode explanations

Modes:
- strict: Fail on missing parent (safest)
- resurrect: Auto-create parent tombstones from JSONL
- skip: Skip orphans with warning
- allow: Import without validation (default, most permissive)

Closes bd-8072, bd-b92a

Amp-Thread-ID: https://ampcode.com/threads/T-fd18d4a5-06b3-4400-9073-194d570846d8
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-04 23:59:50 -08:00
parent 0bf5c91cb3
commit ff8f6ecadf
5 changed files with 72 additions and 4 deletions

View File

@@ -33,6 +33,7 @@ Behavior:
dryRun, _ := cmd.Flags().GetBool("dry-run")
renameOnImport, _ := cmd.Flags().GetBool("rename-on-import")
dedupeAfter, _ := cmd.Flags().GetBool("dedupe-after")
orphanHandling, _ := cmd.Flags().GetString("orphan-handling")
// Open input
in := os.Stdin
@@ -98,6 +99,7 @@ Behavior:
SkipUpdate: skipUpdate,
Strict: strict,
RenameOnImport: renameOnImport,
OrphanHandling: orphanHandling,
}
result, err := importIssuesCore(ctx, dbPath, store, allIssues, opts)
@@ -263,6 +265,7 @@ func init() {
importCmd.Flags().Bool("dedupe-after", false, "Detect and report content duplicates after import")
importCmd.Flags().Bool("dry-run", false, "Preview collision detection without making changes")
importCmd.Flags().Bool("rename-on-import", false, "Rename imported issues to match database prefix (updates all references)")
importCmd.Flags().String("orphan-handling", "", "How to handle missing parent issues: strict/resurrect/skip/allow (default: use config or 'allow')")
importCmd.Flags().BoolVar(&jsonOutput, "json", false, "Output import statistics in JSON format")
rootCmd.AddCommand(importCmd)
}