diff options
author | Lauris BH <lauris@nix.lv> | 2020-05-29 09:20:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-29 09:20:01 +0300 |
commit | bd2335671f0dce454a8cb669ed635a97be77f414 (patch) | |
tree | b1a8620d8e8a1de18427ea841782a9fe72e84360 /modules/analyze | |
parent | e8955173a9be1acaa9a3755c37b6059422acda20 (diff) | |
download | gitea-bd2335671f0dce454a8cb669ed635a97be77f414.tar.gz gitea-bd2335671f0dce454a8cb669ed635a97be77f414.zip |
Exclude generated files from language statistics (#11653)
* Update go-enry to v2.5.2
Diffstat (limited to 'modules/analyze')
-rw-r--r-- | modules/analyze/code_langauge.go | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/modules/analyze/code_langauge.go b/modules/analyze/code_langauge.go index 3bd2d512f9..baec2cebc5 100644 --- a/modules/analyze/code_langauge.go +++ b/modules/analyze/code_langauge.go @@ -10,8 +10,8 @@ import ( "github.com/go-enry/go-enry/v2" ) -// GetCodeLanguageWithCallback detects code language based on file name and content using callback -func GetCodeLanguageWithCallback(filename string, contentFunc func() ([]byte, error)) string { +// GetCodeLanguage detects code language based on file name and content +func GetCodeLanguage(filename string, content []byte) string { if language, ok := enry.GetLanguageByExtension(filename); ok { return language } @@ -20,17 +20,9 @@ func GetCodeLanguageWithCallback(filename string, contentFunc func() ([]byte, er return language } - content, err := contentFunc() - if err != nil { + if len(content) == 0 { return enry.OtherLanguage } return enry.GetLanguage(filepath.Base(filename), content) } - -// GetCodeLanguage detects code language based on file name and content -func GetCodeLanguage(filename string, content []byte) string { - return GetCodeLanguageWithCallback(filename, func() ([]byte, error) { - return content, nil - }) -} |