mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 14:03: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:
@@ -96,16 +96,15 @@ func DeleteLabel(ctx *context.Context) {
|
||||
|
||||
// InitializeLabels init labels for an organization
|
||||
func InitializeLabels(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*forms.InitializeLabelsForm)
|
||||
form := web.GetForm[*forms.InitializeLabelsForm](ctx)
|
||||
if ctx.HasError() {
|
||||
ctx.Redirect(ctx.Org.OrgLink + "/labels")
|
||||
return
|
||||
}
|
||||
|
||||
if err := repo_module.InitializeLabels(ctx, ctx.Org.Organization.ID, form.TemplateName, true); err != nil {
|
||||
if label.IsErrTemplateLoad(err) {
|
||||
originalErr := err.(label.ErrTemplateLoad).OriginalError
|
||||
ctx.Flash.Error(ctx.Tr("repo.issues.label_templates.fail_to_load_file", form.TemplateName, originalErr))
|
||||
if errTemplateLoad, ok := err.(label.ErrTemplateLoad); ok {
|
||||
ctx.Flash.Error(ctx.Tr("repo.issues.label_templates.fail_to_load_file", form.TemplateName, errTemplateLoad.OriginalError))
|
||||
ctx.Redirect(ctx.Org.OrgLink + "/settings/labels")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user