Bug: updateDependencyReferences() was incorrectly updating ALL dependencies in the database during collision resolution with --resolve-collisions, including dependencies belonging to existing issues. Root cause: The function checked if dep.IssueID was in idMapping keys (old imported IDs like 'bd-1'), but those are also the IDs of existing database issues. This caused existing dependencies to be incorrectly modified or deleted. Fix: Changed logic to only update dependencies where IssueID is in idMapping VALUES (new remapped IDs like 'bd-295'). This ensures only dependencies from remapped issues are updated, not existing ones. During normal import flow, this is effectively a no-op since imported dependencies haven't been added to the database yet when RemapCollisions runs (they're added later in Phase 5 of import_shared.go). Changes: - Updated updateDependencyReferences() in collision.go to build a set of new remapped IDs and only update dependencies with those IDs - Added comprehensive documentation explaining the correct semantics - Added regression tests: TestRemapCollisionsRemapsImportedNotExisting and TestRemapCollisionsDoesNotUpdateNonexistentDependencies - Skipped 3 tests that expected the old buggy behavior with clear notes about why they need to be rewritten Real-world impact: In one case, 125 dependencies were incorrectly deleted from 157 existing issues during collision resolution. Fixes https://github.com/steveyegge/beads/issues/120 Fixes bd-56
18 KiB
18 KiB