diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 26734f2dd6..effb3896c2 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1191,6 +1191,8 @@ audio_not_supported_in_browser = Your browser does not support the HTML5 'audio' stored_lfs = Stored with Git LFS symbolic_link = Symbolic link executable_file = Executable File +vendored = Vendored +generated = Generated commit_graph = Commit Graph commit_graph.select = Select branches commit_graph.hide_pr_refs = Hide Pull Requests diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index aa07d5939d..00fd47b650 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -647,6 +647,21 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) { } } + if ctx.Repo.GitRepo != nil { + checker, deferable := ctx.Repo.GitRepo.CheckAttributeReader(ctx.Repo.CommitID) + if checker != nil { + defer deferable() + attrs, err := checker.CheckPath(ctx.Repo.TreePath) + if err == nil { + vendored, has := attrs["linguist-vendored"] + ctx.Data["IsVendored"] = has && (vendored == "set" || vendored == "true") + + generated, has := attrs["linguist-generated"] + ctx.Data["IsGenerated"] = has && (generated == "set" || generated == "true") + } + } + } + if fInfo.st.IsImage() && !fInfo.st.IsSvgImage() { img, _, err := image.DecodeConfig(bytes.NewReader(buf)) if err == nil { diff --git a/templates/repo/file_info.tmpl b/templates/repo/file_info.tmpl index 3003fbbdb6..33f0f87d61 100644 --- a/templates/repo/file_info.tmpl +++ b/templates/repo/file_info.tmpl @@ -30,6 +30,16 @@ {{ctx.Locale.Tr "repo.executable_file"}} {{end}} + {{if .IsVendored}} +
+ {{ctx.Locale.Tr "repo.vendored"}} +
+ {{end}} + {{if .IsGenerated}} +
+ {{ctx.Locale.Tr "repo.generated"}} +
+ {{end}} {{if .ImageSize}}
{{.ImageSize}}