From a59b18ba35810e17a9ffe1993d149a2a21be396c Mon Sep 17 00:00:00 2001 From: Ayooluwa Isaiah Date: Tue, 4 May 2021 22:51:48 +0100 Subject: [PATCH] Fix bug with case-insensitive filesystems - Path exists conflict is no longer triggered when the casing of a filename is changed. e.g from abc.md to ABC.md --- src/replace.go | 2 +- src/validation.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/replace.go b/src/replace.go index 650ee0e..686655c 100644 --- a/src/replace.go +++ b/src/replace.go @@ -383,7 +383,7 @@ func getAllVariables(str string) (replaceVars, error) { return v, nil } -// regexReplace handles string replacement in regex mode +// regexReplace handles string replacement func (op *Operation) regexReplace( r *regexp.Regexp, fileName, replacement string, diff --git a/src/validation.go b/src/validation.go index 3db0698..93d38f3 100644 --- a/src/validation.go +++ b/src/validation.go @@ -200,7 +200,8 @@ func (op *Operation) detectConflicts() { if _, err := os.Stat(target); err == nil || errors.Is(err, os.ErrExist) { // Don't report a conflict for an unchanged filename - if source == target { + // Also handles case-insensitive filesystems + if strings.EqualFold(source, target) { continue }