Skip to content

Commit

Permalink
repository: added cleanup for PlainClone. [Fixes src-d#741]
Browse files Browse the repository at this point in the history
Signed-off-by: Bartek Jaroszewski <[email protected]>
  • Loading branch information
bjaroszewski committed Jun 27, 2018
1 parent fcfd239 commit 3f8a9c2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,22 @@ func dotGitFileToOSFilesystem(path string, fs billy.Filesystem) (bfs billy.Files
// if the new repository will be bare or normal. If the path is not empty
// ErrRepositoryAlreadyExists is returned.
func PlainClone(path string, isBare bool, o *CloneOptions) (*Repository, error) {
return PlainCloneContext(context.Background(), path, isBare, o)
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
}
return r, err
}

// PlainCloneContext a repository into the path with the given options, isBare
Expand Down

0 comments on commit 3f8a9c2

Please sign in to comment.