Skip to content

The "rename" action cannot handle some situations and result is unexpectable #111

@lambdalisue

Description

@lambdalisue

Simple renames (Success)

foo -> a
bar -> b

Nested renames (Fails)

foo   -> bar
foo/a -> bar/b
foo/c -> bar/c

Explanation

The foo/a does not exist after foo -> bar renames thus the second one is skipped.

How to solve

The foo/a in the second step must become bar/a prior to execute the actual rename.

Cross renames (Fails)

foo     -> a/foo
foo/a   -> a

Explanation

Fern starts renaming from the top thus it creates a directory in the first step.
That's why the second step is skipped while the destination exist.

How to solve

The order of the operations must be changed as the below.
Shallower destination paths must be operated first.

foo/a   -> a
foo     -> a/foo

NOTE: fern should warn if foo/a is file and a/foo cannot be created.

Cyclic renames (Fails)

foo -> bar
bar -> foo

Explanation

The destination exists so fern skip the operations.

How to solve

A temporary destination is required.
For example, the operations must be changed as the below.

foo            -> {tempname}/bar
bar            -> foo
{tempname}/bar -> bar

Nested and Cyclic renames (Fails)

a   -> b
a/b -> b/c
a/c -> b/b

Explanation

The destination exists so fern skip the operations.

How to solve

A temporary destination is required.
For example, the operations must be changed as the below.

a              -> b
b/b            -> {tempname}/b/c
b/c            -> b/b
{tempname}/b/c -> b/c

Conflicts with exsiting file (Fails)

foo   -> bar
foo/a -> bar/b

Above renames on the follwoing tree should be avoided before actual renames.

foo
|- a
|- b

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededin progressThings in progress

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions