Skip to content

Commit c5e187c

Browse files
authored
Upgrade go dependencies (#25819)
1 parent b81c013 commit c5e187c

File tree

10 files changed

+379
-398
lines changed

10 files changed

+379
-398
lines changed

assets/go-licenses.json

Lines changed: 23 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 106 additions & 105 deletions
Large diffs are not rendered by default.

go.sum

Lines changed: 226 additions & 261 deletions
Large diffs are not rendered by default.

models/actions/task.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"code.gitea.io/gitea/modules/util"
1919

2020
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
21-
lru "github.com/hashicorp/golang-lru"
21+
lru "github.com/hashicorp/golang-lru/v2"
2222
"github.com/nektos/act/pkg/jobparser"
2323
"google.golang.org/protobuf/types/known/timestamppb"
2424
"xorm.io/builder"
@@ -57,13 +57,13 @@ type ActionTask struct {
5757
Updated timeutil.TimeStamp `xorm:"updated index"`
5858
}
5959

60-
var successfulTokenTaskCache *lru.Cache
60+
var successfulTokenTaskCache *lru.Cache[string, any]
6161

6262
func init() {
6363
db.RegisterModel(new(ActionTask), func() error {
6464
if setting.SuccessfulTokensCacheSize > 0 {
6565
var err error
66-
successfulTokenTaskCache, err = lru.New(setting.SuccessfulTokensCacheSize)
66+
successfulTokenTaskCache, err = lru.New[string, any](setting.SuccessfulTokensCacheSize)
6767
if err != nil {
6868
return fmt.Errorf("unable to allocate Task cache: %v", err)
6969
}

models/auth/token.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"code.gitea.io/gitea/modules/timeutil"
1616
"code.gitea.io/gitea/modules/util"
1717

18-
lru "github.com/hashicorp/golang-lru"
18+
lru "github.com/hashicorp/golang-lru/v2"
1919
)
2020

2121
// ErrAccessTokenNotExist represents a "AccessTokenNotExist" kind of error.
@@ -54,7 +54,7 @@ func (err ErrAccessTokenEmpty) Unwrap() error {
5454
return util.ErrInvalidArgument
5555
}
5656

57-
var successfulAccessTokenCache *lru.Cache
57+
var successfulAccessTokenCache *lru.Cache[string, any]
5858

5959
// AccessToken represents a personal access token.
6060
type AccessToken struct {
@@ -83,7 +83,7 @@ func init() {
8383
db.RegisterModel(new(AccessToken), func() error {
8484
if setting.SuccessfulTokensCacheSize > 0 {
8585
var err error
86-
successfulAccessTokenCache, err = lru.New(setting.SuccessfulTokensCacheSize)
86+
successfulAccessTokenCache, err = lru.New[string, any](setting.SuccessfulTokensCacheSize)
8787
if err != nil {
8888
return fmt.Errorf("unable to allocate AccessToken cache: %w", err)
8989
}
@@ -154,16 +154,16 @@ func GetAccessTokenBySHA(token string) (*AccessToken, error) {
154154
lastEight := token[len(token)-8:]
155155

156156
if id := getAccessTokenIDFromCache(token); id > 0 {
157-
token := &AccessToken{
157+
accessToken := &AccessToken{
158158
TokenLastEight: lastEight,
159159
}
160160
// Re-get the token from the db in case it has been deleted in the intervening period
161-
has, err := db.GetEngine(db.DefaultContext).ID(id).Get(token)
161+
has, err := db.GetEngine(db.DefaultContext).ID(id).Get(accessToken)
162162
if err != nil {
163163
return nil, err
164164
}
165165
if has {
166-
return token, nil
166+
return accessToken, nil
167167
}
168168
successfulAccessTokenCache.Remove(token)
169169
}

modules/cache/cache_twoqueue.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
"code.gitea.io/gitea/modules/json"
1212

1313
mc "gitea.com/go-chi/cache"
14-
lru "github.com/hashicorp/golang-lru"
14+
lru "github.com/hashicorp/golang-lru/v2"
1515
)
1616

1717
// TwoQueueCache represents a LRU 2Q cache adapter implementation
1818
type TwoQueueCache struct {
1919
lock sync.Mutex
20-
cache *lru.TwoQueueCache
20+
cache *lru.TwoQueueCache[string, any]
2121
interval int
2222
}
2323

@@ -146,7 +146,7 @@ func (c *TwoQueueCache) Flush() error {
146146
return nil
147147
}
148148

149-
func (c *TwoQueueCache) checkAndInvalidate(key any) {
149+
func (c *TwoQueueCache) checkAndInvalidate(key string) {
150150
c.lock.Lock()
151151
defer c.lock.Unlock()
152152
cached, ok := c.cache.Peek(key)
@@ -155,7 +155,7 @@ func (c *TwoQueueCache) checkAndInvalidate(key any) {
155155
}
156156
item, ok := cached.(*MemoryItem)
157157
if !ok || item.hasExpired() {
158-
c.cache.Remove(item)
158+
c.cache.Remove(key)
159159
}
160160
}
161161

@@ -187,9 +187,9 @@ func (c *TwoQueueCache) StartAndGC(opts mc.Options) error {
187187
GhostRatio: lru.Default2QGhostEntries,
188188
}
189189
_ = json.Unmarshal([]byte(opts.AdapterConfig), cfg)
190-
c.cache, err = lru.New2QParams(cfg.Size, cfg.RecentRatio, cfg.GhostRatio)
190+
c.cache, err = lru.New2QParams[string, any](cfg.Size, cfg.RecentRatio, cfg.GhostRatio)
191191
} else {
192-
c.cache, err = lru.New2Q(size)
192+
c.cache, err = lru.New2Q[string, any](size)
193193
}
194194
c.interval = opts.Interval
195195
if c.interval > 0 {

modules/doctor/misc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"code.gitea.io/gitea/modules/structs"
2323
"code.gitea.io/gitea/modules/util"
2424

25-
lru "github.com/hashicorp/golang-lru"
25+
lru "github.com/hashicorp/golang-lru/v2"
2626
"xorm.io/builder"
2727
)
2828

@@ -130,7 +130,7 @@ func checkEnablePushOptions(ctx context.Context, logger log.Logger, autofix bool
130130
func checkDaemonExport(ctx context.Context, logger log.Logger, autofix bool) error {
131131
numRepos := 0
132132
numNeedUpdate := 0
133-
cache, err := lru.New(512)
133+
cache, err := lru.New[int64, any](512)
134134
if err != nil {
135135
logger.Critical("Unable to create cache: %v", err)
136136
return err

modules/highlight/highlight.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/alecthomas/chroma/v2/formatters/html"
2424
"github.com/alecthomas/chroma/v2/lexers"
2525
"github.com/alecthomas/chroma/v2/styles"
26-
lru "github.com/hashicorp/golang-lru"
26+
lru "github.com/hashicorp/golang-lru/v2"
2727
)
2828

2929
// don't index files larger than this many bytes for performance purposes
@@ -35,7 +35,7 @@ var (
3535

3636
once sync.Once
3737

38-
cache *lru.TwoQueueCache
38+
cache *lru.TwoQueueCache[string, any]
3939

4040
githubStyles = styles.Get("github")
4141
)
@@ -46,7 +46,7 @@ func NewContext() {
4646
highlightMapping = setting.GetHighlightMapping()
4747

4848
// The size 512 is simply a conservative rule of thumb
49-
c, err := lru.New2Q(512)
49+
c, err := lru.New2Q[string, any](512)
5050
if err != nil {
5151
panic(fmt.Sprintf("failed to initialize LRU cache for highlighter: %s", err))
5252
}

modules/markup/orgmode/orgmode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (Renderer) SanitizerRules() []setting.MarkupSanitizerRule {
5151
// Render renders orgmode rawbytes to HTML
5252
func Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error {
5353
htmlWriter := org.NewHTMLWriter()
54-
htmlWriter.HighlightCodeBlock = func(source, lang string, inline bool) string {
54+
htmlWriter.HighlightCodeBlock = func(source, lang string, inline bool, params map[string]string) string {
5555
defer func() {
5656
if err := recover(); err != nil {
5757
log.Error("Panic in HighlightCodeBlock: %v\n%s", err, log.Stack(2))

modules/regexplru/regexplru.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88

99
"code.gitea.io/gitea/modules/log"
1010

11-
lru "github.com/hashicorp/golang-lru"
11+
lru "github.com/hashicorp/golang-lru/v2"
1212
)
1313

14-
var lruCache *lru.Cache
14+
var lruCache *lru.Cache[string, any]
1515

1616
func init() {
1717
var err error
18-
lruCache, err = lru.New(1000)
18+
lruCache, err = lru.New[string, any](1000)
1919
if err != nil {
2020
log.Fatal("failed to new LRU cache, err: %v", err)
2121
}

0 commit comments

Comments
 (0)