From 4dc21822d08f4a504b6dd4790e23dcf343777c17 Mon Sep 17 00:00:00 2001 From: Ayooluwa Isaiah Date: Fri, 11 Oct 2024 09:43:31 +0100 Subject: [PATCH] fix empty filename auto resolution --- validate/validate.go | 4 ++-- validate/validate_test/validate_test.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/validate/validate.go b/validate/validate.go index c523b52..9c86626 100644 --- a/validate/validate.go +++ b/validate/validate.go @@ -111,7 +111,7 @@ func checkEmptyFilenameConflict( if ctx.autoFix { // The file is left unchanged - ctx.change.Target = ctx.change.Source + ctx.change.AutoFixTarget(ctx.change.Source) ctx.change.Status = status.Unchanged } } @@ -425,7 +425,7 @@ func checkAndHandleConflict(ctx validationCtx, loopIndex *int) (detected bool) { } if i == len(checks)-1 { - // Special handling for checkTargetFileChangingConflict + // INFO: Special handling for checkTargetFileChangingConflict // Restart the iteration from the beginning *loopIndex = -1 diff --git a/validate/validate_test/validate_test.go b/validate/validate_test/validate_test.go index 747be57..b38f063 100644 --- a/validate/validate_test/validate_test.go +++ b/validate/validate_test/validate_test.go @@ -155,6 +155,19 @@ func TestValidate(t *testing.T) { "testdata/images/dsc-001.arw", }, }, + { + Name: "auto fix empty filename conflict", + Changes: file.Changes{ + { + Source: "1984.pdf", + Target: "", + BaseDir: "ebooks", + Status: status.Unchanged, + }, + }, + Want: []string{"ebooks/1984.pdf"}, + Args: autoFixArgs, + }, { Name: "auto fix path exists conflict", Changes: file.Changes{