diff options
author | JakobDev <jakobdev@gmx.de> | 2022-09-12 00:16:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-12 00:16:56 +0200 |
commit | 23fbf5e1eef8985d8223e5c34e92e8bd2c97bac4 (patch) | |
tree | 5f87657494653590a6aa7e8d593be01bc6cf88e1 | |
parent | ec82a245477c42495ce4857cfc87c99d0220d028 (diff) | |
download | gitea-23fbf5e1eef8985d8223e5c34e92e8bd2c97bac4.tar.gz gitea-23fbf5e1eef8985d8223e5c34e92e8bd2c97bac4.zip |
Show .editorconfig errors in frontend (#21088)
If the user views the .editorconfig of the Repo, an the the
.editorconfig contains error, those errors are now shown above the file.
-rw-r--r-- | routers/web/repo/view.go | 5 | ||||
-rw-r--r-- | templates/repo/view_file.tmpl | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index cdfb4b9906..65c8ab92cf 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -374,6 +374,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["FileName"] = blob.Name() ctx.Data["RawFileLink"] = rawLink + "/" + util.PathEscapeSegments(ctx.Repo.TreePath) + if ctx.Repo.TreePath == ".editorconfig" { + _, editorconfigErr := ctx.Repo.GetEditorconfig() + ctx.Data["FileError"] = editorconfigErr + } + buf := make([]byte, 1024) n, _ := util.ReadAtMost(dataRc, buf) buf = buf[:n] diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index f06521046e..2b4f279cb6 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -1,4 +1,11 @@ <div class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content"> + {{- if .FileError}} + <div class="ui warning message"> + <div class="text left"> + <div>{{.FileError}}</div> + </div> + </div> + {{end}} <h4 class="file-header ui top attached header df ac sb"> <div class="file-header-left df ac pr-4"> {{if .ReadmeInList}} |