Skip to content

Commit

Permalink
cmd/relocate: Fix windows regression
Browse files Browse the repository at this point in the history
This commit fixes an error handling regression on `ggman relocate` that
was only triggered on windows.
  • Loading branch information
tkw1536 committed Jun 1, 2023
1 parent 3fd41e8 commit 26425e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@ ggman comes with the following builtin aliases:

## Changelog

### 1.21.0 (Upcoming)
### 1.20.1 (Upcoming)

- fix `ggman relocate` behavior on Windows

### 1.20.0 (Released [Jun 1 2023](https://github.com/tkw1536/ggman/releases/tag/v1.20.0))

Expand Down
10 changes: 7 additions & 3 deletions cmd/relocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ func (r relocate) Run(context ggman.Context) error {
{
err := os.Rename(gotPath, shouldPath)

// check fi something already exists
if errors.Is(err, fs.ErrExist) {
return errPathAlreadyExists.WithMessageF(shouldPath)
// check if an error was returned because the path already existed
// (fs.ErrPermission is returned by Windows)
if errors.Is(err, fs.ErrExist) || errors.Is(err, fs.ErrPermission) {
if exists, _ := fsx.Exists(shouldPath); exists {
return errPathAlreadyExists.WithMessageF(shouldPath)
}
}

if err != nil {
return errUnableToMoveRepo.WrapError(err)
}
Expand Down

0 comments on commit 26425e7

Please sign in to comment.