forked from forgejo/forgejo
Backport #24900
Fix #24896
If users set different languages by `linguist-language`, the `stats` map
could be: `java: 100, Java: 200`.
Language stats are stored as case-insensitive in database and there is a
unique key.
So, the different language names should be merged to one unique name:
`Java: 300`
(cherry picked from commit a83d597989
)
This commit is contained in:
parent
5fdac0d46a
commit
6d3b3af57d
4 changed files with 58 additions and 5 deletions
|
@ -180,7 +180,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
|||
// FIXME: Why can't we split this and the IsGenerated tests to avoid reading the blob unless absolutely necessary?
|
||||
// - eg. do the all the detection tests using filename first before reading content.
|
||||
language := analyze.GetCodeLanguage(f.Name(), content)
|
||||
if language == enry.OtherLanguage || language == "" {
|
||||
if language == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -192,8 +192,8 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
|||
|
||||
included, checked := includedLanguage[language]
|
||||
if !checked {
|
||||
langtype := enry.GetLanguageType(language)
|
||||
included = langtype == enry.Programming || langtype == enry.Markup
|
||||
langType := enry.GetLanguageType(language)
|
||||
included = langType == enry.Programming || langType == enry.Markup
|
||||
includedLanguage[language] = included
|
||||
}
|
||||
if included {
|
||||
|
@ -210,7 +210,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
|||
sizes[firstExcludedLanguage] = firstExcludedLanguageSize
|
||||
}
|
||||
|
||||
return sizes, nil
|
||||
return mergeLanguageStats(sizes), nil
|
||||
}
|
||||
|
||||
func discardFull(rd *bufio.Reader, discard int64) error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue