Skip to content

Commit

Permalink
detect conflicts correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoisaiah committed Oct 31, 2024
1 parent 969ced3 commit 05a699c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,28 +444,33 @@ func checkAndHandleConflict(ctx validationCtx, loopIndex *int) (detected bool) {

// detectConflicts checks the renamed files for various conflicts and
// automatically fixes them if configured.
func detectConflicts(autoFix, allowOverwrites bool) (detected bool) {
func detectConflicts(autoFix, allowOverwrites bool) bool {
ctx := validationCtx{
autoFix: autoFix,
allowOverwrites: allowOverwrites,
seenPaths: make(map[string]int),
}

conflicts := make(map[int]string)

for i := 0; i < len(changes); i++ {
change := changes[i]

ctx.change = change
ctx.changeIndex = i

detected = checkAndHandleConflict(ctx, &i)
detected := checkAndHandleConflict(ctx, &i)
if detected {
conflicts[ctx.changeIndex] = change.SourcePath
continue
}

delete(conflicts, ctx.changeIndex)

ctx.updateSeenPaths()
}

return
return len(conflicts) > 0
}

// Validate detects and reports any conflicts that can occur while renaming a
Expand Down

0 comments on commit 05a699c

Please sign in to comment.