From 76a85a4ce90fead1eb2b743a42b41617b4592889 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Sat, 14 Oct 2023 10:37:24 +0200 Subject: Final round of `db.DefaultContext` refactor (#27587) Last part of #27065 --- models/repo/redirect.go | 4 ++-- models/repo/redirect_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'models/repo') 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)) } -- cgit v1.2.3