aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-05-22 19:21:46 +0900
committerGitHub <noreply@github.com>2023-05-22 18:21:46 +0800
commitbebc3433c5c1e843ac36603eafd1a0615f64716f (patch)
tree676788ccea930dc271c47de9de3b0632704c2c73 /routers/api
parentf4ef7eed0072d037c3a211af36ccc9f4e11d0014 (diff)
downloadgitea-bebc3433c5c1e843ac36603eafd1a0615f64716f.tar.gz
gitea-bebc3433c5c1e843ac36603eafd1a0615f64716f.zip
Add IsErrRepoFilesAlreadyExist check when fork repo (#24678)
Before: ![image](https://github.com/go-gitea/gitea/assets/18380374/e9e3de75-eb6e-418e-9227-ef4e5f448a04) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/74b1cd6c-c5b1-4ee0-a1d8-6b3fb8d3a8e9)
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/repo/fork.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go
index e1e79c0e78..4cb3eddf58 100644
--- a/routers/api/v1/repo/fork.go
+++ b/routers/api/v1/repo/fork.go
@@ -5,6 +5,7 @@
package repo
import (
+ "errors"
"fmt"
"net/http"
@@ -15,6 +16,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
api "code.gitea.io/gitea/modules/structs"
+ "code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/api/v1/utils"
"code.gitea.io/gitea/services/convert"
@@ -141,7 +143,7 @@ func CreateFork(ctx *context.APIContext) {
Description: repo.Description,
})
if err != nil {
- if repo_service.IsErrForkAlreadyExist(err) || repo_model.IsErrRepoAlreadyExist(err) || repo_model.IsErrReachLimitOfRepo(err) {
+ if errors.Is(err, util.ErrAlreadyExist) || repo_model.IsErrReachLimitOfRepo(err) {
ctx.Error(http.StatusConflict, "ForkRepository", err)
} else {
ctx.Error(http.StatusInternalServerError, "ForkRepository", err)