Fix bd-88: import now reports unchanged issues correctly
When importing JSONL that matches the database exactly, import was reporting '0 created, 0 updated' which was confusing. Now it properly tracks and reports unchanged issues. Changes: - Added Unchanged field to ImportResult - Track unchanged issues separately from skipped/updated - Display unchanged count in import summary - Updated dry-run output to show unchanged count - Added test to verify correct reporting behavior Example output: 'Import complete: 0 created, 0 updated, 88 unchanged' Amp-Thread-ID: https://ampcode.com/threads/T-5dd4843e-9ce3-4fe0-9658-d2227b0a2e4e Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -165,6 +165,7 @@ type ImportOptions struct {
|
||||
type ImportResult struct {
|
||||
Created int // New issues created
|
||||
Updated int // Existing issues updated
|
||||
Unchanged int // Existing issues that matched exactly (idempotent)
|
||||
Skipped int // Issues skipped (duplicates, errors)
|
||||
Collisions int // Collisions detected
|
||||
IDMapping map[string]string // Mapping of remapped IDs (old -> new)
|
||||
@@ -317,7 +318,8 @@ func importIssuesCore(ctx context.Context, dbPath string, store storage.Storage,
|
||||
} else if opts.DryRun {
|
||||
// No collisions in dry-run mode
|
||||
result.Created = len(collisionResult.NewIssues)
|
||||
result.Updated = len(collisionResult.ExactMatches)
|
||||
// bd-88: ExactMatches are unchanged issues (idempotent), not updates
|
||||
result.Unchanged = len(collisionResult.ExactMatches)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -362,15 +364,15 @@ func importIssuesCore(ctx context.Context, dbPath string, store storage.Storage,
|
||||
updates["external_ref"] = nil
|
||||
}
|
||||
|
||||
// bd-84: Only update if data actually changed (prevents timestamp churn)
|
||||
// bd-88: Only update if data actually changed (prevents timestamp churn)
|
||||
if issueDataChanged(existing, updates) {
|
||||
if err := sqliteStore.UpdateIssue(ctx, issue.ID, updates, "import"); err != nil {
|
||||
return nil, fmt.Errorf("error updating issue %s: %w", issue.ID, err)
|
||||
}
|
||||
result.Updated++
|
||||
} else {
|
||||
// Issue unchanged - count as skipped to avoid polluting JSONL with timestamp updates
|
||||
result.Skipped++
|
||||
// bd-88: Track unchanged issues separately for accurate reporting
|
||||
result.Unchanged++
|
||||
}
|
||||
} else {
|
||||
// New issue - check for duplicates in import batch
|
||||
|
||||
Reference in New Issue
Block a user