Skip to content

Commit 6891b90

Browse files
authored
Use enry language type to detect special languages (#11974)
1 parent 5389b6c commit 6891b90

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

modules/git/repo_language_stats.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ import (
2020
const fileSizeLimit int64 = 16 * 1024 // 16 KiB
2121
const bigFileSize int64 = 1024 * 1024 // 1 MiB
2222

23-
// specialLanguages defines list of languages that are excluded from the calculation
24-
// unless they are the only language present in repository. Only languages which under
25-
// normal circumstances are not considered to be code should be listed here.
26-
var specialLanguages = []string{
27-
"XML",
28-
"JSON",
29-
"TOML",
30-
"YAML",
31-
"INI",
32-
"SVG",
33-
"Text",
34-
"Markdown",
35-
}
36-
3723
// GetLanguageStats calculates language stats for git repository at specified commit
3824
func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, error) {
3925
r, err := git.PlainOpen(repo.Path)
@@ -95,8 +81,11 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
9581

9682
// filter special languages unless they are the only language
9783
if len(sizes) > 1 {
98-
for _, language := range specialLanguages {
99-
delete(sizes, language)
84+
for language := range sizes {
85+
langtype := enry.GetLanguageType(language)
86+
if langtype != enry.Programming && langtype != enry.Markup {
87+
delete(sizes, language)
88+
}
10089
}
10190
}
10291

0 commit comments

Comments
 (0)