Files
beads/internal/storage/sqlite
Steve Yegge 81ab3c3d1b Refactor dependency dirty marking to use shared helper (bd-56)
Replace duplicated dirty-marking logic in AddDependency and
RemoveDependency with a new markIssuesDirtyTx helper function.
This improves code maintainability and ensures consistent behavior.

The Problem:
- AddDependency and RemoveDependency had ~20 lines of duplicated code
- Each manually prepared statements and marked issues dirty
- Violation of DRY principle
- Pattern was fragile if preparation failed

The Fix:
- Created markIssuesDirtyTx() helper in dirty.go
- Takes existing transaction and issue IDs
- Both functions now use: markIssuesDirtyTx(ctx, tx, []string{id1, id2})
- Reduced from 20 lines to 3 lines per function

Benefits:
- Eliminates code duplication (DRY)
- Single source of truth for transaction-based dirty marking
- More readable and maintainable
- Easier to modify behavior in future
- Consistent error messages

Changes:
- internal/storage/sqlite/dirty.go:129-154
  * Add markIssuesDirtyTx() helper function
- internal/storage/sqlite/dependencies.go:115-117, 147-149
  * Replace duplicated code with helper call in both functions

Testing:
- All existing tests pass ✓
- Verified both issues marked dirty with same timestamp ✓
- Dependency add/remove works correctly ✓

Impact:
- Cleaner, more maintainable codebase
- No functional changes, pure refactor
- Foundation for future improvements

Closes bd-56

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-14 00:35:43 -07:00
..