summaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2020-05-29 09:20:01 +0300
committerGitHub <noreply@github.com>2020-05-29 09:20:01 +0300
commitbd2335671f0dce454a8cb669ed635a97be77f414 (patch)
treeb1a8620d8e8a1de18427ea841782a9fe72e84360 /modules/git
parente8955173a9be1acaa9a3755c37b6059422acda20 (diff)
downloadgitea-bd2335671f0dce454a8cb669ed635a97be77f414.tar.gz
gitea-bd2335671f0dce454a8cb669ed635a97be77f414.zip
Exclude generated files from language statistics (#11653)
* Update go-enry to v2.5.2
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/repo_language_stats.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/git/repo_language_stats.go b/modules/git/repo_language_stats.go
index ba58bcc2da..8ff8fa20c1 100644
--- a/modules/git/repo_language_stats.go
+++ b/modules/git/repo_language_stats.go
@@ -50,11 +50,15 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]float32, e
return nil
}
+ // If content can not be read just do detection by filename
+ content, _ := readFile(f, fileSizeLimit)
+ if enry.IsGenerated(f.Name, content) {
+ return nil
+ }
+
// TODO: Use .gitattributes file for linguist overrides
- language := analyze.GetCodeLanguageWithCallback(f.Name, func() ([]byte, error) {
- return readFile(f, fileSizeLimit)
- })
+ language := analyze.GetCodeLanguage(f.Name, content)
if language == enry.OtherLanguage || language == "" {
return nil
}