1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-02 16:35:19 +02:00

Replace util.SliceXxx with slices.Xxx (#26958)

This commit is contained in:
CaiCandong 2023-09-07 17:37:47 +08:00 committed by GitHub
parent e97e883ad5
commit a78c2eae24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 46 additions and 110 deletions

View file

@ -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...)
}