mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-16 01:43:24 +09:00
chore: enable forcetypeassert linter, fix issues (#38804)
Enable [`forcetypeassert`](https://github.com/gostaticanalysis/forcetypeassert) linter to prevent unchecked type assertions. ~650 issues fixed, most fixes were clean, some use `setting.PanicInDevOrTesting`. The only behaviour changes are where code would previously send a 500 error or panic, a 4xx error is now emitted. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -135,7 +135,7 @@ func Fork(ctx *context.Context) {
|
||||
|
||||
// ForkPost response for forking a repository
|
||||
func ForkPost(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*forms.CreateRepoForm)
|
||||
form := web.GetForm[*forms.CreateRepoForm](ctx)
|
||||
ctx.Data["Title"] = ctx.Tr("new_fork")
|
||||
|
||||
ctxUser := checkContextUser(ctx, form.UID)
|
||||
@@ -205,6 +205,8 @@ func ForkRepoTo(ctx *context.Context, owner *user_model.User, forkOpts repo_serv
|
||||
repo, err := repo_service.ForkRepository(ctx, ctx.Doer, owner, forkOpts)
|
||||
if err != nil {
|
||||
ctx.Data["Err_RepoName"] = true
|
||||
var errNameReserved db.ErrNameReserved
|
||||
var errNamePatternNotAllowed db.ErrNamePatternNotAllowed
|
||||
switch {
|
||||
case repo_model.IsErrReachLimitOfRepo(err):
|
||||
maxCreationLimit := owner.MaxCreationLimit()
|
||||
@@ -223,10 +225,10 @@ func ForkRepoTo(ctx *context.Context, owner *user_model.User, forkOpts repo_serv
|
||||
default:
|
||||
ctx.JSONError(ctx.Tr("form.repository_files_already_exist"))
|
||||
}
|
||||
case db.IsErrNameReserved(err):
|
||||
ctx.JSONError(ctx.Tr("repo.form.name_reserved", err.(db.ErrNameReserved).Name))
|
||||
case db.IsErrNamePatternNotAllowed(err):
|
||||
ctx.JSONError(ctx.Tr("repo.form.name_pattern_not_allowed", err.(db.ErrNamePatternNotAllowed).Pattern))
|
||||
case errors.As(err, &errNameReserved):
|
||||
ctx.JSONError(ctx.Tr("repo.form.name_reserved", errNameReserved.Name))
|
||||
case errors.As(err, &errNamePatternNotAllowed):
|
||||
ctx.JSONError(ctx.Tr("repo.form.name_pattern_not_allowed", errNamePatternNotAllowed.Pattern))
|
||||
case errors.Is(err, user_model.ErrBlockedUser):
|
||||
ctx.JSONError(ctx.Tr("repo.fork.blocked_user"))
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user