summaryrefslogtreecommitdiffstats
path: root/models/repo_redirect.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-12-06 12:00:50 +0800
committerGitHub <noreply@github.com>2019-12-06 12:00:50 +0800
commit77730db25768036a12e16cef9839b9492218303f (patch)
treebc1df7483f0be61609fa668093f2d04011faa100 /models/repo_redirect.go
parent9ff5b7555913964ebc6c463b00055394c85b8689 (diff)
downloadgitea-77730db25768036a12e16cef9839b9492218303f.tar.gz
gitea-77730db25768036a12e16cef9839b9492218303f.zip
Move repoWorkPool outside rename/transfer repository (#9086)
* Move repoWorkPool outside rename/transfer repository * fix import * Fix test
Diffstat (limited to 'models/repo_redirect.go')
-rw-r--r--models/repo_redirect.go24
1 files changed, 4 insertions, 20 deletions
diff --git a/models/repo_redirect.go b/models/repo_redirect.go
index 2714121a6c..182b6b41a2 100644
--- a/models/repo_redirect.go
+++ b/models/repo_redirect.go
@@ -6,8 +6,6 @@ package models
import (
"strings"
-
- "code.gitea.io/gitea/modules/log"
)
// RepoRedirect represents that a repo name should be redirected to another
@@ -31,36 +29,22 @@ func LookupRepoRedirect(ownerID int64, repoName string) (int64, error) {
}
// NewRepoRedirect create a new repo redirect
-func NewRepoRedirect(ownerID, repoID int64, oldRepoName, newRepoName string) error {
+func NewRepoRedirect(ctx DBContext, ownerID, repoID int64, oldRepoName, newRepoName string) error {
oldRepoName = strings.ToLower(oldRepoName)
newRepoName = strings.ToLower(newRepoName)
- sess := x.NewSession()
- defer sess.Close()
-
- if err := sess.Begin(); err != nil {
- return err
- }
- if err := deleteRepoRedirect(sess, ownerID, newRepoName); err != nil {
- errRollback := sess.Rollback()
- if errRollback != nil {
- log.Error("NewRepoRedirect sess.Rollback: %v", errRollback)
- }
+ if err := deleteRepoRedirect(ctx.e, ownerID, newRepoName); err != nil {
return err
}
- if _, err := sess.Insert(&RepoRedirect{
+ if _, err := ctx.e.Insert(&RepoRedirect{
OwnerID: ownerID,
LowerName: oldRepoName,
RedirectRepoID: repoID,
}); err != nil {
- errRollback := sess.Rollback()
- if errRollback != nil {
- log.Error("NewRepoRedirect sess.Rollback: %v", errRollback)
- }
return err
}
- return sess.Commit()
+ return nil
}
// deleteRepoRedirect delete any redirect from the specified repo name to