summaryrefslogtreecommitdiffstats
path: root/services/repository
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-11-19 09:12:33 +0100
committerGitHub <noreply@github.com>2022-11-19 16:12:33 +0800
commit044c754ea53f5b81f451451df53aea366f6f700a (patch)
tree45688c28a84f87f71ec3f99eb0e8456eb7d19c42 /services/repository
parentfefdb7ffd11bbfbff66dae8e88681ec840dedfde (diff)
downloadgitea-044c754ea53f5b81f451451df53aea366f6f700a.tar.gz
gitea-044c754ea53f5b81f451451df53aea366f6f700a.zip
Add `context.Context` to more methods (#21546)
This PR adds a context parameter to a bunch of methods. Some helper `xxxCtx()` methods got replaced with the normal name now. Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'services/repository')
-rw-r--r--services/repository/adopt.go2
-rw-r--r--services/repository/branch.go5
-rw-r--r--services/repository/fork.go2
-rw-r--r--services/repository/push.go14
-rw-r--r--services/repository/repository.go4
-rw-r--r--services/repository/template.go2
-rw-r--r--services/repository/transfer.go6
7 files changed, 18 insertions, 17 deletions
diff --git a/services/repository/adopt.go b/services/repository/adopt.go
index 57a21f500c..3895c54c7b 100644
--- a/services/repository/adopt.go
+++ b/services/repository/adopt.go
@@ -96,7 +96,7 @@ func AdoptRepository(doer, u *user_model.User, opts repo_module.CreateRepoOption
return nil, err
}
- notification.NotifyCreateRepository(doer, u, repo)
+ notification.NotifyCreateRepository(db.DefaultContext, doer, u, repo)
return repo, nil
}
diff --git a/services/repository/branch.go b/services/repository/branch.go
index 1328422582..e1f26b89af 100644
--- a/services/repository/branch.go
+++ b/services/repository/branch.go
@@ -11,6 +11,7 @@ import (
"strings"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
@@ -141,8 +142,8 @@ func RenameBranch(repo *repo_model.Repository, doer *user_model.User, gitRepo *g
return "", err
}
- notification.NotifyDeleteRef(doer, repo, "branch", git.BranchPrefix+from)
- notification.NotifyCreateRef(doer, repo, "branch", git.BranchPrefix+to, refID)
+ notification.NotifyDeleteRef(db.DefaultContext, doer, repo, "branch", git.BranchPrefix+from)
+ notification.NotifyCreateRef(db.DefaultContext, doer, repo, "branch", git.BranchPrefix+to, refID)
return "", nil
}
diff --git a/services/repository/fork.go b/services/repository/fork.go
index e597bfa449..a9a2b33ed8 100644
--- a/services/repository/fork.go
+++ b/services/repository/fork.go
@@ -177,7 +177,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork
}
}
- notification.NotifyForkRepository(doer, opts.BaseRepo, repo)
+ notification.NotifyForkRepository(ctx, doer, opts.BaseRepo, repo)
return repo, nil
}
diff --git a/services/repository/push.go b/services/repository/push.go
index 6776ff9f74..e2db18e1f7 100644
--- a/services/repository/push.go
+++ b/services/repository/push.go
@@ -117,7 +117,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
tagName := opts.TagName()
if opts.IsDelRef() {
notification.NotifyPushCommits(
- pusher, repo,
+ db.DefaultContext, pusher, repo,
&repo_module.PushUpdateOptions{
RefFullName: git.TagPrefix + tagName,
OldCommitID: opts.OldCommitID,
@@ -125,7 +125,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}, repo_module.NewPushCommits())
delTags = append(delTags, tagName)
- notification.NotifyDeleteRef(pusher, repo, "tag", opts.RefFullName)
+ notification.NotifyDeleteRef(db.DefaultContext, pusher, repo, "tag", opts.RefFullName)
} else { // is new tag
newCommit, err := gitRepo.GetCommit(opts.NewCommitID)
if err != nil {
@@ -137,7 +137,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
commits.CompareURL = repo.ComposeCompareURL(git.EmptySHA, opts.NewCommitID)
notification.NotifyPushCommits(
- pusher, repo,
+ db.DefaultContext, pusher, repo,
&repo_module.PushUpdateOptions{
RefFullName: git.TagPrefix + tagName,
OldCommitID: git.EmptySHA,
@@ -145,7 +145,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}, commits)
addTags = append(addTags, tagName)
- notification.NotifyCreateRef(pusher, repo, "tag", opts.RefFullName, opts.NewCommitID)
+ notification.NotifyCreateRef(db.DefaultContext, pusher, repo, "tag", opts.RefFullName, opts.NewCommitID)
}
} else if opts.IsBranch() { // If is branch reference
if pusher == nil || pusher.ID != opts.PusherID {
@@ -190,7 +190,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
if err != nil {
return fmt.Errorf("newCommit.CommitsBeforeLimit: %w", err)
}
- notification.NotifyCreateRef(pusher, repo, "branch", opts.RefFullName, opts.NewCommitID)
+ notification.NotifyCreateRef(db.DefaultContext, pusher, repo, "branch", opts.RefFullName, opts.NewCommitID)
} else {
l, err = newCommit.CommitsBeforeUntil(opts.OldCommitID)
if err != nil {
@@ -250,7 +250,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
commits.Commits = commits.Commits[:setting.UI.FeedMaxCommitNum]
}
- notification.NotifyPushCommits(pusher, repo, opts, commits)
+ notification.NotifyPushCommits(db.DefaultContext, pusher, repo, opts, commits)
if err = git_model.RemoveDeletedBranchByName(repo.ID, branch); err != nil {
log.Error("models.RemoveDeletedBranch %s/%s failed: %v", repo.ID, branch, err)
@@ -261,7 +261,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
log.Error("repo_module.CacheRef %s/%s failed: %v", repo.ID, branch, err)
}
} else {
- notification.NotifyDeleteRef(pusher, repo, "branch", opts.RefFullName)
+ notification.NotifyDeleteRef(db.DefaultContext, pusher, repo, "branch", opts.RefFullName)
if err = pull_service.CloseBranchPulls(pusher, repo.ID, branch); err != nil {
// close all related pulls
log.Error("close related pull request failed: %v", err)
diff --git a/services/repository/repository.go b/services/repository/repository.go
index 2f2c27ff20..c369b98aae 100644
--- a/services/repository/repository.go
+++ b/services/repository/repository.go
@@ -32,7 +32,7 @@ func CreateRepository(doer, owner *user_model.User, opts repo_module.CreateRepoO
return nil, err
}
- notification.NotifyCreateRepository(doer, owner, repo)
+ notification.NotifyCreateRepository(db.DefaultContext, doer, owner, repo)
return repo, nil
}
@@ -45,7 +45,7 @@ func DeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_mod
if notify {
// If the repo itself has webhooks, we need to trigger them before deleting it...
- notification.NotifyDeleteRepository(doer, repo)
+ notification.NotifyDeleteRepository(ctx, doer, repo)
}
if err := models.DeleteRepository(doer, repo.OwnerID, repo.ID); err != nil {
diff --git a/services/repository/template.go b/services/repository/template.go
index bb5e3f4668..625bc305de 100644
--- a/services/repository/template.go
+++ b/services/repository/template.go
@@ -101,7 +101,7 @@ func GenerateRepository(doer, owner *user_model.User, templateRepo *repo_model.R
return nil, err
}
- notification.NotifyCreateRepository(doer, owner, generateRepo)
+ notification.NotifyCreateRepository(db.DefaultContext, doer, owner, generateRepo)
return generateRepo, nil
}
diff --git a/services/repository/transfer.go b/services/repository/transfer.go
index a0f4a7685c..2778f2e744 100644
--- a/services/repository/transfer.go
+++ b/services/repository/transfer.go
@@ -55,7 +55,7 @@ func TransferOwnership(doer, newOwner *user_model.User, repo *repo_model.Reposit
}
}
- notification.NotifyTransferRepository(doer, repo, oldOwner.Name)
+ notification.NotifyTransferRepository(db.DefaultContext, doer, repo, oldOwner.Name)
return nil
}
@@ -78,7 +78,7 @@ func ChangeRepositoryName(doer *user_model.User, repo *repo_model.Repository, ne
repoWorkingPool.CheckOut(fmt.Sprint(repo.ID))
repo.Name = newRepoName
- notification.NotifyRenameRepository(doer, repo, oldRepoName)
+ notification.NotifyRenameRepository(db.DefaultContext, doer, repo, oldRepoName)
return nil
}
@@ -127,7 +127,7 @@ func StartRepositoryTransfer(doer, newOwner *user_model.User, repo *repo_model.R
}
// notify users who are able to accept / reject transfer
- notification.NotifyRepoPendingTransfer(doer, newOwner, repo)
+ notification.NotifyRepoPendingTransfer(db.DefaultContext, doer, newOwner, repo)
return nil
}