forked from forgejo/forgejo
Convert linguist attribute handling to optional.Option
Based on @KN4CK3R's work in gitea#29267. This drops the custom `LinguistBoolAttrib` type, and uses `optional.Option` instead. I added the `isTrue()` and `isFalse()` (function-local) helpers to make the code easier to follow, because these names convey their goal better than `v.ValueorDefault(false)` or `!v.ValueOrDefault(true)`. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
c80406332f
commit
ee39c58120
4 changed files with 63 additions and 54 deletions
|
@ -13,18 +13,6 @@ 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