diff options
author | JakobDev <jakobdev@gmx.de> | 2023-10-14 10:37:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-14 08:37:24 +0000 |
commit | 76a85a4ce90fead1eb2b743a42b41617b4592889 (patch) | |
tree | ef172bbbc48c24e0d95cd5c689426bad16205a69 /models/repo | |
parent | ae419fa49403537725c806a5f3f1e5b274f52eb7 (diff) | |
download | gitea-76a85a4ce90fead1eb2b743a42b41617b4592889.tar.gz gitea-76a85a4ce90fead1eb2b743a42b41617b4592889.zip |
Final round of `db.DefaultContext` refactor (#27587)
Last part of #27065
Diffstat (limited to 'models/repo')
-rw-r--r-- | models/repo/redirect.go | 4 | ||||
-rw-r--r-- | models/repo/redirect_test.go | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/models/repo/redirect.go b/models/repo/redirect.go index 92a011a453..61789ebefa 100644 --- a/models/repo/redirect.go +++ b/models/repo/redirect.go @@ -50,10 +50,10 @@ func init() { } // LookupRedirect look up if a repository has a redirect name -func LookupRedirect(ownerID int64, repoName string) (int64, error) { +func LookupRedirect(ctx context.Context, ownerID int64, repoName string) (int64, error) { repoName = strings.ToLower(repoName) redirect := &Redirect{OwnerID: ownerID, LowerName: repoName} - if has, err := db.GetEngine(db.DefaultContext).Get(redirect); err != nil { + if has, err := db.GetEngine(ctx).Get(redirect); err != nil { return 0, err } else if !has { return 0, ErrRedirectNotExist{OwnerID: ownerID, RepoName: repoName} diff --git a/models/repo/redirect_test.go b/models/repo/redirect_test.go index 8255704d59..24cf7e89fb 100644 --- a/models/repo/redirect_test.go +++ b/models/repo/redirect_test.go @@ -16,11 +16,11 @@ import ( func TestLookupRedirect(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - repoID, err := repo_model.LookupRedirect(2, "oldrepo1") + repoID, err := repo_model.LookupRedirect(db.DefaultContext, 2, "oldrepo1") assert.NoError(t, err) assert.EqualValues(t, 1, repoID) - _, err = repo_model.LookupRedirect(unittest.NonexistentID, "doesnotexist") + _, err = repo_model.LookupRedirect(db.DefaultContext, unittest.NonexistentID, "doesnotexist") assert.True(t, repo_model.IsErrRedirectNotExist(err)) } |