forked from kevadesu/forgejo
[GITEA] Improved Linguist compatibility
Recognise the `linguist-documentation` and `linguist-detectable`
attributes in `.gitattributes` files, and use them in
`GetLanguageStats()` to make a decision whether to include a particular
file in the stats or not.
This allows one more control over which files in their repositories
contribute toward the language statistics, so that for a project that is
mostly documentation, the language stats can reflect that.
Fixes #1672.
Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit 6d4e02fe5f
)
This commit is contained in:
parent
119d10d9e2
commit
ee1ead8189
5 changed files with 341 additions and 28 deletions
|
@ -13,6 +13,18 @@ const (
|
|||
bigFileSize int64 = 1024 * 1024 // 1 MiB
|
||||
)
|
||||
|
||||
type LinguistBoolAttrib struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
func (attrib *LinguistBoolAttrib) IsTrue() bool {
|
||||
return attrib.Value == "set" || attrib.Value == "true"
|
||||
}
|
||||
|
||||
func (attrib *LinguistBoolAttrib) IsFalse() bool {
|
||||
return attrib.Value == "unset" || attrib.Value == "false"
|
||||
}
|
||||
|
||||
// mergeLanguageStats mergers language names with different cases. The name with most upper case letters is used.
|
||||
func mergeLanguageStats(stats map[string]int64) map[string]int64 {
|
||||
names := map[string]struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue