Refactor the fork service slightly to take ForkRepoOptions (#16744)

* Refactor the fork service slightly to take ForkRepoOptions

This reduces the number of places we need to change if we want to add other
options during fork time.

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>

* Fix integrations and tests after ForkRepository refactor

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>

* Update OldRepo -> BaseRepo

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>

* gofmt pass

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
This commit is contained in:
Kyle Evans 2021-08-28 03:37:14 -05:00 committed by GitHub
parent 1904941382
commit cad70599a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 23 deletions

View file

@ -123,7 +123,11 @@ func CreateFork(ctx *context.APIContext) {
forker = org
}
fork, err := repo_service.ForkRepository(ctx.User, forker, repo, repo.Name, repo.Description)
fork, err := repo_service.ForkRepository(ctx.User, forker, models.ForkRepoOptions{
BaseRepo: repo,
Name: repo.Name,
Description: repo.Description,
})
if err != nil {
ctx.Error(http.StatusInternalServerError, "ForkRepository", err)
return

View file

@ -225,7 +225,11 @@ func ForkPost(ctx *context.Context) {
}
}
repo, err := repo_service.ForkRepository(ctx.User, ctxUser, forkRepo, form.RepoName, form.Description)
repo, err := repo_service.ForkRepository(ctx.User, ctxUser, models.ForkRepoOptions{
BaseRepo: forkRepo,
Name: form.RepoName,
Description: form.Description,
})
if err != nil {
ctx.Data["Err_RepoName"] = true
switch {