Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions modules/git/repo_language_stats_gogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
defer deferable()

sizes := make(map[string]int64)
explicitIncludedLanguage := make(map[string]struct{})
err = tree.Files().ForEach(func(f *object.File) error {
if f.Size == 0 {
return nil
Expand Down Expand Up @@ -76,7 +77,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
}

sizes[language] += f.Size

explicitIncludedLanguage[language] = struct{}{}
return nil
} else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" {
// strip off a ? if present
Expand All @@ -91,6 +92,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
}

sizes[language] += f.Size
explicitIncludedLanguage[language] = struct{}{}
return nil
}
}
Expand Down Expand Up @@ -137,7 +139,9 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
for language := range sizes {
langtype := enry.GetLanguageType(language)
if langtype != enry.Programming && langtype != enry.Markup {
delete(sizes, language)
if _, keep := explicitIncludedLanguage[language]; !keep {
delete(sizes, language)
}
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion modules/git/repo_language_stats_nogogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
contentBuf := bytes.Buffer{}
var content []byte
sizes := make(map[string]int64)
explicitIncludedLanguage := make(map[string]struct{})
for _, f := range entries {
select {
case <-repo.Ctx.Done():
Expand Down Expand Up @@ -108,6 +109,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
}

sizes[language] += f.Size()
explicitIncludedLanguage[language] = struct{}{}
continue
} else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" {
// strip off a ? if present
Expand All @@ -122,6 +124,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
}

sizes[language] += f.Size()
explicitIncludedLanguage[language] = struct{}{}
continue
}
}
Expand Down Expand Up @@ -189,7 +192,9 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
for language := range sizes {
langtype := enry.GetLanguageType(language)
if langtype != enry.Programming && langtype != enry.Markup {
delete(sizes, language)
if _, keep := explicitIncludedLanguage[language]; !keep {
delete(sizes, language)
}
}
}
}
Expand Down