mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Fix 500 when repo has invalid .editorconfig
Creating a notice instead
This commit is contained in:
23
routers/repo/middlewares.go
Normal file
23
routers/repo/middlewares.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-gitea/gitea/models"
|
||||
"github.com/go-gitea/gitea/modules/context"
|
||||
"github.com/gogits/git-module"
|
||||
)
|
||||
|
||||
func setEditorconfigIfExists(ctx *context.Context) {
|
||||
ec, err := ctx.Repo.GetEditorconfig()
|
||||
|
||||
if err != nil && !git.IsErrNotExist(err) {
|
||||
description := fmt.Sprintf("Error while getting .editorconfig file: %v", err)
|
||||
if err := models.CreateRepositoryNotice(description); err != nil {
|
||||
ctx.Handle(500, "ErrCreatingReporitoryNotice", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Editorconfig"] = ec
|
||||
}
|
Reference in New Issue
Block a user