Merge branch 'main' into access-token-scope
This commit is contained in:
commit
290b63d822
4 changed files with 71 additions and 19 deletions
|
@ -44,7 +44,15 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
checker, deferable := repo.CheckAttributeReader(commitID)
|
checker, deferable := repo.CheckAttributeReader(commitID)
|
||||||
defer deferable()
|
defer deferable()
|
||||||
|
|
||||||
|
// sizes contains the current calculated size of all files by language
|
||||||
sizes := make(map[string]int64)
|
sizes := make(map[string]int64)
|
||||||
|
// by default we will only count the sizes of programming languages or markup languages
|
||||||
|
// unless they are explicitly set using linguist-language
|
||||||
|
includedLanguage := map[string]bool{}
|
||||||
|
// or if there's only one language in the repository
|
||||||
|
firstExcludedLanguage := ""
|
||||||
|
firstExcludedLanguageSize := int64(0)
|
||||||
|
|
||||||
err = tree.Files().ForEach(func(f *object.File) error {
|
err = tree.Files().ForEach(func(f *object.File) error {
|
||||||
if f.Size == 0 {
|
if f.Size == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -75,8 +83,8 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
language = group
|
language = group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this language will always be added to the size
|
||||||
sizes[language] += f.Size
|
sizes[language] += f.Size
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
} else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" {
|
} else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" {
|
||||||
// strip off a ? if present
|
// strip off a ? if present
|
||||||
|
@ -90,6 +98,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
language = group
|
language = group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this language will always be added to the size
|
||||||
sizes[language] += f.Size
|
sizes[language] += f.Size
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -124,7 +133,18 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
language = group
|
language = group
|
||||||
}
|
}
|
||||||
|
|
||||||
sizes[language] += f.Size
|
included, checked := includedLanguage[language]
|
||||||
|
if !checked {
|
||||||
|
langtype := enry.GetLanguageType(language)
|
||||||
|
included = langtype == enry.Programming || langtype == enry.Markup
|
||||||
|
includedLanguage[language] = included
|
||||||
|
}
|
||||||
|
if included {
|
||||||
|
sizes[language] += f.Size
|
||||||
|
} else if len(sizes) == 0 && (firstExcludedLanguage == "" || firstExcludedLanguage == language) {
|
||||||
|
firstExcludedLanguage = language
|
||||||
|
firstExcludedLanguageSize += f.Size
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -132,14 +152,9 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter special languages unless they are the only language
|
// If there are no included languages add the first excluded language
|
||||||
if len(sizes) > 1 {
|
if len(sizes) == 0 && firstExcludedLanguage != "" {
|
||||||
for language := range sizes {
|
sizes[firstExcludedLanguage] = firstExcludedLanguageSize
|
||||||
langtype := enry.GetLanguageType(language)
|
|
||||||
if langtype != enry.Programming && langtype != enry.Markup {
|
|
||||||
delete(sizes, language)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sizes, nil
|
return sizes, nil
|
||||||
|
|
|
@ -67,7 +67,16 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
|
|
||||||
contentBuf := bytes.Buffer{}
|
contentBuf := bytes.Buffer{}
|
||||||
var content []byte
|
var content []byte
|
||||||
|
|
||||||
|
// sizes contains the current calculated size of all files by language
|
||||||
sizes := make(map[string]int64)
|
sizes := make(map[string]int64)
|
||||||
|
// by default we will only count the sizes of programming languages or markup languages
|
||||||
|
// unless they are explicitly set using linguist-language
|
||||||
|
includedLanguage := map[string]bool{}
|
||||||
|
// or if there's only one language in the repository
|
||||||
|
firstExcludedLanguage := ""
|
||||||
|
firstExcludedLanguageSize := int64(0)
|
||||||
|
|
||||||
for _, f := range entries {
|
for _, f := range entries {
|
||||||
select {
|
select {
|
||||||
case <-repo.Ctx.Done():
|
case <-repo.Ctx.Done():
|
||||||
|
@ -107,6 +116,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
language = group
|
language = group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this language will always be added to the size
|
||||||
sizes[language] += f.Size()
|
sizes[language] += f.Size()
|
||||||
continue
|
continue
|
||||||
} else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" {
|
} else if language, has := attrs["gitlab-language"]; has && language != "unspecified" && language != "" {
|
||||||
|
@ -121,6 +131,7 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
language = group
|
language = group
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this language will always be added to the size
|
||||||
sizes[language] += f.Size()
|
sizes[language] += f.Size()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -180,18 +191,24 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
||||||
language = group
|
language = group
|
||||||
}
|
}
|
||||||
|
|
||||||
sizes[language] += f.Size()
|
included, checked := includedLanguage[language]
|
||||||
|
if !checked {
|
||||||
|
langtype := enry.GetLanguageType(language)
|
||||||
|
included = langtype == enry.Programming || langtype == enry.Markup
|
||||||
|
includedLanguage[language] = included
|
||||||
|
}
|
||||||
|
if included {
|
||||||
|
sizes[language] += f.Size()
|
||||||
|
} else if len(sizes) == 0 && (firstExcludedLanguage == "" || firstExcludedLanguage == language) {
|
||||||
|
firstExcludedLanguage = language
|
||||||
|
firstExcludedLanguageSize += f.Size()
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter special languages unless they are the only language
|
// If there are no included languages add the first excluded language
|
||||||
if len(sizes) > 1 {
|
if len(sizes) == 0 && firstExcludedLanguage != "" {
|
||||||
for language := range sizes {
|
sizes[firstExcludedLanguage] = firstExcludedLanguageSize
|
||||||
langtype := enry.GetLanguageType(language)
|
|
||||||
if langtype != enry.Programming && langtype != enry.Markup {
|
|
||||||
delete(sizes, language)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sizes, nil
|
return sizes, nil
|
||||||
|
|
11
options/license/FSFULLRWD
Normal file
11
options/license/FSFULLRWD
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||||
|
2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This Makefile.in is free software; the Free Software Foundation
|
||||||
|
gives unlimited permission to copy and/or distribute it,
|
||||||
|
with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||||
|
even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE.
|
9
options/license/x11vnc-openssl-exception
Normal file
9
options/license/x11vnc-openssl-exception
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
In addition, as a special exception, Karl J. Runge
|
||||||
|
gives permission to link the code of its release of x11vnc with the
|
||||||
|
OpenSSL project's "OpenSSL" library (or with modified versions of it
|
||||||
|
that use the same license as the "OpenSSL" library), and distribute
|
||||||
|
the linked executables. You must obey the GNU General Public License
|
||||||
|
in all respects for all of the code used other than "OpenSSL". If you
|
||||||
|
modify this file, you may extend this exception to your version of the
|
||||||
|
file, but you are not obligated to do so. If you do not wish to do
|
||||||
|
so, delete this exception statement from your version.
|
Loading…
Add table
Reference in a new issue