mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-06 01:09:33 +00:00
ba4d0b8ffb
The current rpm repository places all packages in the same repository, and different systems (el7,f34) may hit packages that do not belong to this distribution ( #25304 ) , which now supports grouping of rpm. ![图片](https://github.com/go-gitea/gitea/assets/33776693/d1e1d99f-7799-4b2b-a19b-cb2a5c692914) Fixes #25304 . Fixes #27056 . Refactor: [#25866](https://github.com/go-gitea/gitea/pull/25866)
48 lines
1 KiB
Go
48 lines
1 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package templates
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
|
|
"code.gitea.io/gitea/modules/base"
|
|
)
|
|
|
|
type StringUtils struct{}
|
|
|
|
var stringUtils = StringUtils{}
|
|
|
|
func NewStringUtils() *StringUtils {
|
|
return &stringUtils
|
|
}
|
|
|
|
func (su *StringUtils) HasPrefix(s, prefix string) bool {
|
|
return strings.HasPrefix(s, prefix)
|
|
}
|
|
|
|
func (su *StringUtils) Contains(s, substr string) bool {
|
|
return strings.Contains(s, substr)
|
|
}
|
|
|
|
func (su *StringUtils) ReplaceAllStringRegex(s, regex, new string) string {
|
|
return regexp.MustCompile(regex).ReplaceAllString(s, new)
|
|
}
|
|
|
|
func (su *StringUtils) Split(s, sep string) []string {
|
|
return strings.Split(s, sep)
|
|
}
|
|
|
|
func (su *StringUtils) Join(a []string, sep string) string {
|
|
return strings.Join(a, sep)
|
|
}
|
|
|
|
func (su *StringUtils) Cut(s, sep string) []any {
|
|
before, after, found := strings.Cut(s, sep)
|
|
return []any{before, after, found}
|
|
}
|
|
|
|
func (su *StringUtils) EllipsisString(s string, max int) string {
|
|
return base.EllipsisString(s, max)
|
|
}
|