summaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2023-07-05 05:41:32 +0200
committerGitHub <noreply@github.com>2023-07-04 23:41:32 -0400
commit24e64fe37225a315c74c00d1f5e4d024168feea6 (patch)
treec89664dca5a884d5fc0a322815ce3bc20247cf84 /modules/git
parent4e310133f95ba8581c121a32596807721bdd6af9 (diff)
downloadgitea-24e64fe37225a315c74c00d1f5e4d024168feea6.tar.gz
gitea-24e64fe37225a315c74c00d1f5e4d024168feea6.zip
Replace `interface{}` with `any` (#25686) (#25687)
Same perl replacement as https://github.com/go-gitea/gitea/pull/25686 but for 1.20 to ease future backporting.
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/commit_info_gogit.go2
-rw-r--r--modules/git/foreachref/parser_test.go2
-rw-r--r--modules/git/git.go2
-rw-r--r--modules/git/last_commit_cache.go4
-rw-r--r--modules/git/utils.go8
5 files changed, 9 insertions, 9 deletions
diff --git a/modules/git/commit_info_gogit.go b/modules/git/commit_info_gogit.go
index 20db5691eb..c61d27993c 100644
--- a/modules/git/commit_info_gogit.go
+++ b/modules/git/commit_info_gogit.go
@@ -177,7 +177,7 @@ func GetLastCommitForPaths(ctx context.Context, cache *LastCommitCache, c cgobje
refSha := c.ID().String()
// We do a tree traversal with nodes sorted by commit time
- heap := binaryheap.NewWith(func(a, b interface{}) int {
+ heap := binaryheap.NewWith(func(a, b any) int {
if a.(*commitAndPaths).commit.CommitTime().Before(b.(*commitAndPaths).commit.CommitTime()) {
return 1
}
diff --git a/modules/git/foreachref/parser_test.go b/modules/git/foreachref/parser_test.go
index 5468318ca8..7a37ced356 100644
--- a/modules/git/foreachref/parser_test.go
+++ b/modules/git/foreachref/parser_test.go
@@ -217,7 +217,7 @@ func TestParser(t *testing.T) {
}
}
-func pretty(v interface{}) string {
+func pretty(v any) string {
data, err := json.MarshalIndent(v, "", " ")
if err != nil {
// shouldn't happen
diff --git a/modules/git/git.go b/modules/git/git.go
index f9c0ed669f..f78a496d53 100644
--- a/modules/git/git.go
+++ b/modules/git/git.go
@@ -114,7 +114,7 @@ func VersionInfo() string {
return "(git not found)"
}
format := "%s"
- args := []interface{}{gitVersion.Original()}
+ args := []any{gitVersion.Original()}
// Since git wire protocol has been released from git v2.18
if setting.Git.EnableAutoGitWireProtocol && CheckGitVersionAtLeast("2.18") == nil {
format += ", Wire Protocol %s Enabled"
diff --git a/modules/git/last_commit_cache.go b/modules/git/last_commit_cache.go
index 984561b2c6..20bc796085 100644
--- a/modules/git/last_commit_cache.go
+++ b/modules/git/last_commit_cache.go
@@ -15,9 +15,9 @@ import (
// Cache represents a caching interface
type Cache interface {
// Put puts value into cache with key and expire time.
- Put(key string, val interface{}, timeout int64) error
+ Put(key string, val any, timeout int64) error
// Get gets cached value by given key.
- Get(key string) interface{}
+ Get(key string) any
}
func getCacheKey(repoPath, commitID, entryPath string) string {
diff --git a/modules/git/utils.go b/modules/git/utils.go
index b44363820d..0d67412707 100644
--- a/modules/git/utils.go
+++ b/modules/git/utils.go
@@ -15,17 +15,17 @@ import (
// ObjectCache provides thread-safe cache operations.
type ObjectCache struct {
lock sync.RWMutex
- cache map[string]interface{}
+ cache map[string]any
}
func newObjectCache() *ObjectCache {
return &ObjectCache{
- cache: make(map[string]interface{}, 10),
+ cache: make(map[string]any, 10),
}
}
// Set add obj to cache
-func (oc *ObjectCache) Set(id string, obj interface{}) {
+func (oc *ObjectCache) Set(id string, obj any) {
oc.lock.Lock()
defer oc.lock.Unlock()
@@ -33,7 +33,7 @@ func (oc *ObjectCache) Set(id string, obj interface{}) {
}
// Get get cached obj by id
-func (oc *ObjectCache) Get(id string) (interface{}, bool) {
+func (oc *ObjectCache) Get(id string) (any, bool) {
oc.lock.RLock()
defer oc.lock.RUnlock()