aboutsummaryrefslogtreecommitdiffstats
path: root/models
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 /models
parente97e883ad50774f249c8c694598c25a17227299b (diff)
downloadgitea-a78c2eae243077c1fed5f7b056c64072d3c63ac8.tar.gz
gitea-a78c2eae243077c1fed5f7b056c64072d3c63ac8.zip
Replace `util.SliceXxx` with `slices.Xxx` (#26958)
Diffstat (limited to 'models')
-rw-r--r--models/actions/run.go3
-rw-r--r--models/actions/run_job.go5
-rw-r--r--models/git/protected_branch.go3
-rw-r--r--models/issues/issue.go5
-rw-r--r--models/repo/repo_unit.go3
5 files changed, 12 insertions, 7 deletions
diff --git a/models/actions/run.go b/models/actions/run.go
index 18ed447e80..4853afc15b 100644
--- a/models/actions/run.go
+++ b/models/actions/run.go
@@ -6,6 +6,7 @@ package actions
import (
"context"
"fmt"
+ "slices"
"strings"
"time"
@@ -350,7 +351,7 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
// It's impossible that the run is not found, since Gitea never deletes runs.
}
- if run.Status != 0 || util.SliceContains(cols, "status") {
+ if run.Status != 0 || slices.Contains(cols, "status") {
if run.RepoID == 0 {
run, err = GetRunByID(ctx, run.ID)
if err != nil {
diff --git a/models/actions/run_job.go b/models/actions/run_job.go
index 1da58bb659..4b8664077d 100644
--- a/models/actions/run_job.go
+++ b/models/actions/run_job.go
@@ -6,6 +6,7 @@ package actions
import (
"context"
"fmt"
+ "slices"
"time"
"code.gitea.io/gitea/models/db"
@@ -107,11 +108,11 @@ func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, col
return 0, err
}
- if affected == 0 || (!util.SliceContains(cols, "status") && job.Status == 0) {
+ if affected == 0 || (!slices.Contains(cols, "status") && job.Status == 0) {
return affected, nil
}
- if affected != 0 && util.SliceContains(cols, "status") && job.Status.IsWaiting() {
+ if affected != 0 && slices.Contains(cols, "status") && job.Status.IsWaiting() {
// if the status of job changes to waiting again, increase tasks version.
if err := IncreaseTaskVersion(ctx, job.OwnerID, job.RepoID); err != nil {
return 0, err
diff --git a/models/git/protected_branch.go b/models/git/protected_branch.go
index eef7e3935a..5ed1003749 100644
--- a/models/git/protected_branch.go
+++ b/models/git/protected_branch.go
@@ -7,6 +7,7 @@ import (
"context"
"errors"
"fmt"
+ "slices"
"strings"
"code.gitea.io/gitea/models/db"
@@ -435,7 +436,7 @@ func updateTeamWhitelist(ctx context.Context, repo *repo_model.Repository, curre
whitelist = make([]int64, 0, len(teams))
for i := range teams {
- if util.SliceContains(newWhitelist, teams[i].ID) {
+ if slices.Contains(newWhitelist, teams[i].ID) {
whitelist = append(whitelist, teams[i].ID)
}
}
diff --git a/models/issues/issue.go b/models/issues/issue.go
index f000f4c660..8f59c9cb42 100644
--- a/models/issues/issue.go
+++ b/models/issues/issue.go
@@ -8,6 +8,7 @@ import (
"context"
"fmt"
"regexp"
+ "slices"
"code.gitea.io/gitea/models/db"
project_model "code.gitea.io/gitea/models/project"
@@ -605,7 +606,7 @@ func IsUserParticipantsOfIssue(user *user_model.User, issue *Issue) bool {
log.Error(err.Error())
return false
}
- return util.SliceContains(userIDs, user.ID)
+ return slices.Contains(userIDs, user.ID)
}
// DependencyInfo represents high level information about an issue which is a dependency of another issue.
@@ -630,7 +631,7 @@ func (issue *Issue) GetParticipantIDsByIssue(ctx context.Context) ([]int64, erro
Find(&userIDs); err != nil {
return nil, fmt.Errorf("get poster IDs: %w", err)
}
- if !util.SliceContains(userIDs, issue.PosterID) {
+ if !slices.Contains(userIDs, issue.PosterID) {
return append(userIDs, issue.PosterID), nil
}
return userIDs, nil
diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go
index cf9ff93d32..b8804c6df1 100644
--- a/models/repo/repo_unit.go
+++ b/models/repo/repo_unit.go
@@ -6,6 +6,7 @@ package repo
import (
"context"
"fmt"
+ "slices"
"strings"
"code.gitea.io/gitea/models/db"
@@ -176,7 +177,7 @@ func (cfg *ActionsConfig) ToString() string {
}
func (cfg *ActionsConfig) IsWorkflowDisabled(file string) bool {
- return util.SliceContains(cfg.DisabledWorkflows, file)
+ return slices.Contains(cfg.DisabledWorkflows, file)
}
func (cfg *ActionsConfig) DisableWorkflow(file string) {