diff options
author | Andrey Nering <andrey.nering@gmail.com> | 2017-02-01 10:21:03 -0200 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2017-02-01 07:21:03 -0500 |
commit | 1d951cfc4915d9beb12b9e2e9fcd178069e4ce02 (patch) | |
tree | 4771d054576b5265e3c137c152d0ba472f933768 /routers/repo/middlewares.go | |
parent | 32a0255ce3641bdad7c654cf9677115b6ef31759 (diff) |
Fix 500 when repo has invalid .editorconfig (#3758)
Creating a notice instead
Fixes #3643
Diffstat (limited to 'routers/repo/middlewares.go')
-rw-r--r-- | routers/repo/middlewares.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/routers/repo/middlewares.go b/routers/repo/middlewares.go new file mode 100644 index 00000000..2c344420 --- /dev/null +++ b/routers/repo/middlewares.go @@ -0,0 +1,23 @@ +package repo + +import ( + "fmt" + + "github.com/gogits/git-module" + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/context" +) + +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 +} |