summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/archiver/archiver_test.go6
-rw-r--r--services/mirror/mirror.go7
-rw-r--r--services/pull/check.go7
-rw-r--r--services/pull/check_test.go4
-rw-r--r--services/pull/pull.go4
-rw-r--r--services/repository/transfer.go14
-rw-r--r--services/repository/transfer_test.go10
-rw-r--r--services/webhook/deliver.go4
-rw-r--r--services/wiki/wiki.go10
9 files changed, 30 insertions, 36 deletions
diff --git a/services/archiver/archiver_test.go b/services/archiver/archiver_test.go
index 8a0f73bf9c..84bab14818 100644
--- a/services/archiver/archiver_test.go
+++ b/services/archiver/archiver_test.go
@@ -12,9 +12,9 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/test"
+ "code.gitea.io/gitea/modules/util"
"github.com/stretchr/testify/assert"
- "github.com/unknwon/com"
)
var queueMutex sync.Mutex
@@ -144,7 +144,9 @@ func TestArchive_Basic(t *testing.T) {
for _, req := range inFlight {
assert.True(t, req.IsComplete())
- assert.True(t, com.IsExist(req.GetArchivePath()))
+ exist, err := util.IsExist(req.GetArchivePath())
+ assert.NoError(t, err)
+ assert.True(t, exist)
}
arbitraryReq := inFlight[0]
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go
index 7c3d0d2239..a2acb6f363 100644
--- a/services/mirror/mirror.go
+++ b/services/mirror/mirror.go
@@ -8,6 +8,7 @@ import (
"context"
"fmt"
"net/url"
+ "strconv"
"strings"
"time"
@@ -22,8 +23,6 @@ import (
"code.gitea.io/gitea/modules/sync"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
-
- "github.com/unknwon/com"
)
// mirrorQueue holds an UniqueQueue object of the mirror
@@ -396,11 +395,11 @@ func syncMirror(repoID string) {
}()
mirrorQueue.Remove(repoID)
- m, err := models.GetMirrorByRepoID(com.StrTo(repoID).MustInt64())
+ id, _ := strconv.ParseInt(repoID, 10, 64)
+ m, err := models.GetMirrorByRepoID(id)
if err != nil {
log.Error("GetMirrorByRepoID [%s]: %v", repoID, err)
return
-
}
log.Trace("SyncMirrors [repo: %-v]: Running Sync", m.Repo)
diff --git a/services/pull/check.go b/services/pull/check.go
index 8665b3e7df..5acee8174b 100644
--- a/services/pull/check.go
+++ b/services/pull/check.go
@@ -21,8 +21,6 @@ import (
"code.gitea.io/gitea/modules/queue"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
-
- "github.com/unknwon/com"
)
// prQueue represents a queue to handle update pull request tests
@@ -203,14 +201,13 @@ func InitializePullRequests(ctx context.Context) {
// handle passed PR IDs and test the PRs
func handle(data ...queue.Data) {
for _, datum := range data {
- prID := datum.(string)
- id := com.StrTo(prID).MustInt64()
+ id, _ := strconv.ParseInt(datum.(string), 10, 64)
log.Trace("Testing PR ID %d from the pull requests patch checking queue", id)
pr, err := models.GetPullRequestByID(id)
if err != nil {
- log.Error("GetPullRequestByID[%s]: %v", prID, err)
+ log.Error("GetPullRequestByID[%s]: %v", datum, err)
continue
} else if pr.HasMerged {
continue
diff --git a/services/pull/check_test.go b/services/pull/check_test.go
index 1bddc0b592..33a230e5ab 100644
--- a/services/pull/check_test.go
+++ b/services/pull/check_test.go
@@ -15,7 +15,6 @@ import (
"code.gitea.io/gitea/modules/queue"
"github.com/stretchr/testify/assert"
- "github.com/unknwon/com"
)
func TestPullRequest_AddToTaskQueue(t *testing.T) {
@@ -25,8 +24,7 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
q, err := queue.NewChannelUniqueQueue(func(data ...queue.Data) {
for _, datum := range data {
- prID := datum.(string)
- id := com.StrTo(prID).MustInt64()
+ id, _ := strconv.ParseInt(datum.(string), 10, 64)
idChan <- id
}
}, queue.ChannelUniqueQueueConfiguration{
diff --git a/services/pull/pull.go b/services/pull/pull.go
index 99db078420..476c5dad54 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -21,8 +21,6 @@ import (
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
issue_service "code.gitea.io/gitea/services/issue"
-
- "github.com/unknwon/com"
)
// NewPullRequest creates new pull request with labels for repository.
@@ -326,7 +324,7 @@ func checkIfPRContentChanged(pr *models.PullRequest, oldCommitID, newCommitID st
defer headGitRepo.Close()
// Add a temporary remote.
- tmpRemote := "checkIfPRContentChanged-" + com.ToStr(time.Now().UnixNano())
+ tmpRemote := "checkIfPRContentChanged-" + fmt.Sprint(time.Now().UnixNano())
if err = headGitRepo.AddRemote(tmpRemote, pr.BaseRepo.RepoPath(), true); err != nil {
return false, fmt.Errorf("AddRemote: %s/%s-%s: %v", pr.HeadRepo.OwnerName, pr.HeadRepo.Name, tmpRemote, err)
}
diff --git a/services/repository/transfer.go b/services/repository/transfer.go
index d34c812b86..e2416cf8de 100644
--- a/services/repository/transfer.go
+++ b/services/repository/transfer.go
@@ -10,8 +10,6 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/sync"
-
- "github.com/unknwon/com"
)
// repoWorkingPool represents a working pool to order the parallel changes to the same repository
@@ -30,12 +28,12 @@ func TransferOwnership(doer, newOwner *models.User, repo *models.Repository, tea
oldOwner := repo.Owner
- repoWorkingPool.CheckIn(com.ToStr(repo.ID))
+ repoWorkingPool.CheckIn(fmt.Sprint(repo.ID))
if err := models.TransferOwnership(doer, newOwner.Name, repo); err != nil {
- repoWorkingPool.CheckOut(com.ToStr(repo.ID))
+ repoWorkingPool.CheckOut(fmt.Sprint(repo.ID))
return err
}
- repoWorkingPool.CheckOut(com.ToStr(repo.ID))
+ repoWorkingPool.CheckOut(fmt.Sprint(repo.ID))
newRepo, err := models.GetRepositoryByID(repo.ID)
if err != nil {
@@ -61,12 +59,12 @@ func ChangeRepositoryName(doer *models.User, repo *models.Repository, newRepoNam
// repo so that we can atomically rename the repo path and updates the
// local copy's origin accordingly.
- repoWorkingPool.CheckIn(com.ToStr(repo.ID))
+ repoWorkingPool.CheckIn(fmt.Sprint(repo.ID))
if err := models.ChangeRepositoryName(doer, repo, newRepoName); err != nil {
- repoWorkingPool.CheckOut(com.ToStr(repo.ID))
+ repoWorkingPool.CheckOut(fmt.Sprint(repo.ID))
return err
}
- repoWorkingPool.CheckOut(com.ToStr(repo.ID))
+ repoWorkingPool.CheckOut(fmt.Sprint(repo.ID))
notification.NotifyRenameRepository(doer, repo, oldRepoName)
diff --git a/services/repository/transfer_test.go b/services/repository/transfer_test.go
index 9468e1ced2..052b8c9954 100644
--- a/services/repository/transfer_test.go
+++ b/services/repository/transfer_test.go
@@ -11,9 +11,9 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/notification/action"
+ "code.gitea.io/gitea/modules/util"
"github.com/stretchr/testify/assert"
- "github.com/unknwon/com"
)
var notifySync sync.Once
@@ -37,8 +37,12 @@ func TestTransferOwnership(t *testing.T) {
transferredRepo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
assert.EqualValues(t, 2, transferredRepo.OwnerID)
- assert.False(t, com.IsExist(models.RepoPath("user3", "repo3")))
- assert.True(t, com.IsExist(models.RepoPath("user2", "repo3")))
+ exist, err := util.IsExist(models.RepoPath("user3", "repo3"))
+ assert.NoError(t, err)
+ assert.False(t, exist)
+ exist, err = util.IsExist(models.RepoPath("user2", "repo3"))
+ assert.NoError(t, err)
+ assert.True(t, exist)
models.AssertExistsAndLoadBean(t, &models.Action{
OpType: models.ActionTransferRepo,
ActUserID: 2,
diff --git a/services/webhook/deliver.go b/services/webhook/deliver.go
index 5b6c38f148..44c1a18b6c 100644
--- a/services/webhook/deliver.go
+++ b/services/webhook/deliver.go
@@ -12,6 +12,7 @@ import (
"net"
"net/http"
"net/url"
+ "strconv"
"strings"
"sync"
"time"
@@ -21,7 +22,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"github.com/gobwas/glob"
- "github.com/unknwon/com"
)
// Deliver deliver hook task
@@ -201,7 +201,7 @@ func DeliverHooks(ctx context.Context) {
log.Trace("DeliverHooks [repo_id: %v]", repoIDStr)
hookQueue.Remove(repoIDStr)
- repoID, err := com.StrTo(repoIDStr).Int64()
+ repoID, err := strconv.ParseInt(repoIDStr, 10, 64)
if err != nil {
log.Error("Invalid repo ID: %s", repoIDStr)
continue
diff --git a/services/wiki/wiki.go b/services/wiki/wiki.go
index 67ba1abd0f..75b9d1d1f5 100644
--- a/services/wiki/wiki.go
+++ b/services/wiki/wiki.go
@@ -17,8 +17,6 @@ import (
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/sync"
"code.gitea.io/gitea/modules/util"
-
- "github.com/unknwon/com"
)
var (
@@ -88,8 +86,8 @@ func updateWikiPage(doer *models.User, repo *models.Repository, oldWikiName, new
if err = nameAllowed(newWikiName); err != nil {
return err
}
- wikiWorkingPool.CheckIn(com.ToStr(repo.ID))
- defer wikiWorkingPool.CheckOut(com.ToStr(repo.ID))
+ wikiWorkingPool.CheckIn(fmt.Sprint(repo.ID))
+ defer wikiWorkingPool.CheckOut(fmt.Sprint(repo.ID))
if err = InitWiki(repo); err != nil {
return fmt.Errorf("InitWiki: %v", err)
@@ -242,8 +240,8 @@ func EditWikiPage(doer *models.User, repo *models.Repository, oldWikiName, newWi
// DeleteWikiPage deletes a wiki page identified by its path.
func DeleteWikiPage(doer *models.User, repo *models.Repository, wikiName string) (err error) {
- wikiWorkingPool.CheckIn(com.ToStr(repo.ID))
- defer wikiWorkingPool.CheckOut(com.ToStr(repo.ID))
+ wikiWorkingPool.CheckIn(fmt.Sprint(repo.ID))
+ defer wikiWorkingPool.CheckOut(fmt.Sprint(repo.ID))
if err = InitWiki(repo); err != nil {
return fmt.Errorf("InitWiki: %v", err)