Skip to content

Commit

Permalink
Show .editorconfig errors in frontend (#21088)
Browse files Browse the repository at this point in the history
If the user views the .editorconfig of the Repo, an the the
.editorconfig contains error, those errors are now shown above the file.
  • Loading branch information
JakobDev authored Sep 11, 2022
1 parent ec82a24 commit 23fbf5e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions templates/repo/view_file.tmpl
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down

0 comments on commit 23fbf5e

Please sign in to comment.