migrate from com.* to alternatives (#14103)

* remove github.com/unknwon/com from models

* dont use "com.ToStr()"

* replace "com.ToStr" with "fmt.Sprint" where its easy to do

* more refactor

* fix test

* just "proxy" Copy func for now

* as per @lunny
This commit is contained in:
6543 2020-12-25 09:59:32 +00:00 committed by GitHub
parent 04ae0f2f3f
commit a19447aed1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 230 additions and 220 deletions

View file

@ -34,7 +34,6 @@ import (
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
"github.com/unknwon/com"
"xorm.io/builder"
)
@ -85,7 +84,7 @@ func loadRepoConfig() {
}
for _, f := range customFiles {
if !com.IsSliceContainsStr(files, f) {
if !util.IsStringInSlice(f, files, true) {
files = append(files, f)
}
}
@ -115,12 +114,12 @@ func loadRepoConfig() {
// Filter out invalid names and promote preferred licenses.
sortedLicenses := make([]string, 0, len(Licenses))
for _, name := range setting.Repository.PreferredLicenses {
if com.IsSliceContainsStr(Licenses, name) {
if util.IsStringInSlice(name, Licenses, true) {
sortedLicenses = append(sortedLicenses, name)
}
}
for _, name := range Licenses {
if !com.IsSliceContainsStr(setting.Repository.PreferredLicenses, name) {
if !util.IsStringInSlice(name, setting.Repository.PreferredLicenses, true) {
sortedLicenses = append(sortedLicenses, name)
}
}
@ -1933,7 +1932,7 @@ func repoStatsCheck(ctx context.Context, checker *repoChecker) {
return
}
for _, result := range results {
id := com.StrTo(result["id"]).MustInt64()
id, _ := strconv.ParseInt(string(result["id"]), 10, 64)
select {
case <-ctx.Done():
log.Warn("CheckRepoStats: Cancelled before checking %s for Repo[%d]", checker.desc, id)
@ -2001,7 +2000,7 @@ func CheckRepoStats(ctx context.Context) error {
log.Error("Select %s: %v", desc, err)
} else {
for _, result := range results {
id := com.StrTo(result["id"]).MustInt64()
id, _ := strconv.ParseInt(string(result["id"]), 10, 64)
select {
case <-ctx.Done():
log.Warn("CheckRepoStats: Cancelled during %s for repo ID %d", desc, id)
@ -2024,7 +2023,7 @@ func CheckRepoStats(ctx context.Context) error {
log.Error("Select %s: %v", desc, err)
} else {
for _, result := range results {
id := com.StrTo(result["id"]).MustInt64()
id, _ := strconv.ParseInt(string(result["id"]), 10, 64)
select {
case <-ctx.Done():
log.Warn("CheckRepoStats: Cancelled")
@ -2047,7 +2046,7 @@ func CheckRepoStats(ctx context.Context) error {
log.Error("Select repository count 'num_forks': %v", err)
} else {
for _, result := range results {
id := com.StrTo(result["id"]).MustInt64()
id, _ := strconv.ParseInt(string(result["id"]), 10, 64)
select {
case <-ctx.Done():
log.Warn("CheckRepoStats: Cancelled")