From 85264cd353c6e40fafb152d26385fe977ff8288e Mon Sep 17 00:00:00 2001 From: Otto Richter Date: Tue, 2 May 2023 16:10:09 +0200 Subject: [PATCH] Fix api error message if fork exists The service returns a custom error message which is not tracked here. Change order of options The case that the fork already exists should be more common, followed by the case that a repo with the same name already exists for other reasons. The case that the global repo limit is hit is probably not the likeliest. --- routers/api/v1/repo/fork.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go index 5b564a8066c9f..e1e79c0e780ac 100644 --- a/routers/api/v1/repo/fork.go +++ b/routers/api/v1/repo/fork.go @@ -141,7 +141,7 @@ func CreateFork(ctx *context.APIContext) { Description: repo.Description, }) if err != nil { - if repo_model.IsErrReachLimitOfRepo(err) || repo_model.IsErrRepoAlreadyExist(err) { + if repo_service.IsErrForkAlreadyExist(err) || repo_model.IsErrRepoAlreadyExist(err) || repo_model.IsErrReachLimitOfRepo(err) { ctx.Error(http.StatusConflict, "ForkRepository", err) } else { ctx.Error(http.StatusInternalServerError, "ForkRepository", err)