applyReassignments performs the actual file modifications. refOverrides maps refOverrideKey → target ID for references that the user explicitly chose.
(reassignments []reassignment, allTasks []*model.Task, refOverrides map[string]string)
| 362 | // applyReassignments performs the actual file modifications. |
| 363 | // refOverrides maps refOverrideKey → target ID for references that the user explicitly chose. |
| 364 | func applyReassignments(reassignments []reassignment, allTasks []*model.Task, refOverrides map[string]string) error { |
| 365 | for _, r := range reassignments { |
| 366 | if err := taskfile.ReplaceID(r.OldFilePath, r.NewID); err != nil { |
| 367 | return fmt.Errorf("failed to update ID in %s: %w", r.OldFilePath, err) |
| 368 | } |
| 369 | |
| 370 | if r.OldFilePath != r.NewFilePath { |
| 371 | if err := os.Rename(r.OldFilePath, r.NewFilePath); err != nil { |
| 372 | return fmt.Errorf("failed to rename %s → %s: %w", r.OldFilePath, r.NewFilePath, err) |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | return updateCrossReferences(reassignments, allTasks, refOverrides) |
| 378 | } |
| 379 | |
| 380 | // updateCrossReferences rewrites dependency and parent references in all task files. |
| 381 | func updateCrossReferences(reassignments []reassignment, allTasks []*model.Task, refOverrides map[string]string) error { |
no test coverage detected