From 984fa8d83b403baf1b72ec0e9e98a6c700aabf9d Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 3 Nov 2016 20:45:16 -0200 Subject: Fix 500 when repo has invalid .editorconfig Creating a notice instead --- routers/repo/middlewares.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 routers/repo/middlewares.go (limited to 'routers/repo/middlewares.go') diff --git a/routers/repo/middlewares.go b/routers/repo/middlewares.go new file mode 100644 index 0000000000..f025765cb9 --- /dev/null +++ b/routers/repo/middlewares.go @@ -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 +} -- cgit v1.2.3