code.gitea.io/gitea@v1.22.3/modules/git/attribute.go (about) 1 // Copyright 2024 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package git 5 6 import ( 7 "code.gitea.io/gitea/modules/optional" 8 ) 9 10 const ( 11 AttributeLinguistVendored = "linguist-vendored" 12 AttributeLinguistGenerated = "linguist-generated" 13 AttributeLinguistDocumentation = "linguist-documentation" 14 AttributeLinguistDetectable = "linguist-detectable" 15 AttributeLinguistLanguage = "linguist-language" 16 AttributeGitlabLanguage = "gitlab-language" 17 ) 18 19 // true if "set"/"true", false if "unset"/"false", none otherwise 20 func AttributeToBool(attr map[string]string, name string) optional.Option[bool] { 21 switch attr[name] { 22 case "set", "true": 23 return optional.Some(true) 24 case "unset", "false": 25 return optional.Some(false) 26 } 27 return optional.None[bool]() 28 } 29 30 func AttributeToString(attr map[string]string, name string) optional.Option[string] { 31 if value, has := attr[name]; has && value != "unspecified" { 32 return optional.Some(value) 33 } 34 return optional.None[string]() 35 }