aboutsummaryrefslogtreecommitdiffstats
path: root/services/convert
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-10-03 12:30:41 +0200
committerGitHub <noreply@github.com>2023-10-03 10:30:41 +0000
commitcc5df266808361c1dd3a1d17cbba712826a93d7e (patch)
treef77c59a61d3dc36f07b5b84596e4a1cde12b55cc /services/convert
parent08507e2760638124d75774c29ef37e692a88c02d (diff)
downloadgitea-cc5df266808361c1dd3a1d17cbba712826a93d7e.tar.gz
gitea-cc5df266808361c1dd3a1d17cbba712826a93d7e.zip
Even more `db.DefaultContext` refactor (#27352)
Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'services/convert')
-rw-r--r--services/convert/convert.go6
-rw-r--r--services/convert/git_commit.go2
-rw-r--r--services/convert/issue.go2
-rw-r--r--services/convert/issue_comment.go2
-rw-r--r--services/convert/mirror.go6
-rw-r--r--services/convert/notification.go10
6 files changed, 15 insertions, 13 deletions
diff --git a/services/convert/convert.go b/services/convert/convert.go
index fcb5dd572f..366782390a 100644
--- a/services/convert/convert.go
+++ b/services/convert/convert.go
@@ -119,15 +119,15 @@ func ToBranchProtection(ctx context.Context, bp *git_model.ProtectedBranch) *api
if err != nil {
log.Error("GetUserNamesByIDs (ApprovalsWhitelistUserIDs): %v", err)
}
- pushWhitelistTeams, err := organization.GetTeamNamesByID(bp.WhitelistTeamIDs)
+ pushWhitelistTeams, err := organization.GetTeamNamesByID(ctx, bp.WhitelistTeamIDs)
if err != nil {
log.Error("GetTeamNamesByID (WhitelistTeamIDs): %v", err)
}
- mergeWhitelistTeams, err := organization.GetTeamNamesByID(bp.MergeWhitelistTeamIDs)
+ mergeWhitelistTeams, err := organization.GetTeamNamesByID(ctx, bp.MergeWhitelistTeamIDs)
if err != nil {
log.Error("GetTeamNamesByID (MergeWhitelistTeamIDs): %v", err)
}
- approvalsWhitelistTeams, err := organization.GetTeamNamesByID(bp.ApprovalsWhitelistTeamIDs)
+ approvalsWhitelistTeams, err := organization.GetTeamNamesByID(ctx, bp.ApprovalsWhitelistTeamIDs)
if err != nil {
log.Error("GetTeamNamesByID (ApprovalsWhitelistTeamIDs): %v", err)
}
diff --git a/services/convert/git_commit.go b/services/convert/git_commit.go
index ac15719c1c..ed08691c8b 100644
--- a/services/convert/git_commit.go
+++ b/services/convert/git_commit.go
@@ -210,7 +210,7 @@ func ToCommit(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Rep
// Get diff stats for commit
if opts.Stat {
- diff, err := gitdiff.GetDiff(gitRepo, &gitdiff.DiffOptions{
+ diff, err := gitdiff.GetDiff(ctx, gitRepo, &gitdiff.DiffOptions{
AfterCommitID: commit.ID.String(),
})
if err != nil {
diff --git a/services/convert/issue.go b/services/convert/issue.go
index 33fad31d48..708eac36cf 100644
--- a/services/convert/issue.go
+++ b/services/convert/issue.go
@@ -62,7 +62,7 @@ func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func
if err := issue.Repo.LoadOwner(ctx); err != nil {
return &api.Issue{}
}
- apiIssue.URL = issue.APIURL()
+ apiIssue.URL = issue.APIURL(ctx)
apiIssue.HTMLURL = issue.HTMLURL()
apiIssue.Labels = ToLabelList(issue.Labels, issue.Repo, issue.Repo.Owner)
apiIssue.Repo = &api.RepositoryMeta{
diff --git a/services/convert/issue_comment.go b/services/convert/issue_comment.go
index f2bb4c88f3..b034a50897 100644
--- a/services/convert/issue_comment.go
+++ b/services/convert/issue_comment.go
@@ -55,7 +55,7 @@ func ToTimelineComment(ctx context.Context, repo *repo_model.Repository, c *issu
return nil
}
- err = c.LoadTime()
+ err = c.LoadTime(ctx)
if err != nil {
log.Error("LoadTime: %v", err)
return nil
diff --git a/services/convert/mirror.go b/services/convert/mirror.go
index dade6142a2..249ce2f968 100644
--- a/services/convert/mirror.go
+++ b/services/convert/mirror.go
@@ -4,13 +4,15 @@
package convert
import (
+ "context"
+
repo_model "code.gitea.io/gitea/models/repo"
api "code.gitea.io/gitea/modules/structs"
)
// ToPushMirror convert from repo_model.PushMirror and remoteAddress to api.TopicResponse
-func ToPushMirror(pm *repo_model.PushMirror) (*api.PushMirror, error) {
- repo := pm.GetRepository()
+func ToPushMirror(ctx context.Context, pm *repo_model.PushMirror) (*api.PushMirror, error) {
+ repo := pm.GetRepository(ctx)
return &api.PushMirror{
RepoName: repo.Name,
RemoteName: pm.RemoteName,
diff --git a/services/convert/notification.go b/services/convert/notification.go
index 7f724cf156..0b97530d8b 100644
--- a/services/convert/notification.go
+++ b/services/convert/notification.go
@@ -39,10 +39,10 @@ func ToNotificationThread(ctx context.Context, n *activities_model.Notification)
result.Subject = &api.NotificationSubject{Type: api.NotifySubjectIssue}
if n.Issue != nil {
result.Subject.Title = n.Issue.Title
- result.Subject.URL = n.Issue.APIURL()
+ result.Subject.URL = n.Issue.APIURL(ctx)
result.Subject.HTMLURL = n.Issue.HTMLURL()
result.Subject.State = n.Issue.State()
- comment, err := n.Issue.GetLastComment()
+ comment, err := n.Issue.GetLastComment(ctx)
if err == nil && comment != nil {
result.Subject.LatestCommentURL = comment.APIURL(ctx)
result.Subject.LatestCommentHTMLURL = comment.HTMLURL(ctx)
@@ -52,16 +52,16 @@ func ToNotificationThread(ctx context.Context, n *activities_model.Notification)
result.Subject = &api.NotificationSubject{Type: api.NotifySubjectPull}
if n.Issue != nil {
result.Subject.Title = n.Issue.Title
- result.Subject.URL = n.Issue.APIURL()
+ result.Subject.URL = n.Issue.APIURL(ctx)
result.Subject.HTMLURL = n.Issue.HTMLURL()
result.Subject.State = n.Issue.State()
- comment, err := n.Issue.GetLastComment()
+ comment, err := n.Issue.GetLastComment(ctx)
if err == nil && comment != nil {
result.Subject.LatestCommentURL = comment.APIURL(ctx)
result.Subject.LatestCommentHTMLURL = comment.HTMLURL(ctx)
}
- pr, _ := n.Issue.GetPullRequest()
+ pr, _ := n.Issue.GetPullRequest(ctx)
if pr != nil && pr.HasMerged {
result.Subject.State = "merged"
}