diff options
Diffstat (limited to 'services')
-rw-r--r-- | services/repository/repository.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/services/repository/repository.go b/services/repository/repository.go index 5135435c78..b1156b41d5 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -44,6 +44,21 @@ func ForkRepository(doer, u *models.User, oldRepo *models.Repository, name, desc return repo, nil } +// GenerateRepository generates a repository from a template +func GenerateRepository(doer, u *models.User, oldRepo *models.Repository, opts models.GenerateRepoOptions) (*models.Repository, error) { + repo, err := models.GenerateRepository(doer, u, oldRepo, opts) + 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 + } + + return repo, nil +} + // DeleteRepository deletes a repository for a user or organization. func DeleteRepository(doer *models.User, repo *models.Repository) error { if err := models.DeleteRepository(doer, repo.OwnerID, repo.ID); err != nil { |