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

Function runDeduplicate

apps/cli/internal/cli/deduplicate.go:99–145  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

97}
98
99func runDeduplicate(cmd *cobra.Command, args []string) error {
100 if err := ValidateFormat(dedupFormat, []string{"text", "json"}); err != nil {
101 return err
102 }
103
104 flags := GetGlobalFlags()
105 scanDir := ResolveScanDir(args)
106
107 taskScanner := scanner.NewScanner(scanDir, flags.Verbose, flags.IgnoreDirs)
108 scanResult, err := taskScanner.Scan()
109 if err != nil {
110 return fmt.Errorf("scan failed: %w", err)
111 }
112
113 reassignments, err := planReassignments(scanResult.Tasks)
114 if err != nil {
115 return err
116 }
117
118 idMap := buildIDMap(scanResult.Tasks)
119 ambRefs := findAmbiguousRefs(reassignments, scanResult.Tasks, idMap)
120
121 interactive := !dedupNoInteractive && !dedupDryRun && dedupIsTTY()
122
123 var refOverrides map[string]string
124 if len(ambRefs) > 0 && interactive {
125 refOverrides, err = promptDisambiguation(ambRefs, reassignments)
126 if err != nil {
127 return err
128 }
129 }
130
131 if !dedupDryRun {
132 if err := applyReassignments(reassignments, scanResult.Tasks, refOverrides); err != nil {
133 return err
134 }
135 }
136
137 result := deduplicateResult{
138 DryRun: dedupDryRun,
139 Duplicates: len(reassignments),
140 Reassignments: reassignments,
141 AmbiguousRefs: ambRefs,
142 }
143
144 return outputDeduplicateResult(result, flags.Quiet)
145}
146
147// findAmbiguousRefs finds references to duplicate IDs from tasks outside the collision group.
148func findAmbiguousRefs(reassignments []reassignment, allTasks []*model.Task, idMap map[string][]*model.Task) []ambiguousRef {

Callers 1

captureDedupFunction · 0.85

Calls 10

ScanMethod · 0.95
ValidateFormatFunction · 0.85
GetGlobalFlagsFunction · 0.85
ResolveScanDirFunction · 0.85
planReassignmentsFunction · 0.85
buildIDMapFunction · 0.85
findAmbiguousRefsFunction · 0.85
promptDisambiguationFunction · 0.85
applyReassignmentsFunction · 0.85
outputDeduplicateResultFunction · 0.85

Tested by 1

captureDedupFunction · 0.68