Remove vestigial --resolve-collisions flag
Hash-based IDs make collision resolution unnecessary. The flag was already non-functional (handleCollisions returns error on collision regardless of flag value). Removed: - --resolve-collisions flag from bd import - ResolveCollisions field from ImportOptions and importer.Options - All references in daemon, auto-import, and tests - Updated error messages to reflect hash IDs don't collide All import tests pass. Amp-Thread-ID: https://ampcode.com/threads/T-47dfa0cc-bb71-4467-ac86-f0966a7c5d58 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -168,7 +168,7 @@ func autoImportIfNewer() {
|
||||
|
||||
// Use shared import logic (bd-157)
|
||||
opts := ImportOptions{
|
||||
ResolveCollisions: true, // Auto-import always resolves collisions
|
||||
|
||||
DryRun: false,
|
||||
SkipUpdate: false,
|
||||
Strict: false,
|
||||
|
||||
@@ -188,7 +188,7 @@ func importFromGit(ctx context.Context, dbFilePath string, store storage.Storage
|
||||
// Note: SkipPrefixValidation allows mixed prefixes during auto-import
|
||||
// (but now we set the prefix first, so CreateIssue won't use filename fallback)
|
||||
opts := ImportOptions{
|
||||
ResolveCollisions: true,
|
||||
|
||||
DryRun: false,
|
||||
SkipUpdate: false,
|
||||
SkipPrefixValidation: true, // Auto-import is lenient about prefixes
|
||||
|
||||
@@ -810,7 +810,7 @@ func importToJSONLWithStore(ctx context.Context, store storage.Storage, jsonlPat
|
||||
|
||||
// Use existing import logic with auto-conflict resolution
|
||||
opts := ImportOptions{
|
||||
ResolveCollisions: true, // Auto-resolve ID conflicts
|
||||
|
||||
DryRun: false,
|
||||
SkipUpdate: false,
|
||||
Strict: false,
|
||||
|
||||
@@ -23,15 +23,13 @@ Reads from stdin by default, or use -i flag for file input.
|
||||
Behavior:
|
||||
- Existing issues (same ID) are updated
|
||||
- New issues are created
|
||||
- Collisions (same ID, different content) are detected
|
||||
- Use --resolve-collisions to automatically remap colliding issues
|
||||
- Collisions (same ID, different content) are detected and reported
|
||||
- Use --dedupe-after to find and merge content duplicates after import
|
||||
- Use --dry-run to preview changes without applying them`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
input, _ := cmd.Flags().GetString("input")
|
||||
skipUpdate, _ := cmd.Flags().GetBool("skip-existing")
|
||||
strict, _ := cmd.Flags().GetBool("strict")
|
||||
resolveCollisions, _ := cmd.Flags().GetBool("resolve-collisions")
|
||||
dryRun, _ := cmd.Flags().GetBool("dry-run")
|
||||
renameOnImport, _ := cmd.Flags().GetBool("rename-on-import")
|
||||
dedupeAfter, _ := cmd.Flags().GetBool("dedupe-after")
|
||||
@@ -86,7 +84,6 @@ Behavior:
|
||||
|
||||
// Phase 2: Use shared import logic
|
||||
opts := ImportOptions{
|
||||
ResolveCollisions: resolveCollisions,
|
||||
DryRun: dryRun,
|
||||
SkipUpdate: skipUpdate,
|
||||
Strict: strict,
|
||||
@@ -112,14 +109,14 @@ Behavior:
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Check if it's a collision error when not resolving
|
||||
if !resolveCollisions && result != nil && len(result.CollisionIDs) > 0 {
|
||||
// Check if it's a collision error
|
||||
if result != nil && len(result.CollisionIDs) > 0 {
|
||||
// Print collision report before exiting
|
||||
fmt.Fprintf(os.Stderr, "\n=== Collision Detection Report ===\n")
|
||||
fmt.Fprintf(os.Stderr, "COLLISIONS DETECTED: %d\n\n", result.Collisions)
|
||||
fmt.Fprintf(os.Stderr, "Colliding issue IDs: %v\n", result.CollisionIDs)
|
||||
fmt.Fprintf(os.Stderr, "\nCollision detected! Use --resolve-collisions to automatically remap colliding issues.\n")
|
||||
fmt.Fprintf(os.Stderr, "Or use --dry-run to preview without making changes.\n")
|
||||
fmt.Fprintf(os.Stderr, "\nWith hash-based IDs, collisions should not occur.\n")
|
||||
fmt.Fprintf(os.Stderr, "This may indicate manual ID manipulation or a bug.\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "Import failed: %v\n", err)
|
||||
@@ -249,7 +246,6 @@ func init() {
|
||||
importCmd.Flags().StringP("input", "i", "", "Input file (default: stdin)")
|
||||
importCmd.Flags().BoolP("skip-existing", "s", false, "Skip existing issues instead of updating them")
|
||||
importCmd.Flags().Bool("strict", false, "Fail on dependency errors instead of treating them as warnings")
|
||||
importCmd.Flags().Bool("resolve-collisions", false, "Automatically resolve ID collisions by remapping")
|
||||
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)")
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestImportReturnsCorrectCounts(t *testing.T) {
|
||||
|
||||
// Import with default options
|
||||
opts := ImportOptions{
|
||||
ResolveCollisions: false,
|
||||
|
||||
DryRun: false,
|
||||
SkipUpdate: false,
|
||||
Strict: false,
|
||||
|
||||
@@ -158,7 +158,6 @@ func issueDataChanged(existing *types.Issue, updates map[string]interface{}) boo
|
||||
|
||||
// ImportOptions configures how the import behaves
|
||||
type ImportOptions struct {
|
||||
ResolveCollisions bool // Auto-resolve collisions by remapping to new IDs
|
||||
DryRun bool // Preview changes without applying them
|
||||
SkipUpdate bool // Skip updating existing issues (create-only mode)
|
||||
Strict bool // Fail on any error (dependencies, labels, etc.)
|
||||
@@ -194,7 +193,6 @@ type ImportResult struct {
|
||||
func importIssuesCore(ctx context.Context, dbPath string, store storage.Storage, issues []*types.Issue, opts ImportOptions) (*ImportResult, error) {
|
||||
// Convert ImportOptions to importer.Options
|
||||
importerOpts := importer.Options{
|
||||
ResolveCollisions: opts.ResolveCollisions,
|
||||
DryRun: opts.DryRun,
|
||||
SkipUpdate: opts.SkipUpdate,
|
||||
Strict: opts.Strict,
|
||||
|
||||
@@ -214,7 +214,7 @@ func TestImportClearsExportHashes(t *testing.T) {
|
||||
}
|
||||
|
||||
opts := ImportOptions{
|
||||
ResolveCollisions: false,
|
||||
|
||||
DryRun: false,
|
||||
SkipUpdate: false,
|
||||
Strict: false,
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
|
||||
// Options contains import configuration
|
||||
type Options struct {
|
||||
ResolveCollisions bool // Auto-resolve collisions by remapping to new IDs
|
||||
DryRun bool // Preview changes without applying them
|
||||
SkipUpdate bool // Skip updating existing issues (create-only mode)
|
||||
Strict bool // Fail on any error (dependencies, labels, etc.)
|
||||
|
||||
@@ -209,7 +209,6 @@ func (s *Server) checkAndAutoImportIfStale(req *Request) error {
|
||||
importFunc := func(ctx context.Context, issues []*types.Issue) (created, updated int, idMapping map[string]string, err error) {
|
||||
// Use the importer package to perform the actual import
|
||||
result, err := importer.ImportIssues(ctx, dbPath, store, issues, importer.Options{
|
||||
ResolveCollisions: false, // Do NOT resolve collisions - update existing issues by ID
|
||||
RenameOnImport: true, // Auto-rename prefix mismatches
|
||||
// Note: SkipPrefixValidation is false by default, so we validate and rename
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user