forked from kevadesu/forgejo
Update go tool dependencies (#19676)
* Update go tool dependencies Updated all tool dependencies to latest tags, hoping CI will like it. * fix new lint errors * handle more strings.Title cases * remove lint skip
This commit is contained in:
parent
3c658dff23
commit
318f360252
12 changed files with 30 additions and 18 deletions
|
@ -43,7 +43,7 @@ var defaultTransformers = []transformer{
|
|||
{Name: "PASCAL", Transform: xstrings.ToCamelCase},
|
||||
{Name: "LOWER", Transform: strings.ToLower},
|
||||
{Name: "UPPER", Transform: strings.ToUpper},
|
||||
{Name: "TITLE", Transform: strings.Title},
|
||||
{Name: "TITLE", Transform: util.ToTitleCase},
|
||||
}
|
||||
|
||||
func generateExpansion(src string, templateRepo, generateRepo *repo_model.Repository) string {
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
ini "gopkg.in/ini.v1"
|
||||
)
|
||||
|
@ -245,7 +246,7 @@ func generateNamedLogger(key string, options defaultLogOptions) *LogDescription
|
|||
Provider: provider,
|
||||
Config: config,
|
||||
})
|
||||
log.Info("%s Log: %s(%s:%s)", strings.Title(key), strings.Title(name), provider, levelName)
|
||||
log.Info("%s Log: %s(%s:%s)", util.ToTitleCase(key), util.ToTitleCase(name), provider, levelName)
|
||||
}
|
||||
|
||||
AddLogDescription(key, &description)
|
||||
|
@ -331,7 +332,7 @@ func newLogService() {
|
|||
Provider: provider,
|
||||
Config: config,
|
||||
})
|
||||
log.Info("Gitea Log Mode: %s(%s:%s)", strings.Title(name), strings.Title(provider), levelName)
|
||||
log.Info("Gitea Log Mode: %s(%s:%s)", util.ToTitleCase(name), util.ToTitleCase(provider), levelName)
|
||||
}
|
||||
|
||||
AddLogDescription(log.DEFAULT, &description)
|
||||
|
|
|
@ -52,7 +52,7 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}[\s]*$`)
|
|||
func NewFuncMap() []template.FuncMap {
|
||||
return []template.FuncMap{map[string]interface{}{
|
||||
"GoVer": func() string {
|
||||
return strings.Title(runtime.Version())
|
||||
return util.ToTitleCase(runtime.Version())
|
||||
},
|
||||
"UseHTTPS": func() bool {
|
||||
return strings.HasPrefix(setting.AppURL, "https")
|
||||
|
@ -398,7 +398,7 @@ func NewFuncMap() []template.FuncMap {
|
|||
func NewTextFuncMap() []texttmpl.FuncMap {
|
||||
return []texttmpl.FuncMap{map[string]interface{}{
|
||||
"GoVer": func() string {
|
||||
return strings.Title(runtime.Version())
|
||||
return util.ToTitleCase(runtime.Version())
|
||||
},
|
||||
"AppName": func() string {
|
||||
return setting.AppName
|
||||
|
|
|
@ -11,6 +11,9 @@ import (
|
|||
"math/big"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
// OptionalBool a boolean that can be "null"
|
||||
|
@ -181,3 +184,10 @@ func ToUpperASCII(s string) string {
|
|||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
var titleCaser = cases.Title(language.English)
|
||||
|
||||
// ToTitleCase returns s with all english words capitalized
|
||||
func ToTitleCase(s string) string {
|
||||
return titleCaser.String(s)
|
||||
}
|
||||
|
|
|
@ -220,3 +220,8 @@ func BenchmarkToUpper(b *testing.B) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestToTitleCase(t *testing.T) {
|
||||
assert.Equal(t, ToTitleCase(`foo bar baz`), `Foo Bar Baz`)
|
||||
assert.Equal(t, ToTitleCase(`FOO BAR BAZ`), `Foo Bar Baz`)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue