chore(refactor): split repo_service.ForkRepository in two
ForkRepository performs two different functions: * The fork itself, if it does not already exist * Updates and notifications after the fork is performed The function is split to reflect that and otherwise unmodified. The two function are given different names to: * clarify which integration tests provides coverage * distinguish it from the notification method by the same name
This commit is contained in:
parent
a83f5cd0f0
commit
cfefe2b6c9
9 changed files with 25 additions and 15 deletions
|
@ -148,16 +148,16 @@ func CreateFork(ctx *context.APIContext) {
|
|||
name = *form.Name
|
||||
}
|
||||
|
||||
fork, err := repo_service.ForkRepository(ctx, ctx.Doer, forker, repo_service.ForkRepoOptions{
|
||||
fork, err := repo_service.ForkRepositoryAndUpdates(ctx, ctx.Doer, forker, repo_service.ForkRepoOptions{
|
||||
BaseRepo: repo,
|
||||
Name: name,
|
||||
Description: repo.Description,
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, util.ErrAlreadyExist) || repo_model.IsErrReachLimitOfRepo(err) {
|
||||
ctx.Error(http.StatusConflict, "ForkRepository", err)
|
||||
ctx.Error(http.StatusConflict, "ForkRepositoryAndUpdates", err)
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "ForkRepository", err)
|
||||
ctx.Error(http.StatusInternalServerError, "ForkRepositoryAndUpdates", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ func ForkPost(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
repo, err := repo_service.ForkRepository(ctx, ctx.Doer, ctxUser, repo_service.ForkRepoOptions{
|
||||
repo, err := repo_service.ForkRepositoryAndUpdates(ctx, ctx.Doer, ctxUser, repo_service.ForkRepoOptions{
|
||||
BaseRepo: forkRepo,
|
||||
Name: form.RepoName,
|
||||
Description: form.Description,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue