Skip to content

Commit

Permalink
repository: added conditional to cleanup for PlainClone. [Fixes src-d…
Browse files Browse the repository at this point in the history
…#741]

Signed-off-by: Bartek Jaroszewski <[email protected]>
  • Loading branch information
bjaroszewski committed Jun 28, 2018
1 parent 3f8a9c2 commit 54d26fe
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,21 @@ func dotGitFileToOSFilesystem(path string, fs billy.Filesystem) (bfs billy.Files
// ErrRepositoryAlreadyExists is returned.
func PlainClone(path string, isBare bool, o *CloneOptions) (*Repository, error) {
r, err := PlainCloneContext(context.Background(), path, isBare, o)
switch err {
case transport.ErrAuthenticationRequired:
os.RemoveAll(path)
return nil, err
case transport.ErrAuthorizationFailed:
os.RemoveAll(path)
return nil, err
case transport.ErrRepositoryAlreadyExists:
os.RemoveAll(path)
return nil, err
default:
os.Remove(path)
return nil, err
if err != nil {
switch err {
case transport.ErrAuthenticationRequired:
os.RemoveAll(path)
return nil, err
case transport.ErrAuthorizationFailed:
os.RemoveAll(path)
return nil, err
case transport.ErrRepositoryAlreadyExists:
os.RemoveAll(path)
return nil, err
default:
os.Remove(path)
return nil, err
}
}
return r, err
}
Expand Down

0 comments on commit 54d26fe

Please sign in to comment.