summaryrefslogtreecommitdiffstats
path: root/services/issue
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-10-11 06:24:07 +0200
committerGitHub <noreply@github.com>2023-10-11 06:24:07 +0200
commitebe803e514acb4eedc884226be2489ee6b4acd28 (patch)
tree3f4d38f8267142dcd0e8df7d76cd4fe04c47b85e /services/issue
parent[skip ci] Updated translations via Crowdin (diff)
downloadforgejo-ebe803e514acb4eedc884226be2489ee6b4acd28.tar.xz
forgejo-ebe803e514acb4eedc884226be2489ee6b4acd28.zip
Penultimate round of `db.DefaultContext` refactor (#27414)
Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'services/issue')
-rw-r--r--services/issue/issue_test.go2
-rw-r--r--services/issue/label.go8
-rw-r--r--services/issue/milestone.go8
-rw-r--r--services/issue/milestone_test.go3
4 files changed, 11 insertions, 10 deletions
diff --git a/services/issue/issue_test.go b/services/issue/issue_test.go
index 1f6a77096e..8806cec0e7 100644
--- a/services/issue/issue_test.go
+++ b/services/issue/issue_test.go
@@ -72,7 +72,7 @@ func TestIssue_DeleteIssue(t *testing.T) {
assert.NoError(t, err)
issue2, err := issues_model.GetIssueByID(db.DefaultContext, 2)
assert.NoError(t, err)
- err = issues_model.CreateIssueDependency(user, issue1, issue2)
+ err = issues_model.CreateIssueDependency(db.DefaultContext, user, issue1, issue2)
assert.NoError(t, err)
left, err := issues_model.IssueNoDependenciesLeft(db.DefaultContext, issue1)
assert.NoError(t, err)
diff --git a/services/issue/label.go b/services/issue/label.go
index 91f0308d9f..6b8070d8aa 100644
--- a/services/issue/label.go
+++ b/services/issue/label.go
@@ -15,7 +15,7 @@ import (
// ClearLabels clears all of an issue's labels
func ClearLabels(ctx context.Context, issue *issues_model.Issue, doer *user_model.User) error {
- if err := issues_model.ClearIssueLabels(issue, doer); err != nil {
+ if err := issues_model.ClearIssueLabels(ctx, issue, doer); err != nil {
return err
}
@@ -26,7 +26,7 @@ func ClearLabels(ctx context.Context, issue *issues_model.Issue, doer *user_mode
// AddLabel adds a new label to the issue.
func AddLabel(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, label *issues_model.Label) error {
- if err := issues_model.NewIssueLabel(issue, label, doer); err != nil {
+ if err := issues_model.NewIssueLabel(ctx, issue, label, doer); err != nil {
return err
}
@@ -36,7 +36,7 @@ func AddLabel(ctx context.Context, issue *issues_model.Issue, doer *user_model.U
// AddLabels adds a list of new labels to the issue.
func AddLabels(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, labels []*issues_model.Label) error {
- if err := issues_model.NewIssueLabels(issue, labels, doer); err != nil {
+ if err := issues_model.NewIssueLabels(ctx, issue, labels, doer); err != nil {
return err
}
@@ -86,7 +86,7 @@ func ReplaceLabels(ctx context.Context, issue *issues_model.Issue, doer *user_mo
return err
}
- if err := issues_model.ReplaceIssueLabels(issue, labels, doer); err != nil {
+ if err := issues_model.ReplaceIssueLabels(ctx, issue, labels, doer); err != nil {
return err
}
diff --git a/services/issue/milestone.go b/services/issue/milestone.go
index 5a07cfd2e5..ff645744a7 100644
--- a/services/issue/milestone.go
+++ b/services/issue/milestone.go
@@ -63,14 +63,14 @@ func changeMilestoneAssign(ctx context.Context, doer *user_model.User, issue *is
}
// ChangeMilestoneAssign changes assignment of milestone for issue.
-func ChangeMilestoneAssign(issue *issues_model.Issue, doer *user_model.User, oldMilestoneID int64) (err error) {
- ctx, committer, err := db.TxContext(db.DefaultContext)
+func ChangeMilestoneAssign(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, oldMilestoneID int64) (err error) {
+ dbCtx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
defer committer.Close()
- if err = changeMilestoneAssign(ctx, doer, issue, oldMilestoneID); err != nil {
+ if err = changeMilestoneAssign(dbCtx, doer, issue, oldMilestoneID); err != nil {
return err
}
@@ -78,7 +78,7 @@ func ChangeMilestoneAssign(issue *issues_model.Issue, doer *user_model.User, old
return fmt.Errorf("Commit: %w", err)
}
- notify_service.IssueChangeMilestone(db.DefaultContext, doer, issue, oldMilestoneID)
+ notify_service.IssueChangeMilestone(ctx, doer, issue, oldMilestoneID)
return nil
}
diff --git a/services/issue/milestone_test.go b/services/issue/milestone_test.go
index 069117d1f1..42b910166f 100644
--- a/services/issue/milestone_test.go
+++ b/services/issue/milestone_test.go
@@ -6,6 +6,7 @@ package issue
import (
"testing"
+ "code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -22,7 +23,7 @@ func TestChangeMilestoneAssign(t *testing.T) {
oldMilestoneID := issue.MilestoneID
issue.MilestoneID = 2
- assert.NoError(t, ChangeMilestoneAssign(issue, doer, oldMilestoneID))
+ assert.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID))
unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{
IssueID: issue.ID,
Type: issues_model.CommentTypeMilestone,