mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -374,6 +374,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
 | 
				
			|||||||
	ctx.Data["FileName"] = blob.Name()
 | 
						ctx.Data["FileName"] = blob.Name()
 | 
				
			||||||
	ctx.Data["RawFileLink"] = rawLink + "/" + util.PathEscapeSegments(ctx.Repo.TreePath)
 | 
						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)
 | 
						buf := make([]byte, 1024)
 | 
				
			||||||
	n, _ := util.ReadAtMost(dataRc, buf)
 | 
						n, _ := util.ReadAtMost(dataRc, buf)
 | 
				
			||||||
	buf = buf[:n]
 | 
						buf = buf[:n]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,11 @@
 | 
				
			|||||||
<div class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content">
 | 
					<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">
 | 
						<h4 class="file-header ui top attached header df ac sb">
 | 
				
			||||||
		<div class="file-header-left df ac pr-4">
 | 
							<div class="file-header-left df ac pr-4">
 | 
				
			||||||
			{{if .ReadmeInList}}
 | 
								{{if .ReadmeInList}}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user