diff options
author | Lauris BH <lauris@nix.lv> | 2020-06-19 15:24:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-19 15:24:03 +0300 |
commit | 6891b90303c391f5b7cbb2ff1a259526d927defb (patch) | |
tree | 5ef510590fb5577e83c1617a493c2c59c4b7d7aa /modules/git/repo_language_stats.go | |
parent | 5389b6cde1895bf145b7a830c9de2e503e7fd73d (diff) | |
download | gitea-6891b90303c391f5b7cbb2ff1a259526d927defb.tar.gz gitea-6891b90303c391f5b7cbb2ff1a259526d927defb.zip |
Use enry language type to detect special languages (#11974)
Diffstat (limited to 'modules/git/repo_language_stats.go')
-rw-r--r-- | modules/git/repo_language_stats.go | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/modules/git/repo_language_stats.go b/modules/git/repo_language_stats.go index 06ff704497..b721b996e4 100644 --- a/modules/git/repo_language_stats.go +++ b/modules/git/repo_language_stats.go @@ -20,20 +20,6 @@ import ( const fileSizeLimit int64 = 16 * 1024 // 16 KiB const bigFileSize int64 = 1024 * 1024 // 1 MiB -// specialLanguages defines list of languages that are excluded from the calculation -// unless they are the only language present in repository. Only languages which under -// normal circumstances are not considered to be code should be listed here. -var specialLanguages = []string{ - "XML", - "JSON", - "TOML", - "YAML", - "INI", - "SVG", - "Text", - "Markdown", -} - // GetLanguageStats calculates language stats for git repository at specified commit func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, error) { r, err := git.PlainOpen(repo.Path) @@ -95,8 +81,11 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err // filter special languages unless they are the only language if len(sizes) > 1 { - for _, language := range specialLanguages { - delete(sizes, language) + for language := range sizes { + langtype := enry.GetLanguageType(language) + if langtype != enry.Programming && langtype != enry.Markup { + delete(sizes, language) + } } } |