Skip to content

Commit 23fbf5e

Browse files
authored
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.
1 parent ec82a24 commit 23fbf5e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

routers/web/repo/view.go

+5
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
374374
ctx.Data["FileName"] = blob.Name()
375375
ctx.Data["RawFileLink"] = rawLink + "/" + util.PathEscapeSegments(ctx.Repo.TreePath)
376376

377+
if ctx.Repo.TreePath == ".editorconfig" {
378+
_, editorconfigErr := ctx.Repo.GetEditorconfig()
379+
ctx.Data["FileError"] = editorconfigErr
380+
}
381+
377382
buf := make([]byte, 1024)
378383
n, _ := util.ReadAtMost(dataRc, buf)
379384
buf = buf[:n]

templates/repo/view_file.tmpl

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<div class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content">
2+
{{- if .FileError}}
3+
<div class="ui warning message">
4+
<div class="text left">
5+
<div>{{.FileError}}</div>
6+
</div>
7+
</div>
8+
{{end}}
29
<h4 class="file-header ui top attached header df ac sb">
310
<div class="file-header-left df ac pr-4">
411
{{if .ReadmeInList}}

0 commit comments

Comments
 (0)