Skip to content

Commit 7adc2de

Browse files
wolfogrelunny
andauthored
Use context parameter in models/git (#22367)
After #22362, we can feel free to use transactions without `db.DefaultContext`. And there are still lots of models using `db.DefaultContext`, I think we should refactor them carefully and one by one. Co-authored-by: Lunny Xiao <[email protected]>
1 parent b878155 commit 7adc2de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+179
-176
lines changed

models/git/branches.go

+26-26
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ func (protectBranch *ProtectedBranch) IsProtected() bool {
6767
}
6868

6969
// CanUserPush returns if some user could push to this protected branch
70-
func (protectBranch *ProtectedBranch) CanUserPush(userID int64) bool {
70+
func (protectBranch *ProtectedBranch) CanUserPush(ctx context.Context, userID int64) bool {
7171
if !protectBranch.CanPush {
7272
return false
7373
}
7474

7575
if !protectBranch.EnableWhitelist {
76-
if user, err := user_model.GetUserByID(db.DefaultContext, userID); err != nil {
76+
if user, err := user_model.GetUserByID(ctx, userID); err != nil {
7777
log.Error("GetUserByID: %v", err)
7878
return false
79-
} else if repo, err := repo_model.GetRepositoryByID(db.DefaultContext, protectBranch.RepoID); err != nil {
79+
} else if repo, err := repo_model.GetRepositoryByID(ctx, protectBranch.RepoID); err != nil {
8080
log.Error("repo_model.GetRepositoryByID: %v", err)
8181
return false
82-
} else if writeAccess, err := access_model.HasAccessUnit(db.DefaultContext, user, repo, unit.TypeCode, perm.AccessModeWrite); err != nil {
82+
} else if writeAccess, err := access_model.HasAccessUnit(ctx, user, repo, unit.TypeCode, perm.AccessModeWrite); err != nil {
8383
log.Error("HasAccessUnit: %v", err)
8484
return false
8585
} else {
@@ -95,7 +95,7 @@ func (protectBranch *ProtectedBranch) CanUserPush(userID int64) bool {
9595
return false
9696
}
9797

98-
in, err := organization.IsUserInTeams(db.DefaultContext, userID, protectBranch.WhitelistTeamIDs)
98+
in, err := organization.IsUserInTeams(ctx, userID, protectBranch.WhitelistTeamIDs)
9999
if err != nil {
100100
log.Error("IsUserInTeams: %v", err)
101101
return false
@@ -320,19 +320,19 @@ func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, prote
320320
}
321321

322322
// GetProtectedBranches get all protected branches
323-
func GetProtectedBranches(repoID int64) ([]*ProtectedBranch, error) {
323+
func GetProtectedBranches(ctx context.Context, repoID int64) ([]*ProtectedBranch, error) {
324324
protectedBranches := make([]*ProtectedBranch, 0)
325-
return protectedBranches, db.GetEngine(db.DefaultContext).Find(&protectedBranches, &ProtectedBranch{RepoID: repoID})
325+
return protectedBranches, db.GetEngine(ctx).Find(&protectedBranches, &ProtectedBranch{RepoID: repoID})
326326
}
327327

328328
// IsProtectedBranch checks if branch is protected
329-
func IsProtectedBranch(repoID int64, branchName string) (bool, error) {
329+
func IsProtectedBranch(ctx context.Context, repoID int64, branchName string) (bool, error) {
330330
protectedBranch := &ProtectedBranch{
331331
RepoID: repoID,
332332
BranchName: branchName,
333333
}
334334

335-
has, err := db.GetEngine(db.DefaultContext).Exist(protectedBranch)
335+
has, err := db.GetEngine(ctx).Exist(protectedBranch)
336336
if err != nil {
337337
return true, err
338338
}
@@ -413,13 +413,13 @@ func updateTeamWhitelist(ctx context.Context, repo *repo_model.Repository, curre
413413
}
414414

415415
// DeleteProtectedBranch removes ProtectedBranch relation between the user and repository.
416-
func DeleteProtectedBranch(repoID, id int64) (err error) {
416+
func DeleteProtectedBranch(ctx context.Context, repoID, id int64) (err error) {
417417
protectedBranch := &ProtectedBranch{
418418
RepoID: repoID,
419419
ID: id,
420420
}
421421

422-
if affected, err := db.GetEngine(db.DefaultContext).Delete(protectedBranch); err != nil {
422+
if affected, err := db.GetEngine(ctx).Delete(protectedBranch); err != nil {
423423
return err
424424
} else if affected != 1 {
425425
return fmt.Errorf("delete protected branch ID(%v) failed", id)
@@ -440,28 +440,28 @@ type DeletedBranch struct {
440440
}
441441

442442
// AddDeletedBranch adds a deleted branch to the database
443-
func AddDeletedBranch(repoID int64, branchName, commit string, deletedByID int64) error {
443+
func AddDeletedBranch(ctx context.Context, repoID int64, branchName, commit string, deletedByID int64) error {
444444
deletedBranch := &DeletedBranch{
445445
RepoID: repoID,
446446
Name: branchName,
447447
Commit: commit,
448448
DeletedByID: deletedByID,
449449
}
450450

451-
_, err := db.GetEngine(db.DefaultContext).Insert(deletedBranch)
451+
_, err := db.GetEngine(ctx).Insert(deletedBranch)
452452
return err
453453
}
454454

455455
// GetDeletedBranches returns all the deleted branches
456-
func GetDeletedBranches(repoID int64) ([]*DeletedBranch, error) {
456+
func GetDeletedBranches(ctx context.Context, repoID int64) ([]*DeletedBranch, error) {
457457
deletedBranches := make([]*DeletedBranch, 0)
458-
return deletedBranches, db.GetEngine(db.DefaultContext).Where("repo_id = ?", repoID).Desc("deleted_unix").Find(&deletedBranches)
458+
return deletedBranches, db.GetEngine(ctx).Where("repo_id = ?", repoID).Desc("deleted_unix").Find(&deletedBranches)
459459
}
460460

461461
// GetDeletedBranchByID get a deleted branch by its ID
462-
func GetDeletedBranchByID(repoID, id int64) (*DeletedBranch, error) {
462+
func GetDeletedBranchByID(ctx context.Context, repoID, id int64) (*DeletedBranch, error) {
463463
deletedBranch := &DeletedBranch{}
464-
has, err := db.GetEngine(db.DefaultContext).Where("repo_id = ?", repoID).And("id = ?", id).Get(deletedBranch)
464+
has, err := db.GetEngine(ctx).Where("repo_id = ?", repoID).And("id = ?", id).Get(deletedBranch)
465465
if err != nil {
466466
return nil, err
467467
}
@@ -472,13 +472,13 @@ func GetDeletedBranchByID(repoID, id int64) (*DeletedBranch, error) {
472472
}
473473

474474
// RemoveDeletedBranchByID removes a deleted branch from the database
475-
func RemoveDeletedBranchByID(repoID, id int64) (err error) {
475+
func RemoveDeletedBranchByID(ctx context.Context, repoID, id int64) (err error) {
476476
deletedBranch := &DeletedBranch{
477477
RepoID: repoID,
478478
ID: id,
479479
}
480480

481-
if affected, err := db.GetEngine(db.DefaultContext).Delete(deletedBranch); err != nil {
481+
if affected, err := db.GetEngine(ctx).Delete(deletedBranch); err != nil {
482482
return err
483483
} else if affected != 1 {
484484
return fmt.Errorf("remove deleted branch ID(%v) failed", id)
@@ -498,8 +498,8 @@ func (deletedBranch *DeletedBranch) LoadUser(ctx context.Context) {
498498
}
499499

500500
// RemoveDeletedBranchByName removes all deleted branches
501-
func RemoveDeletedBranchByName(repoID int64, branch string) error {
502-
_, err := db.GetEngine(db.DefaultContext).Where("repo_id=? AND name=?", repoID, branch).Delete(new(DeletedBranch))
501+
func RemoveDeletedBranchByName(ctx context.Context, repoID int64, branch string) error {
502+
_, err := db.GetEngine(ctx).Where("repo_id=? AND name=?", repoID, branch).Delete(new(DeletedBranch))
503503
return err
504504
}
505505

@@ -509,7 +509,7 @@ func RemoveOldDeletedBranches(ctx context.Context, olderThan time.Duration) {
509509
log.Trace("Doing: DeletedBranchesCleanup")
510510

511511
deleteBefore := time.Now().Add(-olderThan)
512-
_, err := db.GetEngine(db.DefaultContext).Where("deleted_unix < ?", deleteBefore.Unix()).Delete(new(DeletedBranch))
512+
_, err := db.GetEngine(ctx).Where("deleted_unix < ?", deleteBefore.Unix()).Delete(new(DeletedBranch))
513513
if err != nil {
514514
log.Error("DeletedBranchesCleanup: %v", err)
515515
}
@@ -526,19 +526,19 @@ type RenamedBranch struct {
526526
}
527527

528528
// FindRenamedBranch check if a branch was renamed
529-
func FindRenamedBranch(repoID int64, from string) (branch *RenamedBranch, exist bool, err error) {
529+
func FindRenamedBranch(ctx context.Context, repoID int64, from string) (branch *RenamedBranch, exist bool, err error) {
530530
branch = &RenamedBranch{
531531
RepoID: repoID,
532532
From: from,
533533
}
534-
exist, err = db.GetEngine(db.DefaultContext).Get(branch)
534+
exist, err = db.GetEngine(ctx).Get(branch)
535535

536536
return branch, exist, err
537537
}
538538

539539
// RenameBranch rename a branch
540-
func RenameBranch(repo *repo_model.Repository, from, to string, gitAction func(isDefault bool) error) (err error) {
541-
ctx, committer, err := db.TxContext(db.DefaultContext)
540+
func RenameBranch(ctx context.Context, repo *repo_model.Repository, from, to string, gitAction func(isDefault bool) error) (err error) {
541+
ctx, committer, err := db.TxContext(ctx)
542542
if err != nil {
543543
return err
544544
}

models/git/branches_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ func TestAddDeletedBranch(t *testing.T) {
2020
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
2121
firstBranch := unittest.AssertExistsAndLoadBean(t, &git_model.DeletedBranch{ID: 1})
2222

23-
assert.Error(t, git_model.AddDeletedBranch(repo.ID, firstBranch.Name, firstBranch.Commit, firstBranch.DeletedByID))
24-
assert.NoError(t, git_model.AddDeletedBranch(repo.ID, "test", "5655464564554545466464656", int64(1)))
23+
assert.Error(t, git_model.AddDeletedBranch(db.DefaultContext, repo.ID, firstBranch.Name, firstBranch.Commit, firstBranch.DeletedByID))
24+
assert.NoError(t, git_model.AddDeletedBranch(db.DefaultContext, repo.ID, "test", "5655464564554545466464656", int64(1)))
2525
}
2626

2727
func TestGetDeletedBranches(t *testing.T) {
2828
assert.NoError(t, unittest.PrepareTestDatabase())
2929
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
3030

31-
branches, err := git_model.GetDeletedBranches(repo.ID)
31+
branches, err := git_model.GetDeletedBranches(db.DefaultContext, repo.ID)
3232
assert.NoError(t, err)
3333
assert.Len(t, branches, 2)
3434
}
@@ -65,7 +65,7 @@ func TestRemoveDeletedBranch(t *testing.T) {
6565

6666
firstBranch := unittest.AssertExistsAndLoadBean(t, &git_model.DeletedBranch{ID: 1})
6767

68-
err := git_model.RemoveDeletedBranchByID(repo.ID, 1)
68+
err := git_model.RemoveDeletedBranchByID(db.DefaultContext, repo.ID, 1)
6969
assert.NoError(t, err)
7070
unittest.AssertNotExistsBean(t, firstBranch)
7171
unittest.AssertExistsAndLoadBean(t, &git_model.DeletedBranch{ID: 2})
@@ -74,7 +74,7 @@ func TestRemoveDeletedBranch(t *testing.T) {
7474
func getDeletedBranch(t *testing.T, branch *git_model.DeletedBranch) *git_model.DeletedBranch {
7575
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
7676

77-
deletedBranch, err := git_model.GetDeletedBranchByID(repo.ID, branch.ID)
77+
deletedBranch, err := git_model.GetDeletedBranchByID(db.DefaultContext, repo.ID, branch.ID)
7878
assert.NoError(t, err)
7979
assert.Equal(t, branch.ID, deletedBranch.ID)
8080
assert.Equal(t, branch.Name, deletedBranch.Name)
@@ -86,12 +86,12 @@ func getDeletedBranch(t *testing.T, branch *git_model.DeletedBranch) *git_model.
8686

8787
func TestFindRenamedBranch(t *testing.T) {
8888
assert.NoError(t, unittest.PrepareTestDatabase())
89-
branch, exist, err := git_model.FindRenamedBranch(1, "dev")
89+
branch, exist, err := git_model.FindRenamedBranch(db.DefaultContext, 1, "dev")
9090
assert.NoError(t, err)
9191
assert.Equal(t, true, exist)
9292
assert.Equal(t, "master", branch.To)
9393

94-
_, exist, err = git_model.FindRenamedBranch(1, "unknow")
94+
_, exist, err = git_model.FindRenamedBranch(db.DefaultContext, 1, "unknow")
9595
assert.NoError(t, err)
9696
assert.Equal(t, false, exist)
9797
}
@@ -110,7 +110,7 @@ func TestRenameBranch(t *testing.T) {
110110
}, git_model.WhitelistOptions{}))
111111
assert.NoError(t, committer.Commit())
112112

113-
assert.NoError(t, git_model.RenameBranch(repo1, "master", "main", func(isDefault bool) error {
113+
assert.NoError(t, git_model.RenameBranch(db.DefaultContext, repo1, "master", "main", func(isDefault bool) error {
114114
_isDefault = isDefault
115115
return nil
116116
}))
@@ -144,7 +144,7 @@ func TestOnlyGetDeletedBranchOnCorrectRepo(t *testing.T) {
144144
// is actually on repo with ID 1.
145145
repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
146146

147-
deletedBranch, err := git_model.GetDeletedBranchByID(repo2.ID, 1)
147+
deletedBranch, err := git_model.GetDeletedBranchByID(db.DefaultContext, repo2.ID, 1)
148148

149149
// Expect no error, and the returned branch is nil.
150150
assert.NoError(t, err)
@@ -154,7 +154,7 @@ func TestOnlyGetDeletedBranchOnCorrectRepo(t *testing.T) {
154154
// This should return the deletedBranch.
155155
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
156156

157-
deletedBranch, err = git_model.GetDeletedBranchByID(repo1.ID, 1)
157+
deletedBranch, err = git_model.GetDeletedBranchByID(db.DefaultContext, repo1.ID, 1)
158158

159159
// Expect no error, and the returned branch to be not nil.
160160
assert.NoError(t, err)

models/git/commit_status.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ func (status *CommitStatus) loadAttributes(ctx context.Context) (err error) {
129129
}
130130

131131
// APIURL returns the absolute APIURL to this commit-status.
132-
func (status *CommitStatus) APIURL() string {
133-
_ = status.loadAttributes(db.DefaultContext)
132+
func (status *CommitStatus) APIURL(ctx context.Context) string {
133+
_ = status.loadAttributes(ctx)
134134
return status.Repo.APIURL() + "/statuses/" + url.PathEscape(status.SHA)
135135
}
136136

@@ -162,15 +162,15 @@ type CommitStatusOptions struct {
162162
}
163163

164164
// GetCommitStatuses returns all statuses for a given commit.
165-
func GetCommitStatuses(repo *repo_model.Repository, sha string, opts *CommitStatusOptions) ([]*CommitStatus, int64, error) {
165+
func GetCommitStatuses(ctx context.Context, repo *repo_model.Repository, sha string, opts *CommitStatusOptions) ([]*CommitStatus, int64, error) {
166166
if opts.Page <= 0 {
167167
opts.Page = 1
168168
}
169169
if opts.PageSize <= 0 {
170170
opts.Page = setting.ItemsPerPage
171171
}
172172

173-
countSession := listCommitStatusesStatement(repo, sha, opts)
173+
countSession := listCommitStatusesStatement(ctx, repo, sha, opts)
174174
countSession = db.SetSessionPagination(countSession, opts)
175175
maxResults, err := countSession.Count(new(CommitStatus))
176176
if err != nil {
@@ -179,14 +179,14 @@ func GetCommitStatuses(repo *repo_model.Repository, sha string, opts *CommitStat
179179
}
180180

181181
statuses := make([]*CommitStatus, 0, opts.PageSize)
182-
findSession := listCommitStatusesStatement(repo, sha, opts)
182+
findSession := listCommitStatusesStatement(ctx, repo, sha, opts)
183183
findSession = db.SetSessionPagination(findSession, opts)
184184
sortCommitStatusesSession(findSession, opts.SortType)
185185
return statuses, maxResults, findSession.Find(&statuses)
186186
}
187187

188-
func listCommitStatusesStatement(repo *repo_model.Repository, sha string, opts *CommitStatusOptions) *xorm.Session {
189-
sess := db.GetEngine(db.DefaultContext).Where("repo_id = ?", repo.ID).And("sha = ?", sha)
188+
func listCommitStatusesStatement(ctx context.Context, repo *repo_model.Repository, sha string, opts *CommitStatusOptions) *xorm.Session {
189+
sess := db.GetEngine(ctx).Where("repo_id = ?", repo.ID).And("sha = ?", sha)
190190
switch opts.State {
191191
case "pending", "success", "error", "failure", "warning":
192192
sess.And("state = ?", opts.State)
@@ -241,10 +241,10 @@ func GetLatestCommitStatus(ctx context.Context, repoID int64, sha string, listOp
241241
}
242242

243243
// FindRepoRecentCommitStatusContexts returns repository's recent commit status contexts
244-
func FindRepoRecentCommitStatusContexts(repoID int64, before time.Duration) ([]string, error) {
244+
func FindRepoRecentCommitStatusContexts(ctx context.Context, repoID int64, before time.Duration) ([]string, error) {
245245
start := timeutil.TimeStampNow().AddDuration(-before)
246246
ids := make([]int64, 0, 10)
247-
if err := db.GetEngine(db.DefaultContext).Table("commit_status").
247+
if err := db.GetEngine(ctx).Table("commit_status").
248248
Where("repo_id = ?", repoID).
249249
And("updated_unix >= ?", start).
250250
Select("max( id ) as id").
@@ -257,7 +257,7 @@ func FindRepoRecentCommitStatusContexts(repoID int64, before time.Duration) ([]s
257257
if len(ids) == 0 {
258258
return contexts, nil
259259
}
260-
return contexts, db.GetEngine(db.DefaultContext).Select("context").Table("commit_status").In("id", ids).Find(&contexts)
260+
return contexts, db.GetEngine(ctx).Select("context").Table("commit_status").In("id", ids).Find(&contexts)
261261
}
262262

263263
// NewCommitStatusOptions holds options for creating a CommitStatus
@@ -269,7 +269,7 @@ type NewCommitStatusOptions struct {
269269
}
270270

271271
// NewCommitStatus save commit statuses into database
272-
func NewCommitStatus(opts NewCommitStatusOptions) error {
272+
func NewCommitStatus(ctx context.Context, opts NewCommitStatusOptions) error {
273273
if opts.Repo == nil {
274274
return fmt.Errorf("NewCommitStatus[nil, %s]: no repository specified", opts.SHA)
275275
}
@@ -283,7 +283,7 @@ func NewCommitStatus(opts NewCommitStatusOptions) error {
283283
return fmt.Errorf("NewCommitStatus[%s, %s]: invalid sha: %w", repoPath, opts.SHA, err)
284284
}
285285

286-
ctx, committer, err := db.TxContext(db.DefaultContext)
286+
ctx, committer, err := db.TxContext(ctx)
287287
if err != nil {
288288
return fmt.Errorf("NewCommitStatus[repo_id: %d, user_id: %d, sha: %s]: %w", opts.Repo.ID, opts.Creator.ID, opts.SHA, err)
289289
}
@@ -322,14 +322,14 @@ type SignCommitWithStatuses struct {
322322
}
323323

324324
// ParseCommitsWithStatus checks commits latest statuses and calculates its worst status state
325-
func ParseCommitsWithStatus(oldCommits []*asymkey_model.SignCommit, repo *repo_model.Repository) []*SignCommitWithStatuses {
325+
func ParseCommitsWithStatus(ctx context.Context, oldCommits []*asymkey_model.SignCommit, repo *repo_model.Repository) []*SignCommitWithStatuses {
326326
newCommits := make([]*SignCommitWithStatuses, 0, len(oldCommits))
327327

328328
for _, c := range oldCommits {
329329
commit := &SignCommitWithStatuses{
330330
SignCommit: c,
331331
}
332-
statuses, _, err := GetLatestCommitStatus(db.DefaultContext, repo.ID, commit.ID.String(), db.ListOptions{})
332+
statuses, _, err := GetLatestCommitStatus(ctx, repo.ID, commit.ID.String(), db.ListOptions{})
333333
if err != nil {
334334
log.Error("GetLatestCommitStatus: %v", err)
335335
} else {
@@ -348,8 +348,8 @@ func hashCommitStatusContext(context string) string {
348348
}
349349

350350
// ConvertFromGitCommit converts git commits into SignCommitWithStatuses
351-
func ConvertFromGitCommit(commits []*git.Commit, repo *repo_model.Repository) []*SignCommitWithStatuses {
352-
return ParseCommitsWithStatus(
351+
func ConvertFromGitCommit(ctx context.Context, commits []*git.Commit, repo *repo_model.Repository) []*SignCommitWithStatuses {
352+
return ParseCommitsWithStatus(ctx,
353353
asymkey_model.ParseCommitsWithSignature(
354354
user_model.ValidateCommitsWithEmails(commits),
355355
repo.GetTrustModel(),

models/git/commit_status_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,28 @@ func TestGetCommitStatuses(t *testing.T) {
2222

2323
sha1 := "1234123412341234123412341234123412341234"
2424

25-
statuses, maxResults, err := git_model.GetCommitStatuses(repo1, sha1, &git_model.CommitStatusOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 50}})
25+
statuses, maxResults, err := git_model.GetCommitStatuses(db.DefaultContext, repo1, sha1, &git_model.CommitStatusOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 50}})
2626
assert.NoError(t, err)
2727
assert.Equal(t, int(maxResults), 5)
2828
assert.Len(t, statuses, 5)
2929

3030
assert.Equal(t, "ci/awesomeness", statuses[0].Context)
3131
assert.Equal(t, structs.CommitStatusPending, statuses[0].State)
32-
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[0].APIURL())
32+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[0].APIURL(db.DefaultContext))
3333

3434
assert.Equal(t, "cov/awesomeness", statuses[1].Context)
3535
assert.Equal(t, structs.CommitStatusWarning, statuses[1].State)
36-
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[1].APIURL())
36+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[1].APIURL(db.DefaultContext))
3737

3838
assert.Equal(t, "cov/awesomeness", statuses[2].Context)
3939
assert.Equal(t, structs.CommitStatusSuccess, statuses[2].State)
40-
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[2].APIURL())
40+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[2].APIURL(db.DefaultContext))
4141

4242
assert.Equal(t, "ci/awesomeness", statuses[3].Context)
4343
assert.Equal(t, structs.CommitStatusFailure, statuses[3].State)
44-
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[3].APIURL())
44+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[3].APIURL(db.DefaultContext))
4545

4646
assert.Equal(t, "deploy/awesomeness", statuses[4].Context)
4747
assert.Equal(t, structs.CommitStatusError, statuses[4].State)
48-
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[4].APIURL())
48+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[4].APIURL(db.DefaultContext))
4949
}

0 commit comments

Comments
 (0)