aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorCaiCandong <50507092+CaiCandong@users.noreply.github.com>2023-09-07 17:37:47 +0800
committerGitHub <noreply@github.com>2023-09-07 09:37:47 +0000
commita78c2eae243077c1fed5f7b056c64072d3c63ac8 (patch)
tree53b63a8dafde117e76f5fede968e384ae55779b1 /routers
parente97e883ad50774f249c8c694598c25a17227299b (diff)
downloadgitea-a78c2eae243077c1fed5f7b056c64072d3c63ac8.tar.gz
gitea-a78c2eae243077c1fed5f7b056c64072d3c63ac8.zip
Replace `util.SliceXxx` with `slices.Xxx` (#26958)
Diffstat (limited to 'routers')
-rw-r--r--routers/api/packages/chef/auth.go3
-rw-r--r--routers/api/v1/repo/repo.go3
-rw-r--r--routers/web/repo/issue.go3
-rw-r--r--routers/web/repo/repo.go5
-rw-r--r--routers/web/repo/view.go3
-rw-r--r--routers/web/user/home.go5
6 files changed, 14 insertions, 8 deletions
diff --git a/routers/api/packages/chef/auth.go b/routers/api/packages/chef/auth.go
index d895640894..53055bb682 100644
--- a/routers/api/packages/chef/auth.go
+++ b/routers/api/packages/chef/auth.go
@@ -16,6 +16,7 @@ import (
"net/http"
"path"
"regexp"
+ "slices"
"strconv"
"strings"
"time"
@@ -265,7 +266,7 @@ func verifyDataOld(signature, data []byte, pub *rsa.PublicKey) error {
}
}
- if !util.SliceEqual(out[skip:], data) {
+ if !slices.Equal(out[skip:], data) {
return fmt.Errorf("could not verify signature")
}
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 29f6a675d4..e86743d55a 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -7,6 +7,7 @@ package repo
import (
"fmt"
"net/http"
+ "slices"
"strings"
"time"
@@ -235,7 +236,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *user_model.User, opt api.Cre
}
// If the readme template does not exist, a 400 will be returned.
- if opt.AutoInit && len(opt.Readme) > 0 && !util.SliceContains(repo_module.Readmes, opt.Readme) {
+ if opt.AutoInit && len(opt.Readme) > 0 && !slices.Contains(repo_module.Readmes, opt.Readme) {
ctx.Error(http.StatusBadRequest, "", fmt.Errorf("readme template does not exist, available templates: %v", repo_module.Readmes))
return
}
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index f5e8f80ddf..c95d54532a 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -12,6 +12,7 @@ import (
"math/big"
"net/http"
"net/url"
+ "slices"
"sort"
"strconv"
"strings"
@@ -3628,7 +3629,7 @@ func issuePosters(ctx *context.Context, isPullList bool) {
if search == "" && ctx.Doer != nil {
// the returned posters slice only contains limited number of users,
// to make the current user (doer) can quickly filter their own issues, always add doer to the posters slice
- if !util.SliceContainsFunc(posters, func(user *user_model.User) bool { return user.ID == ctx.Doer.ID }) {
+ if !slices.ContainsFunc(posters, func(user *user_model.User) bool { return user.ID == ctx.Doer.ID }) {
posters = append(posters, ctx.Doer)
}
}
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 12cd477926..3ed7ca1c91 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"net/http"
+ "slices"
"strings"
"code.gitea.io/gitea/models"
@@ -659,7 +660,7 @@ func GetBranchesList(ctx *context.Context) {
}
resp := &branchTagSearchResponse{}
// always put default branch on the top if it exists
- if util.SliceContains(branches, ctx.Repo.Repository.DefaultBranch) {
+ if slices.Contains(branches, ctx.Repo.Repository.DefaultBranch) {
branches = util.SliceRemoveAll(branches, ctx.Repo.Repository.DefaultBranch)
branches = append([]string{ctx.Repo.Repository.DefaultBranch}, branches...)
}
@@ -693,7 +694,7 @@ func PrepareBranchList(ctx *context.Context) {
return
}
// always put default branch on the top if it exists
- if util.SliceContains(brs, ctx.Repo.Repository.DefaultBranch) {
+ if slices.Contains(brs, ctx.Repo.Repository.DefaultBranch) {
brs = util.SliceRemoveAll(brs, ctx.Repo.Repository.DefaultBranch)
brs = append([]string{ctx.Repo.Repository.DefaultBranch}, brs...)
}
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 15c85f6427..f0fe6140df 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -14,6 +14,7 @@ import (
"net/http"
"net/url"
"path"
+ "slices"
"strings"
"time"
@@ -370,7 +371,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
if workFlowErr != nil {
ctx.Data["FileError"] = ctx.Locale.Tr("actions.runs.invalid_workflow_helper", workFlowErr.Error())
}
- } else if util.SliceContains([]string{"CODEOWNERS", "docs/CODEOWNERS", ".gitea/CODEOWNERS"}, ctx.Repo.TreePath) {
+ } else if slices.Contains([]string{"CODEOWNERS", "docs/CODEOWNERS", ".gitea/CODEOWNERS"}, ctx.Repo.TreePath) {
if data, err := blob.GetBlobContent(setting.UI.MaxDisplayFileSize); err == nil {
_, warnings := issue_model.GetCodeOwnersFromContent(ctx, data)
if len(warnings) > 0 {
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index a7f6a52f1b..a88479e129 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"regexp"
+ "slices"
"sort"
"strconv"
"strings"
@@ -290,7 +291,7 @@ func Milestones(ctx *context.Context) {
if len(repoIDs) == 0 {
repoIDs = showRepoIds.Values()
}
- repoIDs = util.SliceRemoveAllFunc(repoIDs, func(v int64) bool {
+ repoIDs = slices.DeleteFunc(repoIDs, func(v int64) bool {
return !showRepoIds.Contains(v)
})
@@ -534,7 +535,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
// Gets set when clicking filters on the issues overview page.
selectedRepoIDs := getRepoIDs(ctx.FormString("repos"))
// Remove repo IDs that are not accessible to the user.
- selectedRepoIDs = util.SliceRemoveAllFunc(selectedRepoIDs, func(v int64) bool {
+ selectedRepoIDs = slices.DeleteFunc(selectedRepoIDs, func(v int64) bool {
return !accessibleRepos.Contains(v)
})
if len(selectedRepoIDs) > 0 {