MCPcopy Create free account
hub / github.com/driangle/taskmd / updateCrossReferences

Function updateCrossReferences

apps/cli/internal/cli/deduplicate.go:381–405  ·  view source on GitHub ↗

updateCrossReferences rewrites dependency and parent references in all task files.

(reassignments []reassignment, allTasks []*model.Task, refOverrides map[string]string)

Source from the content-addressed store, hash-verified

379
380// updateCrossReferences rewrites dependency and parent references in all task files.
381func updateCrossReferences(reassignments []reassignment, allTasks []*model.Task, refOverrides map[string]string) error {
382 renamedPaths := make(map[string]string, len(reassignments))
383 for _, r := range reassignments {
384 renamedPaths[r.OldFilePath] = r.NewFilePath
385 }
386
387 for _, task := range allTasks {
388 filePath := task.FilePath
389 if newPath, ok := renamedPaths[filePath]; ok {
390 filePath = newPath
391 }
392
393 for _, r := range reassignments {
394 if shouldSkipRewrite(refOverrides, task.FilePath, r.OldID) {
395 continue
396 }
397
398 if err := taskfile.ReplaceReference(filePath, r.OldID, r.NewID); err != nil {
399 return fmt.Errorf("failed to update references in %s: %w", filePath, err)
400 }
401 }
402 }
403
404 return nil
405}
406
407// shouldSkipRewrite checks if an override exists that keeps the original ID for this file+oldID.
408func shouldSkipRewrite(refOverrides map[string]string, origFilePath, oldID string) bool {

Callers 1

applyReassignmentsFunction · 0.85

Calls 1

shouldSkipRewriteFunction · 0.85

Tested by

no test coverage detected