Skip to content

Commit

Permalink
ensure sort is performed before validations
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoisaiah committed Jul 22, 2024
1 parent bc22222 commit 877ae04
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 0 additions & 5 deletions rename/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/ayoisaiah/f2/internal/file"
"github.com/ayoisaiah/f2/internal/jsonutil"
"github.com/ayoisaiah/f2/internal/osutil"
"github.com/ayoisaiah/f2/internal/sortfiles"
"github.com/ayoisaiah/f2/report"
)

Expand Down Expand Up @@ -214,10 +213,6 @@ func Rename(
conf *config.Config,
fileChanges []*file.Change,
) error {
if conf.IncludeDir {
sortfiles.ForRenamingAndUndo(fileChanges, conf.Revert)
}

if !conf.Interactive && !conf.Exec && !conf.JSON {
report.NonInteractive(fileChanges)
return nil
Expand Down
4 changes: 4 additions & 0 deletions replace/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,5 +777,9 @@ func Replace(
return nil, err
}

if conf.IncludeDir {
sortfiles.ForRenamingAndUndo(changes, conf.Revert)
}

return changes, nil
}
2 changes: 1 addition & 1 deletion replace/replace_test/replace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ func TestReplace(t *testing.T) {
},
},
Want: []string{
"music/2013/overgrown",
"music/Overgrown (2013)/01-overgrown.flac",
"music/Overgrown (2013)/02-i-am-sold.flac",
"music/Overgrown (2013)/cover.jpg",
"music/2013/overgrown",
},
Args: []string{
"-f",
Expand Down

0 comments on commit 877ae04

Please sign in to comment.