Skip to content

Commit b553a4b

Browse files
committed
relo: normalize path in dedup comparison to fix Windows failure
The dedup check in resolve compared the raw r.MoveTo against existing.TargetFile which had already been through filepath.Abs. On Windows, filepath.Abs("/tmp/target.go") produces "D:\tmp\target.go", causing identical relos to appear conflicting.
1 parent c920ef7 commit b553a4b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

relo/resolve.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,17 @@ func resolve(ix *mast.Index, relos []Relo, fmInfos []*fileMoveInfo, plan *Plan)
152152
// Deduplicate by group (+ optional file).
153153
if existing, ok := seen[sk]; ok {
154154
// Two explicit relos for the same key: error if they conflict.
155+
// Normalize newTarget the same way TargetFile is set below
156+
// (filepath.Abs) so the comparison works on all platforms.
155157
newTarget := r.MoveTo
156158
if newTarget == "" && defIdent.File != nil {
157159
newTarget = defIdent.File.Path
158160
}
161+
if newTarget != "" {
162+
if abs, err := filepath.Abs(newTarget); err == nil {
163+
newTarget = abs
164+
}
165+
}
159166
newName := r.Rename
160167
if newName == "" {
161168
newName = grp.Name

0 commit comments

Comments
 (0)