Refactor git attributes (#29356)
This commit is contained in:
parent
98ab9445d1
commit
4197e28100
9 changed files with 101 additions and 100 deletions
|
@ -8,7 +8,6 @@ package git
|
|||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/analyze"
|
||||
"code.gitea.io/gitea/modules/optional"
|
||||
|
@ -66,36 +65,27 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
|
|||
if checker != nil {
|
||||
attrs, err := checker.CheckPath(f.Name)
|
||||
if err == nil {
|
||||
isVendored = attributeToBool(attrs, "linguist-vendored")
|
||||
isVendored = AttributeToBool(attrs, AttributeLinguistVendored)
|
||||
if isVendored.ValueOrDefault(false) {
|
||||
return nil
|
||||
}
|
||||
|
||||
isGenerated = attributeToBool(attrs, "linguist-generated")
|
||||
isGenerated = AttributeToBool(attrs, AttributeLinguistGenerated)
|
||||
if isGenerated.ValueOrDefault(false) {
|
||||
return nil
|
||||
}
|
||||
|
||||
isDocumentation = attributeToBool(attrs, "linguist-documentation")
|
||||
isDocumentation = AttributeToBool(attrs, AttributeLinguistDocumentation)
|
||||
if isDocumentation.ValueOrDefault(false) {
|
||||
return nil
|
||||
}
|
||||
|
||||
isDetectable = attributeToBool(attrs, "linguist-detectable")
|
||||
isDetectable = AttributeToBool(attrs, AttributeLinguistDetectable)
|
||||
if !isDetectable.ValueOrDefault(true) {
|
||||
return nil
|
||||
}
|
||||
|
||||
hasLanguage := attributeToString(attrs, "linguist-language")
|
||||
if hasLanguage.Value() == "" {
|
||||
hasLanguage = attributeToString(attrs, "gitlab-language")
|
||||
if hasLanguage.Has() {
|
||||
language := hasLanguage.Value()
|
||||
if idx := strings.IndexByte(language, '?'); idx >= 0 {
|
||||
hasLanguage = optional.Some(language[:idx])
|
||||
}
|
||||
}
|
||||
}
|
||||
hasLanguage := TryReadLanguageAttribute(attrs)
|
||||
if hasLanguage.Value() != "" {
|
||||
language := hasLanguage.Value()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue