Skip to content

Commit

Permalink
add rollback when fork failed
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Oct 22, 2019
1 parent c8b8936 commit 0d36e27
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion services/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func CreateRepository(doer, owner *models.User, opts models.CreateRepoOptions) (
log.Error("Rollback deleteRepository: %v", errDelete)
}
}

return nil, err
}

Expand All @@ -32,6 +31,11 @@ func CreateRepository(doer, owner *models.User, opts models.CreateRepoOptions) (
func ForkRepository(doer, u *models.User, oldRepo *models.Repository, name, desc string) (*models.Repository, error) {
repo, err := models.ForkRepository(doer, u, oldRepo, name, desc)
if err != nil {
if repo != nil {
if errDelete := models.DeleteRepository(doer, u.ID, repo.ID); errDelete != nil {
log.Error("Rollback deleteRepository: %v", errDelete)
}
}
return nil, err
}

Expand Down

0 comments on commit 0d36e27

Please sign in to comment.