Skip to content

Rename from 'X' to 'Y' failed. #37

@canro91

Description

@canro91

First, thanks for this awesome tool. It saved a lot of time.

I'm trying to rename a project from something like src/SomeThing.Core to src/Something.Core. This is the command I'm running in a Powershell run as admin:

> renameproject.exe SomeThing.Core Something.Core --no-commit --no-paket --no-review

But, after running the above command, the renaming fails with the next output:

Analyzing references in your projects - depending on the number of projects this can take a bit...
Project `SomeThing.Core\SomeThing.Core.csproj` removed from the solution.
Rename from 'SomeThing.Core' to 'Something.Core/SomeThing.Core' failed. Should I try again? (y/n) n
fatal: renaming 'SomeThing.Core' failed: Permission denied
call 'git mv "C:\[redacted]\SomeThing\SomeThing.Core" "C:\[redacted]\SomeThing\Something.Core"' failed - aborting
...running git reset to undo any changes...
HEAD is now at f9dd0d3 Initial commit

After googling a bit, I found this SO answer where a intermediate folder is used to move the src folder to destination. Like:

git mv src src-temp
git mv src-temp dest

Changing the gitMove method to follow that workaround seems to work. This is the gitMove method after the change:

void gitMove()
{
    _filesystem.EnsureDirectoryExists(Path.GetDirectoryName(newDir));

    var tmp = $"{oldDir}-Temp";
    _git.Move(oldDir, tmp);
    _git.Move(tmp, newDir);
    var oldPath = Path.GetFileName(oldProjectPath).ToAbsolutePath(newDir);
    if (oldPath != newProjectPath) _git.Move(oldPath, newProjectPath);
}

I'm running Git 2.29.2.windows.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions